如何根据mapping.txt还原混淆的代码

2015/07/13 21:12
阅读数 1.7K

BEFORE
Here’s the stack trace as obfuscated by ProGuard:

Caused by: java.lang.NullPointerException
at net.simplyadvanced.ltediscovery.be.u(Unknown Source)
at net.simplyadvanced.ltediscovery.at.v(Unknown Source)
at net.simplyadvanced.ltediscovery.at.d(Unknown Source)
at net.simplyadvanced.ltediscovery.av.onReceive(Unknown Source)

AFTER
All you need to do is write one line in the command prompt, and the obfuscation will be removed, as you can see here:

Caused by: java.lang.NullPointerException
at net.simplyadvanced.ltediscovery.UtilTelephony.boolean is800MhzNetwork()(Unknown Source)
at net.simplyadvanced.ltediscovery.ServiceDetectLte.void checkAndAlertUserIf800MhzConnected()(Unknown Source)
at net.simplyadvanced.ltediscovery.ServiceDetectLte.void startLocalBroadcastReceiver()(Unknown Source)
at net.simplyadvanced.ltediscovery.ServiceDetectLte$2.void onReceive(android.content.Context,android.content.Intent)(Unknown Source)

HOW TO DECODE STACK TRACE
You can choose either the command line method or GUI (Graphical User Interface) method.


HOW TO DECODE STACK TRACE VIA GUI
1) Open <android-sdk>/tools/proguard/bin/proguardgui.bat
2) Select the “ReTrace” option on the left column.
3) Add your mapping file and obfuscated stack trace.
4) Click “ReTrace!”

Thanks to David Bilik for mentioning this GUI method.

HOW TO DECODE STACK TRACE VIA COMMAND LINE
1) You will need your ProGuard’s mapping.txt file and the stack trace (Ex: stacktrace.txt) that you want to de-obfuscate.
2) The easiest way to do the next step is copy both these files into your<android_sdk_root>/tools/proguard/bin.
3) If you are on Windows, run the following command in the same directory as the files (make sure you change to your own file names):

retrace.bat -verbose mapping.txt stacktrace.txt > out.txt

4) out.txt will have the stack trace de-obfuscated. Now you can debug much easier and faster than before.

版权声明:本文为博主原创文章,未经博主允许不得转载。

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部