美文网首页
IDA Python 脚本(四)

IDA Python 脚本(四)

作者: 炫子_260f | 来源:发表于2020-10-19 17:03 被阅读0次

    常用的脚本

    import idautils
    import idaapi
    
    # 解析为code
    def make_code(start, end):
      for i in range((end - start) / 4):
        addr = start + (i * 4)
        idaapi.do_unknown_range(addr, 4, 0)
        idaapi.auto_make_code(addr)
      return
    
    
    # 解析为function,相当于 P
    def make_function(start, end):
      idc.MakeFunction(start, end)  
      return
      
    # 查找调用addr的地方,并加断点
    def addBreakpoint(addr):
      string_dt_init_ea = addr
      refs = XrefsTo(string_dt_init_ea)
      useful_ref = 0
      for ref in refs:
        useful_ref = ref.frm
        AddBpt(useful_ref)
        AddBpt(useful_ref + 0x4)
    
    # 打印data的数据
    def get_string(startAddr, endAddr):
        out = ""
        index = 1
        charStartAddr = startAddr
        res = ''
        line = 0
        while (startAddr < endAddr) :
            res += hex(Byte(startAddr)) + ','
            if line == 15:
                res += '\n'
                startAddr += 1
                line = 0
            else:
                line += 1
                startAddr += 1
        print (res)
        print ("end")
    

    调用示例

    start = 0xAF1C982C
    end = start + 0x838c
    print(hex(end))
    #make_code(start, end)
    make_function(start, end)
    #addr = 0xAF1B854C
    #addBreakpoint(addr)
    #get_string(start, end)
    ``

    相关文章

      网友评论

          本文标题:IDA Python 脚本(四)

          本文链接:https://www.haomeiwen.com/subject/hpflmktx.html