2024-09-06 23:55:31 +02:00
|
|
|
from io import BufferedRWPair
|
|
|
|
import socket
|
|
|
|
|
|
|
|
REMOTE = "127.0.0.1"
|
2024-09-08 04:18:56 +02:00
|
|
|
PORT = 1338
|
2024-09-06 23:55:31 +02:00
|
|
|
|
|
|
|
def main() -> int:
|
|
|
|
s = socket.socket()
|
|
|
|
s.connect((REMOTE, PORT))
|
|
|
|
sf: BufferedRWPair = s.makefile('rwb')
|
|
|
|
|
|
|
|
pl = int.to_bytes(1337, 2, "big")
|
|
|
|
|
|
|
|
_ = send(sf, pl)
|
2024-09-08 04:18:56 +02:00
|
|
|
_ = recv(sf).decode()
|
2024-09-06 23:55:31 +02:00
|
|
|
|
|
|
|
sf.close()
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def send(sf: BufferedRWPair, msg: bytes) -> int:
|
|
|
|
print(f"> {msg.hex()}")
|
|
|
|
sent: int = sf.write(msg + b"\n")
|
|
|
|
sf.flush()
|
|
|
|
return sent
|
|
|
|
|
|
|
|
def recv(sf: BufferedRWPair) -> bytes:
|
|
|
|
response = sf.readline().strip()
|
|
|
|
print(f"< {response}")
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
exit(main())
|