Shimbles the E-L-F
Reverse Engineering · BearcatCTF 2025 · Nyla
Problem

Utilizing Ghidra allows us to see functions effectively.
Main function
Two_layer_decrypt function
Explanation
undefined8 main(void)
undefined8 main(void)The main function simulates a decryption challenge from Schimbles the gnome:
Introduction: Prints an ASCII art gnome and taunts the user.
User Input: Prompts the user for a decryption key, reads input, and compares it with an encrypted key.
Key Validation:
Decrypts the encrypted key using
two_layer_decryptwith parameters(local_e1, key_length, 0xaa, 3, 0x5f, 2).If the input matches, it decrypts and displays the flag with parameters
(local_d8, flag_length, 0x77, 4, 0x3c, 3).If incorrect, it decrypts and shows a taunt with parameters
(local_b8, taunt_length, 0x6d, 2, 0x33, 5).
Stack Integrity: Checks for stack corruption at the end.
void two_layer_decrypt(long param_1, ulong param_2, byte param_3, undefined4 param_4, byte param_5, undefined4 param_6)
void two_layer_decrypt(long param_1, ulong param_2, byte param_3, undefined4 param_4, byte param_5, undefined4 param_6)This function decrypts a byte array using two XOR and rotation layers:
First Layer: XORs each byte with
param_5, then rotates byparam_6.Second Layer: XORs the result with
param_3, then rotates byparam_4.Stores Decrypted Byte: Updates the byte array with the final decrypted value.
This function is used to decrypt keys, flags, and taunts in the main function.
Finding the key
The
xcommand in GDB is used for examining memory.8bspecifies that you want to view 8 bytes (thebstands for byte) of memory.x/8bxtells GDB to show the bytes in hexadecimal format.0x4010is the memory address you are examining. You provided the address0x4010to GDB to inspect the contents at that specific location in memory.

Solution
Run the binary file and enter the key.
Last updated