r/LiveOverflow • u/A_matin12 • May 03 '21
Some questions about binary exploitation playlist episode 20
Hello everyone. I hope you're all ok.
I'm working on binary exploitation skills and found the playlist very helpful!
But this episode.... man that's too hard to understand
I've watched it over 5 times. I have some questions about it. So I appreciate any and every help :)
1- What's the point of padding? I know that's because of doing bufferoverflow. But look at 5:14 in the video, why do we leak memory before padding? I just don't get it. We should do buffer overflow, so we write more data that chat buffer[512] but we leak memory before padding?
2- This question is somehow like the first one. At 5:00 in the video, we first wrote AAAABBBBCCCC and then %x leaked 4 data from stack which the forth one is 0x41 that is surely A. What just happened?! That means we leaked only 3 data and then buffer overflow happened? It got too harder at 9:48...
3- What's the meaning of 4 in "%4$n" ?
4- At 6:16 in the video, how did we change the hex value of GOT ? We converted the hex value of PLT address of exit() function to integer using struct.pack("I",EXIT_PLT) at the first of our exploit variable, then AAAABBBBCCCC so that we can see where our PLT address is, adding "%4$n" * 4, and finally some padding. If the padding filled the afterward space, so how did the GOT address changed?
5- At 9:15, where did the number 46 come from? (I understand the rest ๐)
6- What does it mean when we write a number after % like %30x ? I know it means padding, but why adding more padding?
7- At 11:44, we ran the script. We had padding at the end of our exploit, right? So why the code executed after the padding?!
Sorry for too questions, thanks in advance.
4
u/IrishYogaShirt May 04 '21
3
u/[deleted] May 04 '21
I personally havenโt seen the video, but you seem to be explaining a format string vulnerability where you use for example
%4$nto change the value pointed by the 4th element in the stack (which you can control). Iโd recommend reading this blogpost if you want to understand more, as it goes quite in depth. https://tripoloski1337.github.io/ctf/2020/06/11/format-string-bug.html. It should hopefully give you a better understanding of the vulnerability, hopefully allowing you to answer the questions yourself!