Mavenkp
Mavenkp

Reputation: 27

Use HEX to find file type

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.

Upvotes: 2

Views: 21395

Answers (2)

Ankit Singh
Ankit Singh

Reputation: 2622

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; 
}

Upvotes: 2

Jan Hudec
Jan Hudec

Reputation: 76346

No, there is not. The hex editor always shows real content (if it has permission to read the file at all).

Most binary file formats start with magic number, but not all of them. However bunch of nul bytes at the beginning looks more like the file is simply corrupt.

Upvotes: -1

Related Questions