如何获得二进制文件的幻数 [英] How to get magic number of a binary file

查看:216
本文介绍了如何获得二进制文件的幻数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个二进制文件都有一个魔幻数字,有人知道如何从文件中检索此信息吗?

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

推荐答案

使用 libmagic file 包中尝试尝试找出文件的类型(如果这是您的目标).

Use libmagic from the file package to try and sniff out the type of file if that's your goal.

Unix上的二进制文件中没有通用的魔术"数字,尽管可能会定义不同的格式.上面的库了解了其中的许多内容,还使用其他各种启发式方法来尝试找出文件的格式/类型.

There are no general "magic" numbers in binary files on unix, though different formats might define their own. The above library knows about many of those and also use various other heuristics to try and figure out the format/type of file.

这篇关于如何获得二进制文件的幻数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆