#!/usr/bin/env python3 """CodeShell.kr - Glass Register (Reversing, 200p) solver. Recovers the accepted 33-byte input from 03_glass_register_Ytqr6gK.bin. Same family as opcode-picnic / switchyard: - strlen(argv[1]) == 0x21 (33) - .rodata @0x2020: 33-byte reversed index table (32,31,...,1,0) - .rodata @0x2060: 33 expected accumulator low-bytes - per outer round i the accumulator low byte depends only on (i, input[32-i]) so every input byte is brute-forced independently over 0..255 Register-level model validated against a live GDB trace (see findings). Differences vs opcode-picnic: - inner loop runs 11 rounds (cmp edi,0xb), not 4 - seed constant 0x4a9a4ce9 instead of 0x9f80c83a - final acceptance additionally requires acc_low(last) != r13 (inverted cmp) """
import sys
M32 = 0xFFFFFFFF
defrol32(x, c): c &= 31 return ((x << c) | (x >> (32 - c))) & M32 if c else x & M32
defrol8(x, c): c &= 7 return ((x << c) | (x >> (8 - c))) & 255if c else x & 255