java 可以读取.exe文件吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16355280/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
is it possible to read .exe file?
提问by user2346177
I want to make a project for identifying malicious software. so is it possible to read .exe file to look for the malicious part? if yes how.
我想做一个识别恶意软件的项目。那么是否可以读取 .exe 文件来查找恶意部分?如果是的话如何。
回答by AlSki
Until an exe runs its just a binary file, so yes you can read it. However a binary file doesn't have lines, its just a constant stream.
直到 exe 运行它只是一个二进制文件,所以是的,你可以阅读它。然而,二进制文件没有行,它只是一个常量流。
Most virus checkers use some form of pattern recognition where they are looking for a pattern of bytes, that might be either instructions or messages, within the file. If you find enough of these to match a known virus then you flag the file as problematic.
大多数病毒检查程序使用某种形式的模式识别,它们在文件中查找字节模式,可能是指令或消息。如果您发现这些文件足以匹配已知病毒,那么您可以将该文件标记为有问题。
回答by matzone
You have to read .EXE file as binary and you don't have to execute it to read inside
您必须将 .EXE 文件作为二进制文件读取,而不必执行它来读取内部文件
回答by Ahmed KRAIEM
is it possible to read .exe without executing it
是否可以在不执行的情况下读取 .exe
Yes, sure.
是的,当然。
is it possible to read .exe file line by line
是否可以逐行读取 .exe 文件
In theory, you can. But I doubt that that's what you want.
理论上,你可以。但我怀疑这就是你想要的。
You shoul read binary files (ie. exe) in chunks of bytes.
您应该以字节块的形式读取二进制文件(即 exe)。
回答by Drona
Reading an executable file does not execute it. Besides, an executable file is a stream of binary data and hence it may not contain newline characters. Hence, reading it line by line does not make sense. You need to read byte by byte.
读取可执行文件并不会执行它。此外,可执行文件是二进制数据流,因此它可能不包含换行符。因此,逐行阅读是没有意义的。您需要逐字节读取。
回答by Angel.King.47
I am not sure exacly what you mean by read line by line, do you mean that reading the actuall code. If so, then not exactly. However you can read the compiled code, using tools such as hexdump
or gdb
我不确定你所说的逐行阅读是什么意思,你的意思是阅读实际代码。如果是这样,那么不完全是。但是,您可以使用诸如hexdump
或 之类的工具读取编译后的代码gdb
hexdump
will allow you to look at the actually binary of the file. You can use multiple formats.Given the hexdump you can read the binary and devise a program that works out the inner workings and determine the issue.
hexdump
将允许您查看文件的实际二进制文件。您可以使用多种格式。给定十六进制转储,您可以读取二进制文件并设计一个程序来解决内部工作并确定问题。
gdb
allows you to look at the skeleton of a program in a much more readable format. however for gdb to work the program has to be compiled with debug flags.
gdb
允许您以更具可读性的格式查看程序的骨架。但是要让 gdb 工作,程序必须使用调试标志进行编译。
There is however another program called strace
. That shows you all the calls to the kernel a program makes. However this will execute the program. Maybe running in a sandbox may help.
然而,还有另一个程序叫做strace
. 这显示了程序对内核的所有调用。但是,这将执行程序。也许在沙箱中运行可能会有所帮助。
The tools I mentoned are already compiled programs that allow you to do things you are after. But you can just read the file byte by byte and determine what your program thinks is malicious.
我提到的工具是已经编译好的程序,可以让你做你想做的事情。但是您可以逐字节读取文件并确定您的程序认为是恶意的。
Hope this helps
希望这可以帮助
回答by Evgeniy Dorofeev
No, you cannot read exe file line by line because it's a binary file, there are no lines in it.
不,您不能逐行读取 exe 文件,因为它是一个二进制文件,其中没有行。