使用IDA调试Android原生程序中遇到的问题及解决方法

来源:互联网 发布:ipad绿色上网软件 编辑:程序博客网 时间:2024/06/06 11:49

因为自己也是新手,在实践过程中遇到一些问题,就想将其解决方法分享出来,其中也参考了网上很多的资料。

IDA调试Android原生代码 推荐一篇很详细的文章:Android动态方式破解apk进阶篇(IDA调试so源码)

http://www.cnblogs.com/chenxibobo/p/6075058.html


Question 1:

问题:error: only position independent executables (PIE) are supported


原因:

这个主要是Android5.0以上的编译选项默认开启了pie,在5.0以下编译的原生应用不能运行。

解决办法:

1.用Android5.0以下的手机进行操作

2.用IDA6.6+版本

3.修改android_server十六进制文件

    原理:linker通过检测可执行程序elf header中的e_type字段判断是否PIC,只需要将android_server的elf header字段中的e_type改为ET_DYN(3)即可。具体办法:
 (1) 使用hexedit或其他二(十六)进制编辑工具打开android_server
 (2)将第17个字节处的02改成03,保存退出

保存。push到手机,即可运行。


Question 2:

问题:用IDA6.1动态调试C原生程序,IDA中的输出为:
Could not set the shlib bpt, shared object events will not be handled
B6FE1000: loaded /system/bin/linker
8000: process /data/local/tem/hijack has started
Debugger: process has exited (exit code 0)
<Default>: incompatible saved desktop has been ignored

调试服务的dos窗口显示:
[1] Accepting connection from localhost(127.0.0.1)...
Failed to find r_debug in /system/bin/linker
hijack[1] Closing connection from localhost(127.0.0.1)...

解决方案:
换了IDA6.6 调试成功

附IDA6.6下载地址看雪: http://tools.pediy.com/windows/disassemblers.htm


Question 3:

连接到Debugger->run->Remote ARMLinux/Android debugger/时,配置如下


即可连接:



 

Question 4:

连接到IDA中,发现是dl_start,如何进入main函数中?



再开一个IDA,打开同一个文件,在export栏找到main函数,双击,进入汇编代码,可以看到main函数在hijack中的偏移地址是00000B10,如下


回到调试窗口,按组合件ctrl+s,可以看到hijack在内存中的加载地址是B6F4D000


可以计算得出,main函数地址是B6F4D000 + 00000B10B6F4DB10

G键 或者 菜单选jump——jump to address——输入B6F4DB10,跳转


发现都是DCB

P键即可




0 0
原创粉丝点击