Skip to main content

TamuCTF 2019 pwn challenge 3 write up (ง'̀-'́)ง (day 28)

 Image result for pwning meme

Okay next, let's solve the 3rd challenge

Don't forget to run it first so we know how the program work


ok so the program greet us with some kind of hex value that I expect it was some memory address inside the program. When we enter some strings it doesn't give us anything.




let's load our binary to Ghidra and when I dump all the functions the only functions that caught my eyes are main and echo. The main function doesn't have any particularly interesting function so lets just to the echo function.

Notice that there is gets function again and we should have the ability to cause a buffer overflow in the program

before we start to do some fuzzing, load the binary to Ghidra so we have a more depth understanding of the code.

hmmm, notice that the printed address is the address of the variable that stored our input. I assume we should use that address to place our shellcode but we will get into that later.


create a pattern so we know how much buffer that we need to change the EIP register.





cool! we are able to know how much offset that we need to change the EIP, but let's have a quick look at the security in the binary


Damn! the PIE has enabled this means that the stack address is random and we cannot put our shellcode.

But take a look again at the program when it runs, it shows us the memory of the variable inside the stack and by knowing this location we can craft our program to put the shellcode in the address.


to generate the shellcode I use msfvenom because I'm too lazy to craft it by myself LOL. To craft the payload, I use this formula:

payload = buf+padding+eip

so in the simple term, we put our payload at the start of our variable since we already got the address where we have to jump. Run the program again with our python script and to mimic real-life CTF event I map the program to the port using a socat utility check my previous post on pwn1 on how to set this up.

ok just a little not from me, maybe many of you try to put the padding that contains "\x90" nop sled at the beginning of the payload but when I try to run with this kind of placement in my payload it didn't work.


 yea we got the root shell!

hope you enjoy this write up

references:
https://www.youtube.com/watch?v=1S0aBV-Waeo&t=35s

https://github.com/zst123/tamuctf-2019-writeups/blob/master/Solved/Pwn3/solve.py


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

WriteUp PWN tarzan ROP UNICTF ಠ_ಠ (day 61)

So in this post, I'm going to talk about how to solve the Tarzan pwn challenge from UNICTF 2019. Back in the day when the competition is still going I couldn't finish it and don't have any clue to solve this but this time I was able to finish it :) Also in this post, we will be going to be heavily focused on how to utilize pwntools to construct a ROP chain. If you kinda confused about my explanation in this post you can refer to this following youtube video, link: https://www.youtube.com/watch?v=gWU2yOu0COk I build the python script based on this video Ok, let's get started! In this challenge, you will get two binary first go with tarzan and libc-2.29.so by providing .so file it tell us what version library that the target machine is using this could help us to do ROP chain. first, we run the Tarzan binary to get the basic idea of the program work and as you can see it just show you some text, newline and when you try to input something it doesn't gi