from pwn import remote import re from base64 import b64decode from sympy import factorint from Crypto.Util.number import bytes_to_long, inverse, long_to_bytes with remote("d7c40d8ec4e734fe7ac812f9-1338-shadows-of-neon-city.challenge.cscg.live", "1337", ssl=True) as conn: data = conn.recvuntil(b":\n").decode("utf-8") print(data) matches = re.findall(r'(\w+)\s*=\s*([\w/=+]+)', data) locals().update({key: value if not value.isdigit() else int(value) for key, value in matches}) cipher = bytes_to_long(b64decode(cipher)) p,q = factorint(n).keys() n = p * q phi_n = (p-1) * (q-1) d = inverse(e, phi_n) plain_int = pow(cipher, d, n) plaintext = long_to_bytes(plain_int) conn.sendline(plaintext) conn.interactive()