环境:
xp ps3
VS 2008 release版本, 禁用优化
IDA
参考:
https://www.52pojie.cn/thread-495464-1-1.html
《0day安全 软件漏洞分析技术》 11.4
漏洞代码:
#include<stdafx.h>
#include<stdlib.h>
#include<string.h>
char shellcode[]="\x90\x90\x90\x90 .... ";
void test(char * input){
char str[200];
strcpy(str,input);
int zero=0;
zero=1/zero;
}
void main(){
char * buf=(char *)malloc(500);
strcpy(buf,shellcode);
test(shellcode);
}
思路:
使用 test() 函数中 strcpy() 栈溢出 覆盖 S.E.H 异常处理函数地址,使其指向 堆 中的shellcode 。
构造的除0异常会触发异常,程序调用异常处理,
因为异常处理函数的指针指向的是堆空间,而SafeSEH对指向堆空间的异常处理函数指针是直接校验通过的,所以直接执行shellcode。