给ida android增加内存信息

ida连接android gdbserver调试时,用于增加段信息:

import os

import threading


def execcmd(cmd):
    r = os.popen(cmd)
    text = r.read();
    r.close()
    return text


def execadbcmd(cmd):
    return execcmd("adb shell " + cmd)


def refreshModules(pid):
    content = execadbcmd("cat /proc/%d/maps" % (pid))
    if content.find("No such file") != -1 or content == "":
        print "pid memory empty"
        return None
    for line in content.splitlines():
        addr_range_str = None
        if line.find(" ") != -1:
            addr_range_str = line.split(" ")[0].split("-")
        if addr_range_str != None:
            addr_begin = int(addr_range_str[0], 16)
            addr_end = int(addr_range_str[1], 16)
            modname = line.split(" ")[-1]
            AddSeg(addr_begin, addr_end, 0, 1, 0, 0)
            SegRename(addr_begin, modname)
            AnalyzeArea(addr_begin, addr_end)
if __name__ == "__main__":
    pid = 3759

    refreshModule(pid)


用于调试时跟踪函数流程

import idaapi

x=0

while x<100:

idaapi.step_over()

GetDebuggerEvent(WFNE_SUSP, -1)

rv = idaapi.regval_t()

idaapi.get_reg_val('EIP',rv)

print GetDisasm(rv.ival)

if GetMnem(rv.ival) == "retn":

break

x = x + 1



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值