|
|||||||||||
|
RE: Automatic discovery of shellcode address
From: Adam Gilmore <vuln(at)optusnet.com.au>
Date: Mon Mar 24 2003 - 08:44:08 EST In fact I'm sure you'd find the vast majority of normal stack overflow exploits using this idea. Also, I find an easier method to find the shellcode address is trial and error. i.e. gdb ./myprog, run `perl -e'print "A"x1000'` - wait for the segfault, take a look at esp/ebp then do a dump of say.. x/255xb. Chances are if you subtract/add a little with either esp or ebp, you're bound to find your 0x41 0x41 0x41 somewhere =)
-----Original Message-----
Hi, During the course of this work I had an interesting idea, and I thought I'd post it here for comments. There are many programs which are exploitable via user supplied variables such as command line arguments, and environmental variables. When these inputs are not adequately bounds tested they can be used to subvert control flow. A common method of exploitation is to run a program with a long argument, and see if EIP is overtaken, for example: /usr/bin/foo `perl -e "print 'a' x 1000'` If this is vulnerable you'd see something like "cannot access memory at 0x41414141". This indicated that you've managed to overwrite ESP, with an address you control. After that it's endgame - it's just a matter of working out where your shellcode may be placed and the magic offsets to modify to point to it. Whilst this isn't terribly difficult it's a time consuming and fragile process. (Maybe that's just me!) Knowing the direction the stack goes down all you need to do is overwrite the memory with: # shellcode # address of the start of the buffer x 1000 If the start of the buffer being copied to is know then stick the shellcode there, and afterwards just append that address, so that all the likely return pointers are left sticking at your shellcode in a known location. (OK LD_PRELOAD doesn't work for setuid binaries, but typically copying the target to your machine will work, and you're safe as the displayed addresses won't change). Does this sound reasonable, or am I imagining things? I wrote a small textfile on it, available below, (note it's still work in progress): http://www.steve.org.uk/Hacks/preload.txt Steve --- www.steve.org.ukReceived on Mon Mar 24 13:14:55 2003 This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 14:07:38 EDT |
||||||||||
|
|||||||||||