怎样得到shellcode?
- 提问者网友:戎马万世
- 2021-04-13 03:36
- 五星知识达人网友:梦中风几里
- 2021-04-13 03:52
你直接拿去用去吧。不给你解释了
void ShellCodeGenerater(char *file)
{
int iFileSize;
FILE *fp = NULL;
fp = fopen(file, "rb");
if( fp == NULL )
{
printf("Error: Unable to open %s!\n", file);
exit(1);
}
//计算文件大小
fseek(fp, 0, SEEK_END);
iFileSize = ftell(fp);
fseek(fp, 0, SEEK_SET);
BYTE bb;
char *buff = new char[iFileSize+2];
if( fgets(buff, iFileSize+1, fp) == NULL )
{
printf("Error: Unable to read from file.\n");
exit(1);
}
FILE* myfile;
myfile = fopen("ShellCode.txt","w");
// fprintf(myfile,"#include <stdio.h>\n");
fprintf(myfile,"char shellcode[] = \n");
fprintf(myfile, "\"");
for( int i=0 ; i < iFileSize ; i++ )
{
bb = buff[i];
fprintf(myfile,"\\x%2.2X", bb);
if(i%20==0)
{
fprintf(myfile,"\"");
fprintf(myfile,"\n\"");
}
}
fclose(fp);
return;
}