int __cdecl mainCRTStartup(void) ... return main(__argc, __argv);

The main function (address 0x140001200 ) implements a simple console UI:

// 2. Compute a 32‑bit “hash” of the transformed buffer uint32_t h = 0xFFFFFFFF; for (int i = 0; i < 9; ++i) h ^= buf[i]; for (int j = 0; j < 8; ++j) if (h & 1) h = (h >> 1) ^ 0xEDB88320; // CRC‑32 (polynomial 0xEDB88320) else h >>= 1;

Find an input string s (9 bytes) such that CRC32( b_0 … b_8 ) == 0x56C9A4F2 . 4.2. CRC‑32 is linear over GF(2) CRC‑32 with a fixed polynomial is a linear operation:

# 3. Invert the per‑byte transform to get the actual serial serial_bytes = bytes(invert_transform(b) for b in transformed) serial = serial_bytes.decode('latin-1') # keep raw bytes, printable check later print("[+] Serial candidate:", serial)

# Instead of a complicated generic reverse, we exploit the fact that # CRC‑32 with polynomial 0xEDB88320 is reversible byte‑by‑byte. # The following tiny routine does it: def reverse_crc_bytes(target, nbytes): crc = target out = [] for _ in range(nbytes): # The low byte of the CRC is the byte that was processed last, # after the forward step it becomes (crc ^ byte) & 0xFF. # So to reverse, we take the low byte as the original data byte. b = crc & 0xFF out.append(b) crc = (crc ^ TABLE[b]) >> 8 return list(reversed(out))

def crc32_step_rev(crc, b): """Reverse one CRC‑32 step (process byte b at the *end* of the stream).""" # The forward step is: crc = (crc >> 8) ^ TABLE[(crc ^ b) & 0xFF] # Reversing: idx = (crc ^ b) & 0xFF prev_crc = (crc ^ TABLE[idx]) << 8 prev_crc |= idx return prev_crc & 0xFFFFFFFF

# Inverse table: given a CRC value and a trailing byte, find the prior CRC INV_TABLE = ((crc ^ b) & 0xFF) : (crc ^ b) >> 8 for b in range(256) for crc in range(256)

# ------------------------------------------------------------ if __name__ == "__main__": TARGET = 0x56C9A4F2

The program uses the insecure gets_s but limits to 63 characters – no overflow. The real work is in check_serial . 3.3. The serial‑checking routine In Ghidra the function is named check_serial (address 0x140001560 ). Its decompiled pseudo‑code (after some renaming) looks like this:

t(i) = ROL8( c_i XOR 0x5A, 3 ) ROL8 rotates an 8‑bit value left by 3 bits.

def reverse_crc(target_crc, length): """Return the list of bytes that must have been fed to the CRC to get target_crc.""" # Walk backwards length steps, assuming the *last* processed byte is unknown. # We'll treat each step as "what byte could we have processed last?" # Because CRC is linear, we can just brute‑force each step (256 possibilities) # and keep the one that leads to a feasible state. With 9 steps it is trivial. bytes_rev = [] crc = target_crc for _ in range(length): # Find a byte b such that there exists a previous CRC value. # Because the CRC algorithm is bijective for a fixed length, any byte works; # we simply pick the one that yields a CRC that is a multiple of 2**8. # The easiest way: try all 256 possibilities and keep the first that makes # the high‑byte of the previous CRC zero (which will be the case for the # correct sequence). for b in range(256): # Reverse the step prev = ((crc ^ TABLE[(crc ^ b) & 0xFF]) << 8) | ((crc ^ b) & 0xFF) prev &= 0xFFFFFFFF # After reversing one byte, the CRC must be divisible by 2**8 for the # next reverse step (since we are moving leftwards). This property holds # for the true sequence. if (prev & 0xFF) == 0: bytes_rev.append(b) crc = prev >> 8 break else: raise RuntimeError("No suitable byte found – something went wrong") return list(reversed(bytes_rev))