windows下gdb与gdb_server调试Android的程序

概要总结:

手机服务端:

启动方式:  gdbserver:23946 + bin程序路径

附加方式:  gdbserver:23946+-attach [pid]

PC客户端:

C:\Users>D:\android-ndk-r9\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-gdb.exe

(gdb) target remote 127.0.0.1:23946


详细过程:

环境: pc:windows7 x32

            模拟器Android4.2.2

gdbserver 路径 D:\android-ndk-r9\prebuilt\android-arm\gdbserver 

gdb 路径:D:\android-ndk-r9\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-gdb.exe


1.上传并修改手机的gdbserver权限

adb push D:\android-ndk-r9\prebuilt\android-arm\gdbserver\gdbserver /data/local/tmp

adb shell chmod 777 /data/local/tmp/gdbserver


2.端口转发

adb forward tcp:23946 tcp:23946


3.运行gdbserver

启动方式:  gdbserver:23946 + bin程序路径

附加方式:  gdbserver:23946+-attach [pid]

root@android:/ # gdbserver :23946 --attach 1805
gdbserver :23946 --attach 1805
Attached; pid = 1805
Listening on port 23946

4.运行gdb

C:\Users>D:\android-ndk-r9\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-gdb.exe
GNU gdb (GDB) 7.3.1-gg2
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i586-pc-mingw32msvc --target=arm-linux-androi
d".
For bug reporting instructions, please see:
.
(gdb) set disassemble-next on
(gdb) set step-mode on
(gdb) target remote 127.0.0.1:23946
Remote debugging using 127.0.0.1:23946
0x40037ebc in ?? ()
=> 0x40037ebc:  90 00 bd e8     pop     {r4, r7}
(gdb)

此时gdbserver的显示

root@android:/ # gdbserver :23946 --attach 1805
gdbserver :23946 --attach 1805
Attached; pid = 1805
Listening on port 23946
Remote debugging from host 127.0.0.1


后续结合IDA分析。

你可能感兴趣的:(android,逆向)