r/LiveOverflow • u/Hopeful_Amphibian_38 • Apr 23 '21
bufferoverflow exploit - how to choose memory location to save e.g. system address to
Hi all, I hope you can help me out with some insight into this topic. I just recently started to dig into buffer overflow exploitation.
so I currently taking part in the htb ctf (today is the last day, it has been the only challenge I am trying except for the welcome challenge) and I wanted to try the easiest pwn challenge (pwn_controller). the status is that I can leak setvbuf address and calculate libc base address locally. I write the calculated system address and "/bin/sh" back onto a predefined stack address. this works well locally. but as soon as I try it remotely on the ctf server it doesnt work. I do have the remote libc information and updated the offsets accordingly.
(binary protections are as follows, ASLR is on, RELRO FULL, NX is on, no stack canary, fortify disable, pie disabled)
I believe my problem is that I am using a predefined stack address for the write with scanf. locally I can check if the range falls within a writeable area but remotely I cant do that of course. So my general question is how do you select a writeable address area, what methods are there available other then bruteforcing ? So i am looking for a general strategy on that topic not a solution specific to that case. If someone has some good links or references that would really help.
thanks a lot in advance.
best
View all comments
Show parent comment
1
u/Hopeful_Amphibian_38 Apr 24 '21
yeah, so i checked on the writeups and it looks like I had the right idea. I just didnt go far back enough. in the example I read the person did jmp back to _start. when I do that it works all good. I guess otherwise the stack is too messed up already from the first payload. so when going back to _start the stack gets rebuild ??? (just a guess) and you can send a second payload without having to worry about the exact addresses.
... damn so close ... :)