house of orange
house of orange 不是什麼梗,而是一道題目的名字,hitcon 2016ctf house of orange
用到的套路
- 溢出攻擊top chunk的size,泄露libc_base和heap_base
- unsorted bin更改_IO_list_all值
- file stream oriented attack
參考博客
angleboy大佬的write-up
https://github.com/scwuaptx/CTF/blob/master/2016-writeup/hitcon/houseoforange.py
http://4ngelboy.blogspot.tw/2016/10/hitcon-ctf-qual-2016-house-of-orange.html
angleboy大佬_IO_FILE總結
http://4ngelboy.blogspot.tw/2017/11/play-with-file-structure-yet-another.html
泄露libc
雖然trunk不在末尾,但是'\0'
不是read讀入的終止符。所以可以溢出到top trunk的size字段,再次malloc時,
通過多次溢出泄露libc和heap值,從而根據偏移量計算出libc base和heap base。
更改_IO_list_all值
通過unsorted bin attack更改_IO_list_all值爲main_arena的unsorted bin的地址值。
僞造_IO_FILE鏈
一共僞造2個_IO_FILE鏈。unsorted bin爲第一個_IO_FILE頭地址,第一個_IO_FILE的chain爲small bin[4],
第二個爲trunk頭。