简单的缓冲区溢出

      这是一个简单的缓冲区溢出程序,是我在Oday上面学到的,嘿嘿嘿,每个人写的shellcode不一样所以实现的目的也不一样。。。。

 

  大家自由发挥吧。

 

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>

#define PASSWORD "1234567"
int verify_password(char *password)
{
int authenticated;
char buffer[44];
authenticated = strcmp(password, PASSWORD);
strcpy(buffer, password);
return authenticated;
}

int main()
{
int valid_flag = 0;
char password[1024];
FILE *fp;
LoadLibrary("user32.dll"); //prepare for messagebox
if (!(fp = fopen("password.txt", "rw")))
{
exit(0);
}
fscanf(fp, "%s", password);
valid_flag = verify_password(password);
if(valid_flag)
{
printf("incorrect password\n\n");
}
else
{
printf("congratulation!!!!!\n\n");
}

getchar();

return 0;
}

posted @ 2012-09-22 10:54  crazypurple  阅读(140)  评论(0编辑  收藏  举报