write-ups-challenges-2024-2025/royal-message-decryptor/sol.py
2024-11-25 22:32:28 +01:00

22 lines
482 B
Python

from pwn import *
import string
p = remote("localhost", 3006)
p.recvline()
while True:
msg = p.recvline().decode()
p.recvuntil(b"> ")
print(msg)
alphabet = msg.split(" | ")[0]
message = msg.split(" | ")[1][:-1]
alphabet_map = dict(zip(alphabet, string.ascii_letters))
decoded = "".join([alphabet_map[c] if c in alphabet_map else c for c in message])
print(f"Sending back decoded: '{decoded}'")
p.sendline(decoded.encode())
p.recvline()