Android penetration testing 12: IDA dynamic debugging so

0 21
0x00 PrefaceThe previous article shared the use of Android studioand JebDirectly...

0x00 Preface

The previous article shared the use of Android studioand JebDirectly debug Apk files dynamically, this article will share the use of IDA pro debugging so.

The debugging apk file is still using the file from CTF case 4, which has been uploaded to the Knowledge Planet. You can download it yourself

Android penetration testing 12: IDA dynamic debugging so

Technologies involved in this article:

  • IDA pro tool usage

  • Debug android applications

  • Dynamic debugging technology

Note: The apk file required for this case has been uploaded to the Knowledge Planet. Those who need it can download it by following the link at the end of the article

0x01 Preparation

1. Download the case Apk file

Use the Android Killer tool to modify the configuration file and add android:debuggable="true"This configuration, so the apk can be debugged.

1660661572_62fbaf44874ec390c7f1a.png!small?1660661572861

2. FindIDA_Pro_v7.5_Portable\dbgsrvDirectory, where the files correspond to the server files of different platforms:

1660661588_62fbaf5447e56247a4f11.png!small?1660661588781

3. Check the CPU architecture of the phone:

1660661601_62fbaf6145f9d7bb70888.png!small?1660661601912

4. The debugging phone is android's arm64-v8a, you can choose android_server64, send this file to the mobile phone/data/local/tmpDirectory, then grant execution permissions, and finally execute.

1660661613_62fbaf6d01e4e49ed0d57.png!small?1660661613146

The default port is 23946, here it is deliberately changed to 22222

5. Port forwarding

adb forward tcp:11111 tcp:22222    

This indicates that the local 11111 port (on my Windows machine) is forwarded to the remote mobile phone 22222 port:

1660661630_62fbaf7e6c3dc47200030.png!small?1660661630518

After the preparation is done, two debugging methods will be explained: one is to debug the apk started in normal mode, and the other is to debug the apk started in Debug mode. If the debugging code logic runs after startup, then you can use the normal apk startup debugging mode. If the debugging code logic is executed when the application starts, then you need to use the Debug mode to start the Apk for debugging.

0x02 Normal mode debugging

1. Start the corresponding Activity with adb, here using Start apk in normal mode

adb shell am start -n com.example.hellojni/com.example.application.IsThisTheRealOne 

2. Open the 64-bit version of IDA pro and load the libhello-jni.so file from arm64-v8a

3. IDA debugging configuration

Select Remote ARM Linux/Android debugger for debugging

1660661646_62fbaf8ecbf4548ed9799.png!small?1660661647218

Select Debugger options and check the following three options

1660661671_62fbafa75122a8381f6e1.png!small?1660661671685

Select Process options for configuration:

1660661678_62fbafae9f641ac58d6d5.png!small?1660661679030

Select the process to attach to

1660661689_62fbafb9ec67d1aaa3d21.png!small?1660661690100

4, Debugger warning appears

This indicates that the same so file as the locally loaded one is found on the phone, and select same:

1660661704_62fbafc8bc4133fcef502.png!small?1660661705133

5, Search in the module, the module to be debugged

1660661714_62fbafd224aad1de56342.png!small?1660661714420

Then locate the function to be broken into:

1660661730_62fbafe20cd95c01aa627.png!small?1660661730249

6, Set breakpoints

You can directly use the shortcut key F5, and then set breakpoints in the pseudo-code of c/c++:

1660661744_62fbaff0243ab0bb174ac.png!small?1660661744548

7, Start debugging

Click Quick debug view, open LocalsWindow, press F9 to run, press F8 to step over, and debug

1660661756_62fbaffc4927544038e63.png!small?1660661756521

8, Successfully obtained the flag value.

0x03 Debug mode debugging

1, Open Android device monitorTools

This tool is located in theAndroid\Sdk\toolsdirectory

2, In Debug modeStart the apk's Activity

adb shell am start -D -n  com.example.hellojni/com.example.application.IsThisTheRealOne

Found in Android device monitorIn front of the program to be debugged, there is an additionalThe red bug

1660661774_62fbb00ed6ad6ff076fab.png!small?1660661775093

3, Open IDA, load so (as above)

4, IDA debugging configuration, check three items, etc., find the process to be debugged (as above)

5, Execute the jdb command

jdb -connect com.sun.jdi.SocketAttach:hostname=127.0.0.1,port=8608

This port can be viewed in Monitor

After execution is complete,The red bug turns green, then you can start debugging

1660661788_62fbb01c9c3a74578934b.png!small?1660661788770

6, Start debugging, press F9 until

1660661804_62fbb02cd6fc89d2bba82.png!small?1660661805156

At this time, the so to be debugged is loaded

7, Find the module to be debugged and the specific functions within the module (as above)

1660661813_62fbb03553de9e3fd5eb0.png!small?1660661813894

8, Continue debugging

Open Locals to view variables,

1660661831_62fbb0478bcce9c22276c.png!small?1660661831779

Successfully obtained the flag value.

0x04 Conclusion

In Android reverse engineering, dynamic debugging is an important technique, and IDA pro is a powerful tool for debugging so code. Those who are interested can download the apk file of the case for practical experience.

你可能想看:
最后修改时间:
admin
上一篇 2025年03月27日 03:34
下一篇 2025年03月27日 03:57

评论已关闭