当前位置:网站首页>win32:堆破壞的dump文件分析
win32:堆破壞的dump文件分析
2022-07-03 17:52:00 【修的什麼真】
- win32堆結構
在解决實際問題以前,先來了解一下相關概念
1. 堆結構
堆->段->塊
堆是由段,段是由塊組成的,塊就是用戶最終向系統申請的虛擬內存的數據結構。(目前我們用戶態程序只需要理解塊就可以了)
2. _HEAP_ENTRY結構
每個堆,每個段,每個塊都會有相應的_HEAP_ENTRY結構,裏面描述了該區域內容的信息。比如塊的_HEAP_ENTRY結構就存放了所屬的堆,段,前項大小和當前大小等信息。
- windbg堆的相關命令
- 查看所有堆的概覽信息:!heap -s
- 某個堆所有的段和塊信息:!heap -a 0xXXXXXXXX
- 查看某個內存地址所在的_HEAP_ENTRY信息:!heap -x 0xXXXXXXXX
- 統計某個堆的概覽信息:!heap -stat -h 0xXXXXXXXX
- 列出所有大小為X的塊地址:!heap -flt s X
- 查看堆的調試支持:!gflag
- 查看內存塊的內容 dc 0xXXXXXXXX
- 堆破壞的調試
1. 什麼叫做堆破壞
堆破壞其實就是塊破壞,由於對超出地址所在分配的空間讀寫,導致破壞了_HEAP_ENTRY結構(如果是CRT堆,就是破壞了CRT堆的末尾檢查結構,甚至破壞了下一個塊的結構)
2. 一個堆破壞的例子

這裏故意寫了一個越界的操作,編譯成release版本,用windbg掛上去

查看一下ptr的值

查看一下ptr所在的_HEAP_ENTRY結構,發現屬於00b30000這個堆,在00b34420這個塊裏面


我們看到上述塊後續的塊都已經被破壞,所以堆破壞的特征基本就長這樣。但是該例程並不會導致崩潰。
3. 總結一下分析思路
a) 找到該崩潰的塊所在的堆(可以根據地址範圍判斷)。
b) 查看該堆所有塊信息。
c) 從最後一個尚未被破壞的塊找到相應的信息。(如果業務邏輯是從小往大地址寫,就會破壞往後塊,否則就是相反)
边栏推荐
- Hongmeng third training
- Hongmeng fourth training
- Golang unit test, mock test and benchmark test
- link preload prefetch
- How to read the source code [debug and observe the source code]
- Codeforces Round #803 (Div. 2) C. 3SUM Closure
- Notes on problems -- watching videos on edge will make the screen green
- Gear2021 monthly update - December
- AcWing 3438. 数制转换
- [combinatorics] recursive equation (four cases where the non-homogeneous part of a linear non-homogeneous recursive equation with constant coefficients is the general solution of the combination of po
猜你喜欢
随机推荐
Research on Swift
1146_ SiCp learning notes_ exponentiation
Ml (machine learning) softmax function to realize the classification of simple movie categories
ES6类的继承
ArrayList分析3 : 删除元素
Postfix tips and troubleshooting commands
Discussion sur la logique de conception et de mise en oeuvre du processus de paiement
AcWing 4489. 最长子序列
Codeforces Round #803 (Div. 2) C. 3SUM Closure
Leetcode540: a single element in an ordered array
vs2013已阻止安装程序,需安装IE10
MySQL grouping query
Tensorboard quick start (pytoch uses tensorboard)
1147_ Makefile learning_ Target files and dependent files in makefile
How to purchase Google colab members in China
国内如何购买Google Colab会员
VM11289 WAService. js:2 Do not have __ e handler in component:
面试官:值为 nil 为什么不等于 nil ?
Automata and automatic line of non-standard design
聊聊支付流程的设计与实现逻辑








