Foreword: through the decompilation of the last article, we can get dex files, so how do we repackage dex files back to the new APK? If you have such doubts, read this article! It will help you!

What do I do after I get the DEX file?

To be honest, WHEN I just got the dex file after peeling, I was a little confused. I was wondering what I should do after I got the DEX file. How do I repackage the real DEX file back to APK? We all know that after decompiling the unhardened APP, the source is smali file, but now I have dex file, so after getting dex file, what we need to do is compile dex file into SMali file, and then recompile into APK.

Compile the dex file into the smali file

To compile the dex file into a smali file, we need to download the baksmali.jar file. After downloading the baksmali.jar file, we can compile the dex file into a smali file with the following command:

java -jar baksmali.jar smaliTest.dex
Copy the code

For example, if the dex file you want to compile is testsmali. dex, enter the command

java -jar basksmali.jar testSmali.dex
Copy the code

If the compilation succeeds, an out directory is generated, and the files in the out directory are smali files. The following errors may sometimes be encountered

Exception in thread “main”

com.beust.jcommander.MissingCommandException: Expected a command, got classes.dexat

com.beust.jcommander.JCommander.parseValues(JCommander.java:725)at

com.beust.jcommander.JCommander.parse(JCommander.java:304)at

com.beust.jcommander.JCommander.parse(JCommander.java:287)at org.jf.baksmali.Main.main(Main.java:90)

In this case, you simply change the command above to

java -jar basksmali.jar disassemble testSmali.dex
Copy the code

Can be solved.

Considerations for back compilation

After compiling the hardened app, you need to modify the Androidmanifest.xml file as follows

You need to change the content of “XXX” in android:name=” XXX “to “yyy” in Android :value=”yyy” and delete that line.

There may be several dex files in an APK, and there will be several folders when compiling the dex files into smali files. In this case, we will name the Smali folder as shown below

Now you can use apkTool B XXX to pack the APK after you shelled it.

Note: monkey apK can not be installed directly at this time, but also need to be signed before installation.

conclusion

This article is a little short, in fact, the compilation of DEX file into smALI file is not complicated, the main purpose of this article is to tell you how to get dex file back, repackage to generate a new APK, if there is any problem in this process, welcome to leave a comment below.

Please indicate the source for reprinting: www.wizardev.cn

Scan the code to pay attention to the public number, reply “get information” have surprise