I would like to ask if anyone knows how to solve the above mentioned problem I encounter. I was reverse engineering an apk, and met a part where static analysis with IDA Pro is not enough, so I thought that I could use the android_server provided by IDA Pro to debug the .so library during runtime. However, I kept getting an error from IDA Pro when trying to attach to any process within my emulator: 'The debugger could not attach to the selected process. This can perhaps indicate the process was just terminated, or that you don't have the necessary privileges.' I used adb to push the android_server to my emulator, and then used adb shell and executed the script as root, but I'm still having this error. Any ideas on what am I doing wrong? Thanks in advance!
As mentioned, you have pushed the android_server to your emulator and executed it. So I guess you may forget forward your data from your development machine to your emulator.
As you executed the android_server, you can see
Listening on 0.0.0.0:23946... in your emulator, which means android_server could kown what it should do by getting information from the emulator's port 23946.
Now, you need transfer the information from IDA to your emulator.
To do this, you need:
In IDA, click
Select Debugger, choose a debugger accroding to your condition. For me, I choose Remote Linux Debugger.
Process Options, and set hostname to 127.0.0.1, then set port to 23946 or some other port you want, which your IDA could use to send information.
In your development machine, as Windows, open cmd or powershell, enter
adb forward tcp:23946 tcp:23946, so that your IDA can send data to your android_server. For more details for adb forward, please see https://developer.android.com/studio/command-line/adb#forwardports
If fortunately, now, in IDA, click
Attach to process, you may see the processes list, which means success.
I saw such issue in following situations:
- When you run
android_serveras non-root user (without prior call to
- When you run it with wrong working directory (as '/data/local/tmp/android_server
instead ofcd /data/local/tmp/ && ./android_server`).
So, please make you sure that you do everything exactly in correct way:
su cd /data/local/tmp ./android_server
Otherwise it may not work.