Loading... # 漏洞分类为: 缓冲区溢出:向缓冲区填充的数据超过了缓冲区本身,导致原本数据被覆盖。 1. 缓冲区溢出: 1. 堆溢出 2. 栈溢出 2. 整形溢出: 1. 存储溢出 2. 运算溢出 3. 符号问题 3. UAF(USE-AFter-Free) 4. ShellCode --- # 栈溢出: <span style="color:#FFFF00">先进后出原则</span> 栈是从高地址到低地址的方向。向栈里压栈,之后pop从栈里取出参数。 在调用函数的事和传入的参数,从右向左依次PUSH压入栈,在调用CALL的时候把下一个EIP的地址也压入栈中,在返回到下一个命令执行的地址的时候需要用到push到这个空间的地址。 ![image.png](http://www.irohane.top/usr/uploads/2021/01/690925003.png) ## 正常拷贝 ![image.png](http://www.irohane.top/usr/uploads/2021/01/2883035616.png) ![image.png](http://www.irohane.top/usr/uploads/2021/01/3592950060.png) ## 溢出拷贝 利用局部变量空间直接在栈中分配,在拷贝的时候并没有对要拷贝大小做出严格判断,导致的栈溢出 ![image.png](http://www.irohane.top/usr/uploads/2021/01/3571850032.png) ![image.png](http://www.irohane.top/usr/uploads/2021/01/2021876154.png) ![image.png](http://www.irohane.top/usr/uploads/2021/01/2283022956.png) 在这里的栈溢出只会造成程序的崩溃,如果利用返回地址就可以让程序跳到自己编写的代码块继续执行。 ![image.png](http://www.irohane.top/usr/uploads/2021/01/2912691106.png) ## 代码 ```cpp #include <iostream> #include <stdio.h> #include <Windows.h> void FunText(char *buf) { char buf_[8]; memcpy(buf_, buf,64); return; } int main() { char buf[64] = { 0 }; memset(buf, 0x41, 64); FunText(buf); return 1; } ``` # 堆溢出 堆-是一种数据结构,非连续性,由开发者自行分配,向高位扩展。链表遍历,由低向高进行。 堆溢出: - 给堆里面的变量赋予超过其分配的空间大小的值,堆链表的后续链表数据会被覆盖所致。 下图根据-加密与解密堆溢出的图样来画出的,但是在WIN 10 中堆变了样。无法演示。 ![image.png](http://www.irohane.top/usr/uploads/2021/01/2444185951.png) # 整型漏洞溢出 整形区分有符号和无符号类型,有符号类型最高位会被当成符号位来进行表示,所以表示的范围就缩减了一半。 整形漏洞包括三个: - 存储溢出 - 计算溢出 - 符号问题 ## 存储溢出 由不同存储类型的数据造成的。 ```cpp int len = 0x32768 short len2 = len ``` len2 无法容纳 len的全部,导致与预期的不同。即len2等于0 ![image.png](http://www.irohane.top/usr/uploads/2021/01/84748497.png) ## 运算溢出 原因: - 在进行操作的时候,对两个运算的数,并没有考虑到超出的范围。导致运算之后的值,超出了范围。 最后修改:2021 年 01 月 19 日 © 允许规范转载 赞 0 如果觉得我的文章对你有用,请随意赞赏