Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deobfuscate jar file using mapping.txt generated by Proguard?

This may sound suspicious, but I need to deobfuscate my own app. Some time ago I published my app that I obfuscated with Proguard. Unfortunately I did not save that version of the app and changed the code a lot.

Now I need the code of that older version. I still have mapping.txt file generated by Proguard.

I have converted the classes.dex file to jar (using dex2jar tool), now I need to deobfuscate it according to mapping.txt. Are there any tools that can help me? Maybe Proguard itself?

UPD. I need a tool that can automatically rename all the classes, functions etc, so I dont have to do it manually. Thank you

like image 746
user2758776 Avatar asked Mar 27 '16 09:03

user2758776


People also ask

How do I read ProGuard mapping?

It should be located at build/outputs/proguard/release/mapping. txt in your application module's directory. In the latest version of ProGuard and Android Studio, the file is located at build/outputs/mapping/release/mapping.

What is retrace mapping file?

R8 retrace is a tool for obtaining the original stack trace from an obfuscated stack trace. The stack trace is reconstructed by matching class and method names in a mapping file to their original definitions.


Video Answer


2 Answers

If you have the mappings then you can get every class, field, and method name back.You can use java-asm (A bytecode modification library) to remap the class and member names. Most of the work will be updating member descriptors.

I made one for myself and it took about a day to get it working reliably.

Edit: It's not perfect, but it's pretty darn close. Link. Screenshot of the GUI Give it a proguarded jar file, the mappings and it'll rename all it can find. There's a few issues but for just looking at the source it should do the job. Just dump the jar it makes (FileName + "-Re.jar") into a decompiler such as Luyten/JD-GUI. Also the file inputs are only changed via the buttons. The textboxes are just for visual-feedback/confirmation.

Edit 2: Fixed NPE occurring when class entry in mappings doesn't exist in the given jar.

Edit 3: Fixed a lot of issues resulting in methods not being renamed.

Edit 4: Uploaded compiled jar to github (releases, in the zip file it's in the mapping util), added support for multiple mapping types.

like image 137
Display Name Avatar answered Oct 01 '22 11:10

Display Name


I suggest to use proguard tool as suggested in above answer along with Enigma. The solution for your problem can't be very straightforward and you need to use a combination of available tools to resolve it.

like image 40
Akram Avatar answered Oct 01 '22 11:10

Akram