Skip to content

Instantly share code, notes, and snippets.

@GuillaumeMorini
Created January 2, 2025 09:38
Show Gist options
  • Select an option

  • Save GuillaumeMorini/9eb01822b01f2081a36c4db09fadf99e to your computer and use it in GitHub Desktop.

Select an option

Save GuillaumeMorini/9eb01822b01f2081a36c4db09fadf99e to your computer and use it in GitHub Desktop.
fcsc2022-misc-a-l-envers
import socket
import re
HOST = "127.0.0.1" # The server's hostname or IP address
PORT = 4000 # The port used by the server
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
data = s.recv(1024)
print("Received",data)
st=re.sub(r'>>> ','',data.decode())
print("extract",st)
while 1:
resp=st[:-1][::-1]+"\n"
print("Sent",resp)
s.sendall(str.encode(resp))
data = s.recv(1024)
print("Received",data)
st=re.sub(r'.*\n>>> ','',data.decode())
print("st:",st)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment