可执行文件 - 如何用 ASCII 识别它们
看起来所有 EXE 文件以 ASCII 模式打开时都以 MZ 开头,vbs、com 和 bat 文件也有 ASCII 标识吗?我似乎找不到模式...
或者也许还有另一种方法来识别它们?除了扩展之外...
It looks like all EXE files begin with MZ when they are opened in ASCII mode, is there an ASCII identified for vbs, com and bat files as well? i can't seem to find a pattern...
Or maybe there's another way to identify them? aside from just the extension...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,不是真的(Windows 可执行文件可以在开头有 PE 或 PK 而不是 MZ - 查看其他可能的格式)。
对于其他类型的文件,您可以使用某些启发式方法(例如,GIF 文件以“GIF89”开头,Bash shell 脚本通常以
#!/bin/bash
开头,BAT 文件通常执行@echo off
在开头,VBS 脚本在行首使用撇号作为注释标记),但它们并不总是 100% 可靠(一个文件可以是 BAT脚本和 Bash shell 脚本;或者既是有效的 ZIP 存档又是有效的 GIF 图像的文件(例如 剑龙图像),例如)。请参阅本文以进一步阅读。
No, not really (Windows executables can have PE or PK at the beginning instead of MZ - see this for other possible formats).
For other types of files, there are certain heuristics you can use (e.g. GIF files start with "GIF89", Bash shell scripts usually start with
#!/bin/bash
, BAT files often execute@echo off
at the beginning, VBS scripts use apostrophe at the start of line as a comment marker), but they aren't always 100% reliable (a file can be both a BAT script and a Bash shell script; or a file that's both a valid ZIP archive and a valid GIF image (like that stegosaurus image), for example).See e.g. this article for further reading.
TrID 似乎有一个“独立”应用程序,您可以使用它传递文件并读出内容并查看它是什么文件。它以能够向其传递通用文件(或不带扩展名)而自豪,并且它使用文件的标头来发现它实际上是什么文件类型。
TrID seems to have a "standalone" application you could probably use and pass the file in and read the contents out and see what file it is. It prides itself on the ability to pass it a generic file (extension or without) and it uses the headers of the file to discover what file type it actually is.
看看本教程是否有帮助(如何检测可执行文件的类型 3 系列 )。他甚至提出了如何做到这一点的分步算法。
另请参阅这篇文章:如何确定文件是否可执行?
See if this tutorial is helpful (How to detect the types of executable files 3 part series). He has even presented a step by step algorithm on how to do this.
Also see this post: How to determine if a file is executable?