Welcome to RainFall
π Level04 of Rainfall Project π
π Introduction
Hello, today Iβm gonna show you the level04 of rainfall, Well, is pretty much the same level as the level 03.
So the report will be rather short, although an exploit written with pwntools is provided.
π» Objdump Analysis
We can run the following command, To disassemble the binary with the intel assembly syntax.
1 | $ objdump -d ./level4 -M intel |
Once itβs done, the output will be like that
1 | 08048444 <p>: |
So, as you can see we have three functions named respectively main
, n
and p
and the vulnerability is present in p
function.
You can see, the main function call n
function and in n
function a call to fgets@plt
is performed and buffer is allocated like the previous level, and read on STDIN.
So we have an entry input user of 0x200
or 512 bytes in decimal, So we have also talk in last previous level about calling convention, remember in x86-32 bits the argument is passed through the stack in LIFO order.
So to resume, In the n
function we can see that it calls the p
function and if we look a little closer at the p
function
we can see that the first parameter is directly the first argument, which shows that printf
has no constant parameter, so if we throw the binary and write %x
4 times for example, we can read on the stack as on the previous level
Now, if we look at the n function just after the p
function call, we see that an address from the Data segment ds:
is written to the eax register.
The eax
register is then compared with the value 0x1025544
if the condition is triggered then the zero flag is set, we execute the system function with the cat command at address 0x08048590
as the first parameter
with the following command we can look at the addresses corresponding to the symbol in the binary
we note that the address compared with the value in the eax
register is in fact the symbol m
so weβll have to write to the location of the m
symbol we can now create our payload directly with pwntools
π€ Python Exploit
1 | #!/usr/bin/python3 |