题目
文件
1
2
3
4
5
6
7
8
9
10root@261f8c67866c:/pwn/wnote# file wnote
wnote: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=684d0cb0365cd02a87cff0614e93e462659047d0, not stripped
64位elf文件动态链接
root@261f8c67866c:/pwn/wnote# checksec wnote
[*] '/pwn/wnote/wnote'
Arch: amd64-64-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: PIE enabled功能
1
2
3
4
5
6
7
8
9
10== Welcome to WOLLEY note manager V1.12 ==
== 1. Add note ==
== 2. Edit note ==
== 3. Delete note ==
== 4. Encrypt note ==
== 5. Decrypt note ==
== 6. List one note ==
== 7. List all note ==
== 8. Exit note ==
== Enter a number to start... ==数据结构
1
2
3
4
5calloc(1uLL, 0x1E0uLL); 存放结构体数组
note 结构体
0x0 ptr
0x8 size
0x10 encrypt#加密标志
漏洞
1 | if ( size > 0x20 ) |
- 可以分配的堆快大小受到限制,只能得到0x20 0x50 0x80 大小的堆块。
0x00-0x20 | input_size 0x20 |
---|---|
0x21-0x3f | 0x40 |
0x40 | (input_size +0xf)&0xf |
0x41-0x7f | 0x80 |
0x80-0x400 | (input_size+0xf)&0xf |
- 输入size为0x40 或大于0x7f时会产生溢出
漏洞利用
- info leak
- FD leak addr
- 通过溢出修改size造成overlap
- 将数组中两个ptr指向同一个堆
- unsortbin leak libc
- fastbin leak heap
- FD leak addr
- hijack rip
- unsortbin attack io_list_all
- 通过溢出伪造堆块大小为0x60(fake file struct),free
- 再次malloc,触发_IO_flush_all_lockp getshell
exp
- info leak
1 | from pwn import * |