Simple tool to verify if an ELF binary needs 32-bit or 64-bit architecture.
7d813a460ffed1a22f27976531bfa21e90d2e83608e2011d3d91286db1fd484b
/* A simple tool to verify if an elf runs on 32 or 64bit arch by WarGame. For more visit http://vx.netlux.org/wargamevx */
#include <stdio.h>
#include <elf.h>
char *GetELFType(char *fn)
{
unsigned char e_ident[EI_NIDENT];
FILE *fp = fopen(fn,"r");
if(fp == NULL)
{
return "error opening";
}
fread(e_ident,EI_NIDENT,1,fp);
fclose(fp);
switch(e_ident[EI_CLASS])
{
case ELFCLASS32:
return "ELF32";
break;
case ELFCLASS64:
return "ELF64";
break;
default:
return "UNKNOWN";
break;
}
}
int main(int argc,char *argv[])
{
int f_cnt;
if(argc == 1)
{
printf("32or64elf by WarGame\n");
printf("Usage: %s <elf1> <elf2> ... <elfn>\n",argv[0]);
return 1;
}
for(f_cnt = 1;f_cnt < argc;f_cnt++)
printf("%s: %s\n",argv[f_cnt],GetELFType(argv[f_cnt]));
return 0;
}