Skip to content

Commit

Permalink
Attempt to send payload three times
Browse files Browse the repository at this point in the history
  • Loading branch information
mc-17 committed Jan 9, 2022
1 parent b5c2bee commit 6e9e45b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions sender.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import time
import socket


def send(ip, port, file):
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM, proto=0)
client_socket.settimeout(3000)
client_socket.connect((ip, port))
for i in range(3):
print(f"Sending payload: attempt {i}...")
time.sleep(1)
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM, proto=0)
client_socket.settimeout(3000)
client_socket.connect((ip, port))

try:
with open(file, "rb") as fp:
client_socket.sendfile(fp)
finally:
client_socket.close()
try:
with open(file, "rb") as fp:
client_socket.sendfile(fp)
print(f"Sending payload: attempt {i} succeeded!")
break
finally:
client_socket.close()

0 comments on commit 6e9e45b

Please sign in to comment.