Use HEX to find file type

13,318

If you are using Linux or Unix. You can type

$ file filename

Or you can use HEX signatures of the file. refere this. http://www.garykessler.net/library/file_sigs.html

or use third party library "magic.h" library known as "libmagic" and use if in c++ like this.

#include <stdio.h>
#include "magic.h" 
int main() {   
  magic_t myt = magic_open(MAGIC_CONTINUE|MAGIC_ERROR/*|MAGIC_DEBUG*/|MAGIC_MIME);
  magic_load(myt,NULL);   printf("magic output: '%s'\n",magic_file(myt,YOURFILENAME)); 
  magic_close(myt);

  return 0; 
}
Share:
13,318
Mavenkp
Author by

Mavenkp

Updated on June 04, 2022

Comments

  • Mavenkp
    Mavenkp almost 2 years

    I got a file and i don't know its type. I tried to run tools to get file type but that was of no use. When I open the file in hex editor it shows 00 hex value from starting to certain address(50 +linse). I know we can find type of file by seeing hex code of the file. But in this case it is showing 00. Can any one help how to find file type using hex value? Is there any way to obscure hex information so that file type can be hide.