Welcome to RainFall

π Level00 of Rainfall Project π
π Introduction
We have access to the level0 user via SSH. Inside the home directory, we find a setuid binary named level0.
1 | level0@RainFall:~$ ls -la |
π Executing the Binary
Running the binary without arguments results in a segmentation fault, while providing any argument simply prints βNo !β. π€
1 | level0@RainFall:~$ ./level0 |
Letβs analyze it using gdb!
π΅οΈ Reverse Engineering with GDB
π οΈ Disassembling main
1 | Dump of assembler code for function main: |
π§© Understanding the Assembly Code
sub esp, 0x20β Allocates 32 bytes (equivalent to 256 bits) of stack space for local variables.mov eax, DWORD PTR [ebp+0xc]β Loads the pointer toargv, which is stored atebp+0xc.add eax, 0x4β Moves toargv[1](since pointers are 4 bytes in x86).mov eax, DWORD PTR [eax]β Loads the value ofargv[1](the first argument given to the program).call atoiβ Convertsargv[1]from a string to an integer.cmp eax, 0x1a7β Compares the result with 423 (0x1A7 in hex).
If the comparison is successful, the program spawns a shell! π
π― Exploiting the Binary
We simply run the binary with 423 as an argument:
1 | level0@RainFall:~$ ./level0 423 |
π We now have access to level1! π
π Retrieving the Flag
Once inside the level1 home directory, we can grab the .pass file:
1 | $ cd ../level1 |
π Conclusion
This level was a simple integer comparison check.
By passing 423 as an argument, we were able to execute a privileged shell and retrieve the next levelβs credentials! π
π― Key Takeaways:
- π οΈ Understanding stack manipulation (
sub esp, 0x20ex: allocate memory on stack space). - π§© Pointer arithmetic in C (
argv[1]is at ebp+0xc). - π₯ Exploiting integer comparisons to pop a shell !.