8

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

user2758776
  • 421
  • 1
  • 5
  • 15
  • It is probably not possible. Once you compile the app, the code is already "obfuscated" by the compiler. The case that you obfuscate the app with Proguard again, that is double-obfuscated. There might a way to deobfuscate and decompile the app. I recommend you to save and backup anything before you code next time. –  Mar 27 '16 at 09:22
  • 1
    This doesn't help you now, but to prevent such problems in the future, use a **version control system** (VCS). – F43nd1r Mar 29 '16 at 23:25

2 Answers2

14

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.

beppe9000
  • 1,056
  • 1
  • 13
  • 28
Display Name
  • 942
  • 1
  • 10
  • 20
  • This looks like the thing I want, unfortuately I get NPE when I press "Undo" button: *java.lang.NullPointerException at me.lpk.mapping.MappedClass.(MappedClass.java:38) at me.lpk.mapping.ProguardLoader.readClass(ProguardLoader.java:121) at me.lpk.mapping.ProguardLoader.read(ProguardLoader.java:61) at me.lpk.mapping.ProguardLoader.read(ProguardLoader.java:41) at me.lpk.mapping.MappingGen.mappingsFromProguard(MappingGen.java:49) at me.lpk.ReProguard$4.actionPerformed(ReProguard.java:123) ...* – user2758776 Mar 31 '16 at 12:38
  • Looks like it threw that because the class name it tried loading didn't exist in the jar. Reworked the ProguardLoader class to check for this. If the class doesnt exist in the jar then the mapping for that class will be ignored. Reuploaded the tool with the fix. – Display Name Mar 31 '16 at 15:17
  • Thank you for your effort, but I still get NPE: java.lang.NullPointerException at me.lpk.mapping.MappedClass.(MappedClass.java:38) at me.lpk.mapping.ProguardLoader.readClass(ProguardLoader.java:126) at me.lpk.mapping.ProguardLoader.read(ProguardLoader.java:61) at me.lpk.mapping.ProguardLoader.read(ProguardLoader.java:41) at me.lpk.mapping.MappingGen.mappingsFromProguard(MappingGen.java:49) at me.lpk.ReProguard$4.actionPerformed(ReProguard.java:123) Maybe you can share with me the source code of your tool? Thanks! – user2758776 Mar 31 '16 at 17:12
  • 2
    Here you go: https://github.com/LPK-Matt/SkidSuite2 I'm trying to reproduce the NPE but I can't seem to figure out how your mappings trigger it now. – Display Name Mar 31 '16 at 19:11
  • Links do not work anymore, did you change your github user name? – beppe9000 Jun 24 '18 at 09:05
  • @beppe9000 I have found it here: https://github.com/FireMasterK/SkidSuite2-Latest – Oleksandr Albul Dec 21 '19 at 02:46
  • The repository linked does not seem to contain the tool in question, but I did find this alternative: https://github.com/SuspiciousActivity/ProGuard-Unmapper – Avamander Sep 01 '20 at 00:10
3

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.

Community
  • 1
  • 1
Akram
  • 2,158
  • 1
  • 17
  • 24
  • In addition to Proguard I've also made it work with Engima mappings. However I have not compiled a version with the Enigma GUI active. Source is on the repo however: https://github.com/LPK-Matt/SkidSuite2/blob/master/SkidReob/src/me/lpk/gui/windows/mapping/WindowEnigma.java – Display Name Apr 05 '16 at 16:00
  • @DankVader that url gives a 404 – beppe9000 Oct 08 '16 at 14:28
  • @beppe9000 The specific file was removed in a commit but the repo is still up. https://github.com/LPK-Matt/SkidSuite2/releases Since making that comment it has been compiled and placed under releases. – Display Name Oct 08 '16 at 21:11