Description
I have a friend that enjoys coding and he hasn't stopped talking about a snake recently He left this file on my computer and dares me to uncover a secret phrase from it. Can you assist?
Setup
Bytecode reversing
Download the bytecode file snake and examine it with tools like uncompyle6 or Python's dis module.
Translate the extracted logic into a new Python script that performs the inverse XOR operations.
wget https://artifacts.picoctf.net/c_titan/31/snake && \
python3 your_decrypt.py
Solution
- Step 1Recover the keyDisassembly shows key_str being built into t_Jo3. Convert that string into a key list of ordinals.
- Step 2Recreate the input listThe bytecode stores the ciphertext integers in a list (input_list). Copy those numbers into your script.
- Step 3XOR decryptExtend the keystream until it matches input_list length, XOR each pair, and join the characters to reveal the flag.result = ''.join(chr(a ^ b) for a,b in zip(input_list, key_list))
Flag
picoCTF{N0t_sO_coNfus1ng_sn@ke_30a...}
The decrypted string from the XOR routine is the final flag.