Encryptinator
05/04/2023
By: unvariant
Tags: pwn TAMUCTF-2023Problem Description:
I have made this super secure encryption engine. I'll encrypt any message and no one will ever be able to read it. Not even me!
Hints:
Reveal Hints
NoneSolve script
from pwn import *
p = remote("tamuctf.com", 443, ssl=True, sni="encryptinator")
p.sendlineafter(b"> ", b"1")
p.sendlineafter(b": ", b"A")
p.sendlineafter(b"> ", b"2")
p.sendlineafter(b": ", str(0).encode())
p.recvuntil(b":\n")
enc = p.recvline()[:64]
print(f"enc: {enc}")
p.sendlineafter(b"> ", b"2")
p.sendlineafter(b": ", str(-3112).encode())
p.recvuntil(b":\n")
iv = p.recvline()[:16]
print(f"iv: {iv}")
p.sendlineafter(b"> ", b"2")
p.sendlineafter(b": ", b"-3248")
p.recvuntil(b":\n")
rng = p.recvline()[:64]
print(f"rng: {rng}")
def unhex (s):
assert(len(s) % 2 == 0)
result = []
for i in range(0, len(s), 2):
result.append(int(s[i:i+2], 16))
return result
enc = unhex(enc)
iv = unhex(iv)
rng = unhex(rng)
flag = ""
for i in range(len(enc)):
flag += chr(enc[i] ^ rng[i] ^ iv[i % 8])
print(flag)