forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TFTP::Client retransmit lost data blocks on upload
Retransmit data blocks until we receieve a matching ACK.
- Loading branch information
David Barksdale
committed
Jun 9, 2015
1 parent
9fa4234
commit 91a06fb
Showing
1 changed file
with
20 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,21 +302,27 @@ def send_data(host,port) | |
yield "Sending #{expected_size} bytes (#{expected_blocks} blocks)" | ||
end | ||
data_blocks.each_with_index do |data_block,idx| | ||
req = [OpData, (idx + 1), data_block].pack("nnA*") | ||
if self.server_sock.sendto(req, host, port) > 0 | ||
sent_data += data_block.size | ||
end | ||
res = self.server_sock.recvfrom(65535) | ||
if res | ||
code, type, msg = parse_tftp_response(res[0]) | ||
if code == 4 | ||
sent_blocks += 1 | ||
yield "Sent #{data_block.size} bytes in block #{sent_blocks}" if block_given? | ||
else | ||
if block_given? | ||
yield "Got an unexpected response: Code:%d, Type:%d, Message:'%s'. Aborting." % [code, type, msg] | ||
while true | ||
req = [OpData, (idx + 1), data_block].pack("nnA*") | ||
self.server_sock.sendto(req, host, port) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
amatus
Owner
|
||
res = self.server_sock.recvfrom(65535) | ||
if res | ||
code, type, msg = parse_tftp_response(res[0]) | ||
if code == 4 | ||
if type == idx + 1 | ||
sent_blocks += 1 | ||
sent_data += data_block.size | ||
yield "Sent #{data_block.size} bytes in block #{idx+1}" if block_given? | ||
break | ||
else | ||
next | ||
end | ||
else | ||
if block_given? | ||
yield "Got an unexpected response: Code:%d, Type:%d, Message:'%s'. Aborting." % [code, type, msg] | ||
end | ||
break | ||
end | ||
break | ||
end | ||
end | ||
end | ||
|
The return value of sendto() should be checked