参考Dalvik或Java虚拟机?

时间:2021-05-05 05:00:59

I am looking into Dalvik bytecode currently but as I lack a compiler background, I am finding it a little hard to grasp the design. I am pretty sure no one has written a book on Dalvik (or I could be wrong) so can someone suggest me a reference on the Java VM that contains some hands-on examples? Specifically, what I am interested in are:

我目前正在研究Dalvik字节码,但由于我缺乏编译器背景,我发现它有点难以掌握设计。我很确定没有人写过关于Dalvik的书(或者我可能是错的)所以有人可以建议我在Java VM上提供一些包含一些动手实例的参考吗?具体来说,我感兴趣的是:

  • Understand how to interpret the generated byte-code
  • 理解如何解释生成的字节码
  • Using VM specifications (Dalvik or Java) to decompile the byte code into an intermediate representation and then compile it back
  • 使用VM规范(Dalvik或Java)将字节代码反编译为中间表示,然后将其编译回来

In short, probably what I am looking for is to learn reverse engineering byte code so that I can analyze it for vulnerabilities. Any suggestions?

简而言之,我正在寻找的可能是学习逆向工程字节码,以便我可以分析它的漏洞。有什么建议么?

2 个解决方案

#1


9  

For reference material, nothing beats the dalvik docs. You can find these either in the dalvik sub-project in AOSP, or they are now available online at http://s.android.com/tech/dalvik/index.html

对于参考资料,没有什么比dalvik文档更好。您可以在AOSP的dalvik子项目中找到它们,或者现在可以在http://s.android.com/tech/dalvik/index.html上在线获取它们。

Bytecode format (or dalvik-bytecode.html in the dalvik project) is probably the one that you would be most interested in. .Dex Format (dex-format.html) is also useful, as is Instruction Formats (instruction-formats.html)

字节码格式(或dalvik项目中的dalvik-bytecode.html)可能是您最感兴趣的格式.Dex格式(dex-format.html)也很有用,指令格式(instruction-formats.html)也是如此。 )

For some more general information about the bytecode, check out http://code.google.com/p/smali/wiki/Registers and http://code.google.com/p/smali/wiki/TypesMethodsAndFields

有关字节码的更多常规信息,请查看http://code.google.com/p/smali/wiki/Registers和http://code.google.com/p/smali/wiki/TypesMethodsAndFields

You'll definitely want a few tools. I'm naturally quite partial to smali/baksmali, which is the only assembler/disassembler pair currently available. There is also a disassembler called dedexer (but no assembler), and dexdump, which comes with the AOSP codebase and provides a low-level dump of dex files - not just the bytecode, but all the dex structures as well (baksmali has similar output, with the -D option).

你肯定想要一些工具。我当然非常偏爱smali / baksmali,这是目前唯一可用的汇编/反汇编程序。还有一个名为dedexer(但没有汇编程序)的反汇编程序,以及dexdump,它附带AOSP代码库并提供dex文件的低级转储 - 不仅仅是字节码,还包括所有dex结构(baksmali具有相似的输出) ,使用-D选项)。

You might also be interested in apktool, which uses smali/baksmali, but also has the ability to reverse the "compiled" xml files in an apk.

您可能也对apktool感兴趣,它使用smali / baksmali,但也能够反转apk中的“已编译”xml文件。

There are a couple of tools out there that convert dalvik bytecode back to java bytecode, although I don't think they're 100% yet - undx and dex2jar

有几个工具将dalvik字节码转换回java字节码,虽然我不认为它们是100% - undx和dex2jar

#2


3  

There are already tools for reverse engineering .dex files to generate a human-readable representations of the byte codes. One of the most popular is baksmali, which you can find here: http://code.google.com/p/smali/.

已有用于逆向工程.dex文件的工具,用于生成字节代码的人类可读表示。其中最受欢迎的是baksmali,您可以在此处找到:http://code.google.com/p/smali/。

A description of the byte codes themselves can be found easily by Googling. Here was the third results: http://www.netmite.com/android/mydroid/dalvik/docs/dalvik-bytecode.html.

Googling可以很容易地找到字节码本身的描述。以下是第三个结果:http://www.netmite.com/android/mydroid/dalvik/docs/dalvik-bytecode.html。

If you are reverse engineering layouts, you'll need a binary-xml-to-xml converter as well. There's another stack overflow question that mentions a few tools for doing that: Parse versionCode from android apk files

如果您是逆向工程布局,则还需要二进制xml到xml转换器。还有另一个堆栈溢出问题,提到了一些工具:从Android apk文件解析versionCode

#1


9  

For reference material, nothing beats the dalvik docs. You can find these either in the dalvik sub-project in AOSP, or they are now available online at http://s.android.com/tech/dalvik/index.html

对于参考资料,没有什么比dalvik文档更好。您可以在AOSP的dalvik子项目中找到它们,或者现在可以在http://s.android.com/tech/dalvik/index.html上在线获取它们。

Bytecode format (or dalvik-bytecode.html in the dalvik project) is probably the one that you would be most interested in. .Dex Format (dex-format.html) is also useful, as is Instruction Formats (instruction-formats.html)

字节码格式(或dalvik项目中的dalvik-bytecode.html)可能是您最感兴趣的格式.Dex格式(dex-format.html)也很有用,指令格式(instruction-formats.html)也是如此。 )

For some more general information about the bytecode, check out http://code.google.com/p/smali/wiki/Registers and http://code.google.com/p/smali/wiki/TypesMethodsAndFields

有关字节码的更多常规信息,请查看http://code.google.com/p/smali/wiki/Registers和http://code.google.com/p/smali/wiki/TypesMethodsAndFields

You'll definitely want a few tools. I'm naturally quite partial to smali/baksmali, which is the only assembler/disassembler pair currently available. There is also a disassembler called dedexer (but no assembler), and dexdump, which comes with the AOSP codebase and provides a low-level dump of dex files - not just the bytecode, but all the dex structures as well (baksmali has similar output, with the -D option).

你肯定想要一些工具。我当然非常偏爱smali / baksmali,这是目前唯一可用的汇编/反汇编程序。还有一个名为dedexer(但没有汇编程序)的反汇编程序,以及dexdump,它附带AOSP代码库并提供dex文件的低级转储 - 不仅仅是字节码,还包括所有dex结构(baksmali具有相似的输出) ,使用-D选项)。

You might also be interested in apktool, which uses smali/baksmali, but also has the ability to reverse the "compiled" xml files in an apk.

您可能也对apktool感兴趣,它使用smali / baksmali,但也能够反转apk中的“已编译”xml文件。

There are a couple of tools out there that convert dalvik bytecode back to java bytecode, although I don't think they're 100% yet - undx and dex2jar

有几个工具将dalvik字节码转换回java字节码,虽然我不认为它们是100% - undx和dex2jar

#2


3  

There are already tools for reverse engineering .dex files to generate a human-readable representations of the byte codes. One of the most popular is baksmali, which you can find here: http://code.google.com/p/smali/.

已有用于逆向工程.dex文件的工具,用于生成字节代码的人类可读表示。其中最受欢迎的是baksmali,您可以在此处找到:http://code.google.com/p/smali/。

A description of the byte codes themselves can be found easily by Googling. Here was the third results: http://www.netmite.com/android/mydroid/dalvik/docs/dalvik-bytecode.html.

Googling可以很容易地找到字节码本身的描述。以下是第三个结果:http://www.netmite.com/android/mydroid/dalvik/docs/dalvik-bytecode.html。

If you are reverse engineering layouts, you'll need a binary-xml-to-xml converter as well. There's another stack overflow question that mentions a few tools for doing that: Parse versionCode from android apk files

如果您是逆向工程布局,则还需要二进制xml到xml转换器。还有另一个堆栈溢出问题,提到了一些工具:从Android apk文件解析versionCode