例题 Asis CTF 2016 b00ks
`
1. 安全策略
[*] '/root/ctf/Other/pwn/heap/b00ks'
Arch: amd64-64-little
RELRO: Full RELRO
Stack: No canary found
NX: NX enabled
PIE: PIE enabled
开启了full RELRO,因此无法直接进行GOT表劫持。开启了PIE,也导致不能直接用引用静态分析的地址。
2. 静态分析
程序的功能是对图书的增删改查。
1. Create a book
2. Delete a book
3. Edit a book
4. Print book detail
5. Change current author name
6. Exit
一个图书对象由3个chunk组成:name-chunk,description-chunk和detail-chunk。其中name-chunk和description-chunk的大小和内容均由用户决定;detail-chunk的结构如下所示
| prev_size |
| size: 0x20 |
| bookID |
| name-chunk ptr |
| desc-chunk ptr |
| desc size |
溢出点
程序中逐字节写入的函数0x1009f5
存在off-by-one漏洞,假设要写入的内存大小是0x20,使用该函数写入时会将0x21个字节覆盖为\x00
。分析可以发现,写入author name、book name、book content时会引用该函数从而导致溢出。
利用溢出
Author name储存在0x302040
开始的32字节的内存中,而0x302060开始的内存空间存储的是现有的book的detail chunk的指针。这里的话存在两种利用方式
- 在没有bo