In Level 13 of the SnowCrash project by 42 school, you are provided with a 32-bit binary file named level13. When executed, the binary outputs the following message:
./level13
1
UID 2013 started us but we expect 4242
Binary Analysis
To analyze the binary, you can use the objdump command to disassemble it and inspect the main function. Here is the command and relevant output:
The key instruction to focus on is at address 0x804859a:
1
0x804859a: 3d 92 10 00 00 cmp eax,0x1092
This instruction compares the eax register with 0x1092 (which is 4242 in decimal). To successfully execute the binary and obtain the flag, eax needs to be set to 4242.
Exploitation Process
To exploit this binary, you can use a debugger like GDB (with the GEF extension) or any other debugger of your choice. Here are the steps using GDB:
Start GDB with the binary
1
gdb ./level13
Set a breakpoint at the critical instruction:
1
gdb> b *0x804859a
Run the binary:
1
gdb> run
Overwrite the eax register before the comparison:
1
gdb> set$eax=0x1092
Verify the value of eax:
1
gdb> info registers eax
Continue execution to complete the binary and obtain the flag:
1
gdb> c
Conclusion
By following the above steps, you will be able to bypass the UID check in the binary and retrieve the token. Use the token to connect with the flag13 user and get the flag.
This level illustrates the importance of understanding assembly instructions and utilizing debugging tools to manipulate the execution flow of a binary.