eclipse Android NDK 反编译本机代码的可能性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28864029/
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
Android NDK possibility of decompiling native code
提问by
Is is possible to decode native code compiled and liked to android through ndk ?
是否可以通过 ndk 解码编译并喜欢 android 的本机代码?
and is it possible from the apk to reconstruct the project and import it to eclipse (or any other IDE)?
是否可以从 apk 重建项目并将其导入 eclipse(或任何其他 IDE)?
is it possible to use the .so
files in the apk file again to reconstruct the project or with another project if the java native function declaration is done appropriately?
.so
如果java本机函数声明正确完成,是否可以再次使用apk文件中的文件来重建项目或另一个项目?
采纳答案by jaroslawj
Decompiling native to source code is (probably, I wasn't trying it) possible, there are some tools like this https://www.hex-rays.com/products/decompiler/
反编译源代码是可能的(可能,我没有尝试过),有一些像这样的工具https://www.hex-rays.com/products/decompiler/
It's possible to reconstruct project from apk but code will be obfuscated (weird class and method names). You may check your app against apk2gold (https://github.com/lxdvs/apk2gold)
可以从 apk 重建项目,但代码将被混淆(奇怪的类和方法名称)。您可以根据 apk2gold ( https://github.com/lxdvs/apk2gold)检查您的应用
As for your last question, with a little effort - yes.
至于你的最后一个问题,稍微努力一下 - 是的。
回答by JimmyB
Is is possible to decode native code compiled
是否可以解码编译的本机代码
No.
不。
is it possible from the apk to reconstruct the project
是否可以从apk重建项目
Yes, a lot of it. Extracting .class
files is easy, decompiling mostly too. An obfuscation step in your build process will make this a lot more difficult.
是的,很多。提取.class
文件很容易,反编译也很容易。构建过程中的混淆步骤会使这变得更加困难。
However, constant values and initilizers are very easy to come by from a compiled class. Don't try something like private static String SECRET = "sesame123";
. This is not at all difficult to reverse engineer. - The same is, by the way, valid for .so
files too.
然而,常量值和初始化器很容易从编译的类中获得。不要尝试类似的东西private static String SECRET = "sesame123";
。这一点也不难逆向工程。- 顺便说一下,这对.so
文件也有效。
is it possible to use the .so files in the apk file again to reconstruct the project
是否可以再次使用apk文件中的.so文件来重建项目
No.
不。
It depends on what you mean with "project". The functions and signatures of your native library are probably easy to recover from the corresponding (compiled) Java class in any case. The (source-)code is basically "lost" for good after compilation to native code. If someone knows how to use your shared library though (easy to figure out, see above), he would be able to useit in whatever app he likes.
这取决于你对“项目”的意思。无论如何,您的本机库的函数和签名可能很容易从相应的(已编译的)Java 类中恢复。在编译为本机代码后,(源代码)代码基本上“丢失”了。如果有人知道如何使用您的共享库(很容易弄清楚,见上文),他将能够在他喜欢的任何应用程序中使用它。
To sum it up:
把它们加起来:
a) The source code cannot be reconstructed from compiled native code.
a) 源代码不能从已编译的本机代码中重构。
b) Java source is much easier to reconstruct from compiled .class
files; obfuscation of the code can make it harder.
b) Java 源代码更容易从编译.class
文件中重构;代码的混淆会使它变得更难。
c) Any functionality your app may have, native or not, can quite easily be extracted and exploited by another app the attacker may write.
c) 您的应用程序可能具有的任何功能,无论是否是原生的,都可以很容易地被攻击者编写的另一个应用程序提取和利用。
See also: http://en.wikipedia.org/wiki/Security_through_obscurity
回答by Efe Kahraman
is it possible from the apk to reconstruct the project and import it to eclipse (or any other IDE)?
是否可以从 apk 重建项目并将其导入 eclipse(或任何其他 IDE)?
This can be done by dex decompilers and apk resource extractors.
这可以通过 dex 反编译器和 apk 资源提取器来完成。
Is is possible to decode native code compiled and liked to android through ndk ?
is it possible to use the .so files in the apk file again to reconstruct the project or with another project if the java native function declaration is done appropriately?
是否可以通过 ndk 解码编译并喜欢 android 的本机代码?
是否可以再次使用 apk 文件中的 .so 文件来重建项目或使用另一个项目,如果 Java 本机函数声明正确完成?
Once you get the shared object, you caninclude it in your own project. You can dump global symbols of library and learn its usage via decompiled Java code. However, if shared object is build against a specific architecture, you might not able to rebuild it across other platforms.
获得共享对象后,您可以将其包含在您自己的项目中。您可以转储库的全局符号并通过反编译的 Java 代码了解其用法。但是,如果共享对象是针对特定架构构建的,您可能无法跨其他平台重建它。
回答by 18446744073709551615
Is is possible to decode native code compiled and liked to android through ndk ?
是否可以通过 ndk 解码编译并喜欢 android 的本机代码?
One can disassemble; there are C/C++ decompilers, but for really complex code they are nearly useless.
一个可以拆卸;有 C/C++ 反编译器,但对于真正复杂的代码,它们几乎没用。
and is it possible from the apk to reconstruct the project and import it to eclipse (or any other IDE)?
是否可以从 apk 重建项目并将其导入 eclipse(或任何其他 IDE)?
it is possible to baksmali (disassemble) an .apk, to fix something in it, and to smali (assemble) it again. One can substitute some function calls by other function calls, and one can add new classes.
可以对 .apk 进行 baksmali(反汇编),修复其中的某些内容,然后再次进行 smali(组装)。可以用其他函数调用替换一些函数调用,并且可以添加新类。
Decompiling to Java is also possible, but the code likely will not compile, so it is rather about analysis than about modification.
反编译成Java也是可以的,但是代码很可能不会编译,所以与其说是修改,不如说是分析。
Obfuscated code is still readable, provided that they invest some efforts in analysis.
混淆的代码仍然可读,只要他们在分析上投入了一些努力。
You can obfuscate the code, but they will see icons, they will find the resource ids, and they will find the onClick()button handlers.
您可以混淆代码,但他们会看到图标,他们会找到资源 ID,他们会找到onClick()按钮处理程序。
is it possible to use the .so files in the apk file again to reconstruct the project or with another project if the java native function declaration is done appropriately?
是否可以再次使用 apk 文件中的 .so 文件来重建项目或使用另一个项目,如果 Java 本机函数声明正确完成?
They will have no problem with using .so as-is with another project (unless someone asks them to fix a bug in that .so). In the same way, they can make a .jar from your .apk and use that .jar as a library with another project.
他们在另一个项目中使用 .so 没有问题(除非有人要求他们修复 .so 中的错误)。以同样的方式,他们可以从您的 .apk 制作一个 .jar 并将该 .jar 用作另一个项目的库。
In general, a .so it a bit more difficult to tinker with than a .jar .
一般来说, .so 比 .jar 更难修改。