提交 569979b6 创建 作者: 赵鹏翀's avatar 赵鹏翀

init template

上级
/Debug
/Release
<?xml version="1.0" encoding="gb2312"?>
<ASMProject Version="1.00" Name="Lab011" TemplatePath="console(c)\Project" ProjectID="6b019acd-27a3-490e-83c2-12b33b04d51b" IsSubmitWork="0">
<Configurations>
<Configuration Name="Debug" DebuggerFlavor="0">
<Tool Name="PreBuildEventTool"/>
<Tool Name="CustomBuildTool"/>
<Tool Name="GCCCompilerTool" PreprocessorDefinitions="_DEBUG" GenerateDebugInformation="-1" LanguageStandard="c99"/>
<Tool Name="PreLinkEventTool"/>
<Tool Name="GCCLinkerTool"/>
<Tool Name="PostBuildEventTool"/>
</Configuration>
<Configuration Name="Release" DebuggerFlavor="0">
<Tool Name="PreBuildEventTool"/>
<Tool Name="CustomBuildTool"/>
<Tool Name="GCCCompilerTool" PreprocessorDefinitions="NDEBUG" LanguageStandard="c99"/>
<Tool Name="PreLinkEventTool"/>
<Tool Name="GCCLinkerTool" StripDebugInfo="-1"/>
<Tool Name="PostBuildEventTool"/>
</Configuration>
</Configurations>
<Files>
<Filter Name="ͷļ" Filter="h;hpp;hxx">
<File RelativePath=".\console.h">
</File>
</Filter>
<Filter Name="Դļ" Filter="cpp;c;cc;cxx">
<File RelativePath=".\console.c">
</File>
</Filter>
</Files>
</ASMProject>
添加文件
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
//构造攻击字符串
char hacker[32] = "0123456789" // 注意以\0作为字符串结尾
"\0";
void buffer_overflow(void)
{
printf("缓冲区异常,返回地址错误!\n");
exit(0);
}
int func(int a, int b)
{
char buffer[8];
memcpy(buffer, hacker, 8); // 构造好攻击字符串后,将复制的长度修改为32
int sum = a + b;
return sum;
}
int main()
{
int result = func(2, 3);
printf("2 + 3 = %d\n", result);
return 0;
}
#ifndef _CONSOLE_H_
#define _CONSOLE_H_
#include <stdio.h>
/* TODO: 在此处引用程序需要的其他头文件 */
#endif /* _CONSOLE_H_ */
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论