最近看到的一个弧注入的题目,了解一下原理
首先弧注入就是在不写入任何可执行代码的情况下注入程序,调用原有的库函数,达到攻击的目的,在Linux下使用较多,这次以windows为例
源程序
#include <stdio.h>
#include <windows.h>
#include <string>
#define PASSWORD "1234567"
int verify_password (char *password)
{
int authenticated;
char buffer[44];
authenticated=strcmp(password,PASSWORD);
// strcpy(buffer,password);//over flowed here!
memcpy(buffer,password,150);//over flowed here!
return authenticated;
}
main()
{p
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");
}
else
{
printf("Congratulation! You have passed the verification!\n");
}
fclose(fp);
}
因为strcpy有00字符串结尾标志的限制,所以使用memcpy函数直接拷贝内存
实验目的是调用messageboxA函数实现弹窗功能
先是函