4

I'm currently working on analyzing some android malwares and i need to decompile APK files. Reading an answer and many other answers like it, i know that we can extract java source code and other resources, create a new project and put those files in, make some modifications and compile the project. Is this approach applicable to every APK file ? If we aim to make very little or no modifications in the java source code, does this approach work for every APK file? If not, what is the main reason?

As another question, i remember i read somewhere (can not find it now) that said converting dex to jar (with tools such as dex2jar) or decompiling dex to java (with tools such as JADX) is somehow lossy and causes information loss. Is there any such concept?

I ask this questions for educational purposes and i'm not aiming to do anything illegal.

Mehran Torki
  • 977
  • 1
  • 9
  • 37
  • In my experience, you can't rely on most decompilers to produce actual recompilable code, for anything but the most trivial code. – JesusFreke Mar 06 '18 at 19:42
  • Converting a dex back to a jar shouldn't be lossy. After all, that code likely started life as a jar to begin with. Although I can't say with confidence that dex2jar specifically isn't lossless. – JesusFreke Mar 06 '18 at 19:43
  • 1
    Although I might be a tiny bit biased, I think you would be better off disassembling the apk and modifying the bytecode, or using something like dexlib2 to modify the bytecode programatically. – JesusFreke Mar 06 '18 at 19:45
  • @JesusFreke Yes, i've seen some examples of how to edit dex bytecodes to make some small changes but it gets complicated for big ones. Thanks for your comments. – Mehran Torki Mar 06 '18 at 20:45
  • 1
    @JesusFreke I think both jar -> dex and dex -> jar are lossy due to the subtle differences between the formats. For example, dex has no `multianewarray`, so array creation has to be desugared. – Antimony Mar 08 '18 at 08:14
  • @Antimony I defer to your expertise. Having written such a tool yourself, you would know better than me :) – JesusFreke Mar 08 '18 at 18:13

0 Answers0