Introduction of ProGuard

  • ProGuard is the obfuscation tool that comes with the Android SDK. Its location in the SDK directory is as follows:
The directory where the ProGuard tool is located
Android/sdk/tools/proguard/
Copy the code
  • The proGuard /bin directory provides the following executable tools:
-> ProGuardGUI: Visual obfuscation integration tool; -> retrace: provides commands to trace and restore the obfuscated code;Copy the code

ReTrace de-obfuscate

ReTrace is used to restore obfuscated code or logs, mostly to view crash logs.

Use the retrace.sh command to restore the obfuscated code as follows:

The # retrace.sh command restores the log using mapping.txt and prints it to out.txt
$ retrace.sh -verbose mapping.txt log.txt > out.txt
Copy the code

Proguardgui visual obfuscation tool

Proguardgui is a visual obfuscation tool interface. Here are two ways it can start and de-obfuscate.

Method 1: ProGuardgui.jar

The procedure for proGuardgui.jar is as follows:

  1. Keep the mapping.txt file when packing, which can be used to restore obtruded code (or logs).
# mapping. TXT is stored in the following directory
app/build/outputs/mapping/release
Copy the code
  1. Use the mapping.txt file to restore the confused apK output logs:
# 1. Find the proGuardgui.jar directory:
Android/sdk/tools/proguard/lib
# 2. Open the proGuardgui.jar file
# 3. Select ReTrace and restore as follows:-> Select the mapping file saved when packaging -> Enter the obtruded code (or log) -> press the Retrace button -> Restore succeededCopy the code

Method 2. Start the ProGuardGUI visual interface from the command line

  1. Configure the ProGuard environment variable.
MacOS adds the following environment variables to the environment variables
export PATH=$PATH:$ANDROID_HOME/tools/proguard/bin
Copy the code
  1. Command to open the ProGuardGUI visual interface:
Open the visualization tool and run the following command directly
# proguardgui. Sh is open the Android SDK/tools/proguard/lib/proguardgui jar file
$ proguardgui.sh
Copy the code
  1. Select the ReTrace menu and restore the obfuscated log as shown in step 2 of Method 1.