1 Star 0 Fork 0

Eternal/how2heap

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Educational Heap Exploitation

This repo is for learning various heap exploitation techniques. We came up with the idea during a hack meeting, and have implemented the following techniques:

File Technique Glibc-Version Patch Applicable CTF Challenges
first_fit.c Demonstrating glibc malloc's first-fit behavior.
calc_tcache_idx.c Demonstrating glibc's tcache index calculation.
fastbin_dup.c Tricking malloc into returning an already-allocated heap pointer by abusing the fastbin freelist. latest
fastbin_dup_into_stack.c Tricking malloc into returning a nearly-arbitrary pointer by abusing the fastbin freelist. latest 9447-search-engine, 0ctf 2017-babyheap
fastbin_dup_consolidate.c Tricking malloc into returning an already-allocated heap pointer by putting a pointer on both fastbin freelist and unsorted bin freelist. latest Hitcon 2016 SleepyHolder
unsafe_unlink.c Exploiting free on a corrupted chunk to get arbitrary write. latest HITCON CTF 2014-stkof, Insomni'hack 2017-Wheel of Robots
house_of_spirit.c Frees a fake fastbin chunk to get malloc to return a nearly-arbitrary pointer. latest hack.lu CTF 2014-OREO
poison_null_byte.c Exploiting a single null byte overflow. latest PlaidCTF 2015-plaiddb, BalsnCTF 2019-PlainNote
house_of_lore.c Tricking malloc into returning a nearly-arbitrary pointer by abusing the smallbin freelist. < 2.31 unknown
overlapping_chunks.c Exploit the overwrite of a freed chunk size in the unsorted bin in order to make a new allocation overlap with an existing chunk < 2.29 patch hack.lu CTF 2015-bookstore, Nuit du Hack 2016-night-deamonic-heap
overlapping_chunks_2.c Exploit the overwrite of an in use chunk size in order to make a new allocation overlap with an existing chunk < 2.29 patch
mmap_overlapping_chunks.c Exploit an in use mmap chunk in order to make a new allocation overlap with a current mmap chunk latest
house_of_force.c Exploiting the Top Chunk (Wilderness) header in order to get malloc to return a nearly-arbitrary pointer < 2.29 patch Boston Key Party 2016-cookbook, BCTF 2016-bcloud
unsorted_bin_into_stack.c Exploiting the overwrite of a freed chunk on unsorted bin freelist to return a nearly-arbitrary pointer. < 2.29 patch
unsorted_bin_attack.c Exploiting the overwrite of a freed chunk on unsorted bin freelist to write a large value into arbitrary address < 2.29 patch 0ctf 2016-zerostorage
large_bin_attack.c Exploiting the overwrite of a freed chunk on large bin freelist to write a large value into arbitrary address latest 0ctf 2018-heapstorm2
house_of_einherjar.c Exploiting a single null byte overflow to trick malloc into returning a controlled pointer latest Seccon 2016-tinypad
house_of_orange.c Exploiting the Top Chunk (Wilderness) in order to gain arbitrary code execution < 2.26 unknown Hitcon 2016 houseoforange
house_of_roman.c Leakless technique in order to gain remote code execution via fake fastbins, the unsorted_bin attack and relative overwrites. < 2.29 patch
tcache_dup.c Tricking malloc into returning an already-allocated heap pointer by abusing the tcache freelist. 2.26 - 2.28 patch
tcache_poisoning.c Tricking malloc into returning a completely arbitrary pointer by abusing the tcache freelist. > 2.25
tcache_house_of_spirit.c Frees a fake chunk to get malloc to return a nearly-arbitrary pointer. > 2.25
house_of_botcake.c Bypass double free restriction on tcache. Make tcache_dup great again. > 2.25
tcache_stashing_unlink_attack.c Exploiting the overwrite of a freed chunk on small bin freelist to trick malloc into returning an arbitrary pointer and write a large value into arbitraty address with the help of calloc. > 2.25 Hitcon 2019 one punch man
fastbin_reverse_into_tcache.c Exploiting the overwrite of a freed chunk in the fastbin to write a large value into an arbitrary address. > 2.25

The GnuLibc is under constant development and several of the techniques above have let to consistency checks introduced in the malloc/free logic. Consequently, these checks regularly break some of the techniques and require adjustments to bypass them (if possible). We address this issue by keeping multiple versions of the same technique for each Glibc-release that required an adjustment. The structure is glibc_<version>/technique.c.

Have a good example? Add it here! Try to inline the whole technique in a single .c -- it's a lot easier to learn that way.

Heap Exploitation Tools

There are some heap exploitation tools floating around.

shadow

jemalloc exploitation framework: https://github.com/CENSUS/shadow

libheap

Examine the glibc heap in gdb: https://github.com/cloudburst/libheap

heap-viewer

Examine the glibc heap in IDA Pro: https://github.com/danigargu/heap-viewer

heapinspect

A Python based heap playground with good visualization for educational purposes: https://github.com/matrix1001/heapinspect

Forkever

Debugger that lets you set "checkpoints" as well as view and edit the heap using a hexeditor: https://github.com/haxkor/forkever

Malloc Playground

The malloc_playground.c file given is the source for a program that prompts the user for commands to allocate and free memory interactively.

Pwngdb

Examine the glibc heap in gdb: https://github.com/scwuaptx/Pwngdb

Other resources

Some good heap exploitation resources, roughly in order of their publication, are:

Hardening

There are a couple of "hardening" measures embedded in glibc, like export MALLOC_CHECK_=1 (enables some checks), export MALLOC_PERTURB_=1 (data is overwritten), export MALLOC_MMAP_THRESHOLD_=1 (always use mmap()), ...

More info: mcheck(), mallopt().

There's also some tracing support as mtrace(), malloc_stats(), malloc_info(), memusage, and in other functions in this family.

MIT License Copyright (c) 2020 Shellphish Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

学习heap中相关漏洞利用技术的调试文件,来源:GitHub 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tordan/how2heap.git
git@gitee.com:tordan/how2heap.git
tordan
how2heap
how2heap
master

搜索帮助