Skip to main content

WriteUp PWN whatsyourname UNICTF ( ͠° ͟ʖ ͡°) (day 39)


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
Show the disassemble of main function using gdb:


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

Popular posts from this blog

Having fun analyzing nginx log to find malicious attacker in the net (ง'̀-'́)ง (day 37)

  What makes you sleepless at night? is it because of a ghost or scary stories? is it because you have an important meeting tomorrow? or is it because you have an exam? For me, what keeps me up all night is that I keep thinking about what happens to a website that I just created, is it safe from an attacker (certainly not) or did I missing some security adjustments that lead to vulnerability? well I'm not the best secure programmer in the world, I'm still learning and there is a big possibility that I can make a mistake but for me, a mistake can be a valuable investment to myself or yourself to be better so from this idea, I want to know more about what attackers casually do when attacking a website. Here in this post, I'm going to show you how I analyzed attack to the website that I have permission to design and also some interesting findings that I could get from the analysis Background: All of this analysis comes from the traffic that is targeted to th...

Utilize Pwntools for crafting ROP chain :') (day 69)

who doesn't like pwntools? it is a very versatile tool and can be customized according to our need using the python script but did you need to know that pwntools itself can help us to automatically craft a rop chain for us? so in this post, I will show you how to make rop chain less painful and make pwntools do all the heavy lifting. To demonstrate this I will use the binary challenge callme 64 bit from ropemporium link: https://ropemporium.com/challenge/callme.html Crashing the app: Like any other exploitation process, we need to crash the program by generating a long string pattern to determine the offset. based on the information from the above figure we can see that we required to provide 40 bytes of offset Fun stuff: now this where the fun stuff began write the following python script: as in the guideline of the challenged said we need to chain the function call by first to call the callme_one function, callme_two function and then callme_three funct...

Bypassing stack canaries protection :') (day 51)

In my previous blogs, I show you guys how to bypass some common protection usually used in Linux binary such as NX and ASLR but this time we are going to take it to the next level we are going to talk about protection employ in the modern Linux OS which is "The Canaries" and how to bypass it. note: this post was not originally mined it was inspired by the following resources https://ctf-wiki.github.io/ctf-wiki/pwn/linux/mitigation/canary/ (Credit goes to the author) we are going to start this post about what is stack canaries and types of different implementation of it then move to the implementation about how to bypass this protection. We are going to focus on "leak canaries" technique What is stack canary: In layman terms, canaries are just another protection mechanism to prevent stack overflow implemented by appending 4/8 bytes value (depend on the architecture) into the stack when a function is entered. When the function is at the end of its exec...