How to get magic number of a binary file

前端 未结 6 1667
傲寒
傲寒 2020-12-06 06:13

There is a magic number associated with each binary file , does anyone know how to retrieve this information from the file?

6条回答
  •  执笔经年
    2020-12-06 07:15

    There is a file command which in turn uses a magic library, the magic library reads from a file found in /etc called magic (this is installation dependant and may vary), which details what are the first few bytes of the file and tells the file what kind of a file it is, be it, jpg, binary, text, shell script. There is an old version of libmagic found on sourceforge. Incidentally, there is a related answer to this here.

    Hope this helps, Best regards, Tom.

提交回复
热议问题