The UNICTF event is over, it was one of the competitions that was hosted by the infamous hack the box and I should say that this competition is fun yet challenging for me I was able to finish 2 problems from the platform I cannot do more of them since I have my class that day. But overall I enjoy every step on solving the challenges
(in the meantime I'm going to solve the other challenges of reversing and pwn)
(Kudos to all my teammates even though we only get 25th places from 67 but hey! we have a lot of fun)
Let's start with the easiest one (since I'm still a noob) the "WhatsYourName" challenge.
So it was categorized as pwn question.
Let's have a quick look at the file security mechanism and it seems that the Non Executable mode is on in this binary we are not able to inject a shellcode in here sadly :(. But the PIE is disabled it means the binary address will remain static
when we run it just shows us a prompt and waiting for input after that it will not give us any further information.
Dump the function we got this list:
There are four functions that actually caught my attention:
- main
- initialize
- exploitme (definitely going to see this)
- win
Ok, so the main function actually calling the initialize functions and exploitme
Have a quick look at initialize function first:
inside the functions it's calling the function of setvbuf and alarm. setvbuf used to set the environment whereas alarm is just as a timeout mechanism if the program is idle about 1e => 30 seconds it will trigger the alarm and exit the code
Next, disassemble the function of exploitme:
AHA! we got the famous gets function that known vulnerable to buffer overflow
let's try to create a script that will brute force how many padding that we need to overwrite the offset.
ok it starts when the padding fill with 56 characters of "A" and we can test it inside the gdb
cool! we able to alter the eip register
but where we want to redirect it?
do you remember the "win" function that I just listed at the beginning of the post? Let's check it out it may contain something useful for us
so the function here contains a system function but what is the param that was passed to it?
open it in ghidra and go to that function.
okay so we see now that it is clear to go to the win function so we can get the flag
I create a flag.txt file so it mimics the real-life scenario (it will contain "you got me" strings)
ok so here is the problem, by concept in order to route the flow of the program to win function the payload supposed to be like this
but unfortunately, it hit a segmentation fault. I spend hours trying to figure out what is wrong with the payload but I arrive at the conclusion that the address that I was used is not completely correct due to the stack register is interfere with the system function, so I just use the next address which is 0x00000000004006c8 and walaa! it works
It also works outside the GDB and we got the flag :)
That's all folks
I hope you enjoy my post :D
Comments
Post a Comment