缓冲区溢出

其实呢 就是拷贝字符串或者内存时,在栈里把返回地址给改了,改到自己制定位置,达到“执行任意代码作用”,一般是自己精心构造的shellcode。

一般利用可信软件过杀毒软件,或者达到内核中执行任意代码。

下面是我的一个小例子:

git:https://github.com/xjp342023125/Code/trunk/Src/Test/StackOverflow

需要编译时把check GS关闭。

// StackOverflow.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <cstdio>
#include <cstring>

template<int nBufSize,int nZhanSize>
struct sStackOverFlow
{
char szZhanWei[nZhanSize];
void* addrRet;
char sz[nBufSize];
};

void fff()
{
printf("ccccccccccc");
}
void outstr(int a,const char *p)
{
char sz[10];
strcpy(sz,p);
printf("%s %d",sz,a);
}

int _tmain(int argc, _TCHAR* argv[])
{
sStackOverFlow<10,0xc+4> ssss;
memset(ssss.szZhanWei,1,0xc+4);
ssss.addrRet = fff;
outstr(111,(char*)&ssss);
getchar();
return 0;
}

原文地址:https://www.cnblogs.com/xujinping/p/4373623.html