【Android 安全】DEX 加密 ( Proguard 混淆 | 将混淆后的报错信息转为原始报错信息 | retrace.bat 命令执行目录 | 暴露更少信息 )(一)

文章目录

一、将混淆后的报错信息转为原始报错信息

二、retrace.bat 命令执行目录

三、暴露更少信息


更多 ProGuard 混淆配置参考 : https://www.guardsquare.com/en/products/proguard/manual/usage






一、将混淆后的报错信息转为原始报错信息


前提 : proguard-rules.pro 混淆配置中配置保留行数 ;


# 保留行数
-keepattributes SourceFile,LineNumberTable


混淆后的报错信息 :


2020-11-10 12:01:59.426 28142-28142/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: kim.hsl.handler, PID: 28142
    java.lang.RuntimeException: Unable to start activity ComponentInfo{kim.hsl.handler/kim.hsl.handler.MainActivity}: java.lang.NullPointerException: Attempt to read from field 'b.a.a.d b.a.a.b.a' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3897)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4076)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8349)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
     Caused by: java.lang.NullPointerException: Attempt to read from field 'b.a.a.d b.a.a.b.a' on a null object reference
        at b.a.a.a.<init>(Handler.java:30)
        at kim.hsl.handler.MainActivity.onCreate(MainActivity.kt:24)
        at android.app.Activity.performCreate(Activity.java:8085)
        at android.app.Activity.performCreate(Activity.java:8073)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3870)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4076) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473) 
        at android.os.Handler.dispatchMessage(Handler.java:110) 
        at android.os.Looper.loop(Looper.java:219) 
        at android.app.ActivityThread.main(ActivityThread.java:8349) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)



将上述混淆后的报错信息 , 保存到 bug.txt 文件中 , 放在 app\build\outputs\mapping\debug 目录里 ;


在 Sdk\tools\proguard\bin 中找到 retrace.bat 工具 ;


【Android 安全】DEX 加密 ( Proguard 混淆 | 将混淆后的报错信息转为原始报错信息 | retrace.bat 命令执行目录 | 暴露更少信息 )(一)


使用上述 retrace.bat 命令 , 通过 Proguard 混淆映射文件 mapping.txt , 还原被混淆过的 报错信息 ;


进入 D:\001_Programs\001_Android\002_Sdk\Sdk\tools\proguard\lib 目录 , 然后在该目录执行上述命令 ;


D:\001_Programs\001_Android\002_Sdk\Sdk\tools\proguard\bin\retrace.bat -verbose D:\002_Project\002_Android_Learn\Handler\app\build\outputs\mapping\debug\mapping.txt D:\002_Project\002_Android_Learn\Handler\app\build\outputs\mapping\debug\bug.txt


一定要注意 , 必须在 D:\001_Programs\001_Android\002_Sdk\Sdk\tools\proguard\lib 目录中执行该命令 ;


还原结果 :


D:\001_Programs\001_Android\002_Sdk\Sdk\tools\proguard\lib>D:\001_Programs\001_Android\002_Sdk\Sdk\tools\proguard\bin\retrace.bat -verbose D:\002_Project\002_Android_Learn\Handler\app\build\outputs\mapping\debug\mapping.txt D:\002_Project\002_Android_Learn\Handler\app\build\outputs\mapping\debug\bug.txt
2020-11-10 12:01:59.426 28142-28142/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: kim.hsl.handler, PID: 28142
    java.lang.RuntimeException: Unable to start activity ComponentInfo{kim.hsl.handler/kim.hsl.handler.MainActivity}: java.lang.NullPointerException: Attempt to read from field 'b.a.a.d b.a.a.b.a' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3897)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4076)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8349)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
     Caused by: java.lang.NullPointerException: Attempt to read from field 'b.a.a.d b.a.a.b.a' on a null object reference
        at kim.hsl.handler.Handler.void <init>()(Handler.java:30)
        at kim.hsl.handler.MainActivity.void onCreate(android.os.Bundle)(MainActivity.kt:24)
        at android.app.Activity.performCreate(Activity.java:8085)
        at android.app.Activity.performCreate(Activity.java:8073)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3870)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4076)聽
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)聽
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)聽
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)聽
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2473)聽
        at android.os.Handler.dispatchMessage(Handler.java:110)聽
        at android.os.Looper.loop(Looper.java:219)聽
        at android.app.ActivityThread.main(ActivityThread.java:8349)聽
        at java.lang.reflect.Method.invoke(Native Method)聽
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)聽
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)聽
D:\001_Programs\001_Android\002_Sdk\Sdk\tools\proguard\lib>

【Android 安全】DEX 加密 ( Proguard 混淆 | 将混淆后的报错信息转为原始报错信息 | retrace.bat 命令执行目录 | 暴露更少信息 )(一)





上一篇:开发人员必知的Git技能及Git工作流总结!(三)


下一篇:推荐IE前端性能分析神器DynaTrace Ajax Edition