如何查找编译可执行文件的语言?
给定一个应用程序的可执行文件(Windows、Linux 或 Mac OS X),是否有办法找出用于编写该应用程序的编程语言?
Given a executable file (Windows, Linux or Mac OS X) of an application, is there a way to figure out the programming language that was used to write that application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在一般情况下,我认为不会。然而,在特定情况下,这是可能的。
In the general case, I would think not. In a specific case, however, it might be possible.
除非有一些与其相关的特定元数据或与该 exe 相关的某些语言特定功能,否则极不可能。可执行文件(通常)是为特定平台编译的代码或为特定语言即时编译的中间代码。对于 JIT 代码,您也许能够确定它是 .NET 还是其他某种生成中间代码的语言,但在大多数情况下,这是一项相当困难且不合理的任务。我可能是错的,但根据我的理解,这是不可能的。
Highly unlikely unless there is some specific metadata associated with it or some language specific feature associated with that exe. Executables are (usually) code compiled for a specific platform or intermediate code that will be just-in-time compiled for a specific language. In the case of JITed code you might be able to determine if its .NET or some other language that produces an intermediate code but for the most part this is a fairly difficult and unreasonable task. I could be wrong but from my understanding this isn't possible.
我不妨晚点回答。
即使给定编程语言的编译器决定丢弃一些元数据,例如数据部分中的符号,并带有诸如“从 Joe 的 C 编译器版本 4.1.104 编译”之类的消息,也没有什么——没有什么能阻止我编写 Go 编译器它将相同的消息写入数据部分的相同位置,以欺骗毫无戒心的人查看可执行文件。
更不用说可以为任何给定语言编写无数的编译器。
假设我们查看一个仅包含几个字节的可执行文件......只不过是增加一个寄存器。数百种不同的语言都允许编译器理论上可以优化为无元数据的单节可执行文件。
答案是否定的。
TL;DR:你总是可以欺骗。
I might as well throw in a late answer.
Even if a compiler for a given programming language decides to throw out some metadata such as symbols in a data section with a message like "Compiled from Joe's C compiler version 4.1.104" nothing -- nothing at all stops me from writing a Go compiler that writes the same message into the same location in the data section to trick unsuspecting people looking at the executable.
Not to mention there are an infinite number of compilers that can be written for any given language.
And suppose we look at an executable containing just a few bytes.... say nothing more than incrementing a register. Hundreds of different languages admit compilers that in theory could optimize down to a metadata-free, single section executable.
The answer is simply no.
TL;DR: You can always spoof.