name_msg_handlers.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:shannonRE 作者: Comsecuris 项目源码 文件源码
def name_handlers(ea_from, ea_to):

    global COUNT

    addr = ea_from
    print "from: 0x%08x to: 0x%08x" % (addr, ea_to)
    while (addr < ea_to):

        func_to_name_ea = idc.Dword(addr) & 0xFFFFFFFE
        log_msg_ptr = idc.Dword(addr + 12)
        log_msg = idc.GetString(log_msg_ptr)

        #is that a function already?
        #There were 0 cases of this for our case
        if not idaapi.get_func(func_to_name_ea):
            print "There is no function at 0x%08x!" % func_to_name_ea
            idc.MakeFunction(func_to_name_ea)

        if "sms_Decode" in idc.GetFunctionName(func_to_name_ea) or "mm_Decode" in idc.GetFunctionName(func_to_name_ea) or "cc_Decode" in idc.GetFunctionName(func_to_name_ea) or "gmm_Decode" in idc.GetFunctionName(func_to_name_ea):
            print "Already named appropriately, don't overwrite"

        else:
            print "Naming %s based on %s as %s" % (idc.GetFunctionName(func_to_name_ea), log_msg, create_name(log_msg))
            COUNT += 1

            name = create_name(log_msg)

            # TODO: enable below naming
            ret = idc.LocByName(name)
            count = 1
            while (ret != 0xffffffff):
                count += 1
                ret = idc.LocByName(name + "__" + "%d" % count)
            idc.MakeName(func_to_name_ea, name + ("__%d" % count)*(count > 1))

        addr += 16
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号