Panitia CTF

← Back

Wreck IT Final 2021

Custom Encryption (Reversing)

We solve the problem without reversing or knowing the exact algorithm 👀

from pwn import *

enc = sys.argv.pop().encode()

for i in range(1, len(enc)):
    p = process(['CustomEncryption', cyclic(i)], level='critical')
    if len(p.recv()) == len(enc):
        break

result, log = '', log.progress('Decrypt')
while len(result) < i:
    try:
        for guess in string.printable:
            p = process([
                'CustomEncryption',
                result + guess * (i - len(result))
            ], level='critical')

            GAP = (len(result) * 5) + 6

            log.status(result + guess)

            if enc[:GAP] == p.recv()[:GAP]:
                result += guess
                break
    except:
        result = result[:-1]
        break

log.success(result)