Tutorial navigation

  • How to decompile Apk for Android
  • Android Apk decompiler tutorial (2
  • In Android Studio, you can debug smALI code

background

Code debugging can help us analyze the code more quickly and help us verify various assumptions. Therefore, mastering the skills of smALI code debugging is an essential skill for APK decompilation

Prerequisite: The target process can be debugged

Change the application to be debuggable

Application debuggable, need to open debuggable=true in app manifest file. How to change apK to debuggable? Please refer to the Android APK decompression series tutorial

  • Debug Indicates that the debuggable is enabled by default during compilation
  • Release is compiled with debuggable turned off by default
<application
    android:debuggable="true"
</application>
Copy the code

Verify that the modification is successful

  • JDWP, see: www.jianshu.com/p/1f22362f4…
/ app/select goals adb shell ps | grep package name / / view the phone can be debugging process, if the selected process in adb JDWP list, then the modification is successful, the adb JDWPCopy the code

JDWP debugging principle

Smali code debugging method

(1) Locate the process to be debugged

Select the process to be debugged through Ps

The adb shell ps | grep package nameCopy the code

2) Create a local process and establish a connection with a remote process on the mobile phone

Db Forward TCP :8700 JDWP: indicates the process numberCopy the code

Android Studio attch onto the corresponding port of the local process

(1) Import aptool decompiled project into AS

(2) Create a remote connection

  • The port number is the same as the preceding port number (8700)
  • Android Studio -> localhost:8700-> Phone corresponding process

(3) Locate the interrupt point where the SMAIL code is located

The positioning techniques will not be described here, but will be covered in detail in a later series of tutorials. The recommended tool for analysis is Bytecode-viewer. The characteristics of

  • Ability to analyze resources and code simultaneously
  • The code supports Java and SMALI code comparison analysis, which helps us quickly locate the SMALI code

(4) Click debug

Correlation auxiliary instruction

(1) Check the process corresponding to the port

Lsof - I: portCopy the code

Note: After entering the mobile phone terminal through ADB shell, the PS process is very rare, you need to pass the following command

The adb shell ps | grep package nameCopy the code

A link to the

  • AS Debug smali tutorial: malacupa.com/2018/11/11/…
  • MAC installation timeout:gist.github.com/dasgoll/7b1…
  • Smali Idea plugin: github.com/JesusFreke/…