當前位置: 首頁>>代碼示例>>Python>>正文


Python idautils.FuncItems方法代碼示例

本文整理匯總了Python中idautils.FuncItems方法的典型用法代碼示例。如果您正苦於以下問題:Python idautils.FuncItems方法的具體用法?Python idautils.FuncItems怎麽用?Python idautils.FuncItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在idautils的用法示例。


在下文中一共展示了idautils.FuncItems方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: detect_start_and_stop

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def detect_start_and_stop(self):  # FIXME:Duplicate code with core (or something similar)
        start, stop = 0, 0
        if self.core.ftype == "PE":
            start, stop = self.core.fun_mapping["start"]
        else:
            if "main" in self.core.fun_mapping:
                start, stop = self.core.fun_mapping["main"]
            elif "start" in self.core.fun_mapping:
                if "__libc_start_main" in self.core.fun_mapping:
                    instrs = list(idautils.FuncItems(self.core.fun_mapping["start"][0]))
                    instrs.reverse()
                    for inst in instrs:
                        arg1 = idc.GetOperandValue(inst, 0)
                        if idc.GetMnem(inst) == "push":
                            start, stop = arg1, self.core.fun_mapping["start"][1]
                            break
                else:
                    start, stop = self.core.fun_mapping["start"]
            else:
                start, stop = idc.BeginEA(), 0
        self.start, self.stop = start, stop 
開發者ID:RobinDavid,項目名稱:idasec,代碼行數:23,代碼來源:AnalysisWidget.py

示例2: save_mnemonics_functions_ida

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def save_mnemonics_functions_ida(f1):
  filename= f1
  mnemonics = {}
  flag= 0

  for segAddress in Segments():
    segName = SegName(segAddress)
    if segName == ".text":
      funcs = Functions(SegStart(segAddress), SegEnd(segAddress))
      for address in funcs:
        t1= GetFunctionName(address)
        f1= idautils.FuncItems(address)
        t2=''
        for i in f1:
          t2+= GetMnem(i)
          t2+= '^^^'
        mnemonics[filename+'>'+t1]= t2+'<'+str(address)
        
  return mnemonics 
開發者ID:arvinddoraiswamy,項目名稱:slid,代碼行數:21,代碼來源:save_disasm.py

示例3: find_xrefs_from

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def find_xrefs_from( self, func_ea ):
    
        xrefs = []

        for item in idautils.FuncItems( func_ea ):
            
            ALL_XREFS = 0
            for ref in idautils.XrefsFrom( item, ALL_XREFS ):
                    
                if ref.type not in XrefsFromFinder.XREF_TYPE2STR:
                    continue
                
                if ref.to in idautils.FuncItems( func_ea ):
                    continue
                
                disas = idc.GetDisasm( item )
                curr_xref = XrefFrom( item, ref.to, ref.type, disas )
                xrefs.append( curr_xref )
                
        return xrefs 
開發者ID:darx0r,項目名稱:Reef,代碼行數:22,代碼來源:Reef.py

示例4: set_start_stop

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def set_start_stop(self, ftype):
        assert_ida_available()
        import idc
        import idaapi
        import idautils
        fun_mapping = {idc.GetFunctionName(x): (idaapi.get_func(x).startEA, idaapi.get_func(x).endEA-1)
                       for x in idautils.Functions()}
        start = idc.BeginEA()
        stop = 0
        if ftype == PE:
            start, stop = fun_mapping["start"]
        else:
            if not idc.isCode(idc.GetFlags(start)):
                if idc.MakeCode(start) == 0:
                    print "Fail to decode instr !"
                idaapi.autoWait()
            if idc.GetFunctionName(start) == "":
                if idc.MakeFunction(start) == 0:
                    print "Fail to create function !"
                idaapi.autoWait()
                fun_mapping = {idc.GetFunctionName(x): (idaapi.get_func(x).startEA, idaapi.get_func(x).endEA-1)
                               for x in idautils.Functions()}

            if "main" in fun_mapping:
                start, stop = fun_mapping["main"]
            elif "start" in fun_mapping:
                if "__libc_start_main" in fun_mapping:
                    instrs = list(idautils.FuncItems(fun_mapping["start"][0]))
                    instrs.reverse()
                    for inst in instrs:
                        arg1 = idc.GetOperandValue(inst, 0)
                        if idc.GetMnem(inst) == "push":
                            start, stop = arg1, fun_mapping["start"][1]
                            break
                else:
                    start, stop = fun_mapping["start"]
        self.config.start, self.config.stop = start, stop 
開發者ID:RobinDavid,項目名稱:idasec,代碼行數:39,代碼來源:configuration_file.py

示例5: process_routine

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def process_routine(self, rtn_addr, pred_addr=None, rtn_i=1, total_rtn=1):
        if rtn_addr not in self.functions_cfg:
            self.functions_cfg[rtn_addr] = MyFlowGraph(rtn_addr)
        cfg = self.functions_cfg[rtn_addr]
        path_to = self.config_to_path_function(cfg)
        if pred_addr is None:
            candidates = {x for x in idautils.FuncItems(rtn_addr) if idc.GetMnem(x) in cond_jump}
        else:
            candidates = {pred_addr}
        nb_candidates = len(candidates)
        self.functions_candidates[rtn_addr] = set()
        self.functions_spurious_instrs[rtn_addr] = set()

        self.progressbar_loading.reset()
        self.progressbar_loading.setMaximum(len(candidates))

        name = idc.GetFunctionName(rtn_addr)
        self.result_widget.webview.append("\n=> Function:%s\n" % name)

        self.log("[result]", "Start processing function: 0x%x" % rtn_addr)
        for i, addr in zip(xrange(len(candidates)), candidates):
            path = path_to(addr)
            res = self.process_addr(rtn_addr, addr, path)
            if self.STOP:
                return
            elif res is None:
                continue
            dead_br = "/" if res.dead_branch is None else "%x" % res.dead_branch
            self.result_widget.webview.append("%x:\t%s\t\tK:%d\tDead:%s" % (addr, to_status_name(res.status), res.k, dead_br))

            self.result_widget.webview.verticalScrollBar().setValue(self.result_widget.webview.verticalScrollBar().maximum())
            self.loading_stat.setText("Fun: %d/%d  Addr: %d/%d" % (rtn_i, total_rtn, i+1, nb_candidates))

            self.progressbar_loading.setValue(self.progressbar_loading.value()+1)
            self.functions_candidates[rtn_addr].add(addr) 
開發者ID:RobinDavid,項目名稱:idasec,代碼行數:37,代碼來源:static_opaque_analysis.py

示例6: iter_function_lines

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def iter_function_lines(func_ea) -> Iterable[Line]:
    """Iterate the lines of a function.

    Args:
        func_ea (idaapi.func_t, int): The function to iterate.

    Returns:
        Iterator over all the lines of the function.
    """
    for line in idautils.FuncItems(get_ea(func_ea)):
        yield Line(line) 
開發者ID:tmr232,項目名稱:Sark,代碼行數:13,代碼來源:function.py

示例7: count

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def count(self):
    """return the number of instructions contained in function"""
    return len(list(idautils.FuncItems(self.offset))) 
開發者ID:nirizr,項目名稱:rematch,代碼行數:5,代碼來源:function.py

示例8: data

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def data(self):
    md5 = hashlib.md5()
    for ea in idautils.FuncItems(self.offset):
      asm_line = idc.GetDisasmEx(ea, idc.GENDSM_MULTI_LINE)
      if ';' in asm_line:
        asm_line = asm_line[:asm_line.find(';')]
      asm_line = asm_line.strip()
      asm_line = " ".join(asm_line.split())
      asm_line = asm_line.lower()
      md5.update(asm_line)
    return md5.hexdigest() 
開發者ID:nirizr,項目名稱:rematch,代碼行數:13,代碼來源:assembly_hash.py

示例9: data

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def data(self):
    h = self.keleven
    for ea in idautils.FuncItems(self.offset):
      h = self._cycle(h, idc.Byte(ea))
      # go over all additional bytes of any instruction
      for i in range(ea + 1, ea + idc.ItemSize(ea)):
        h = self._cycle(h, idc.Byte(i))
    return h 
開發者ID:nirizr,項目名稱:rematch,代碼行數:10,代碼來源:instruction_hash.py

示例10: data

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def data(self):
    h = self.keleven
    for ea in idautils.FuncItems(self.offset):
      h = self._cycle(h, idc.Byte(ea))
      # skip additional bytes of any instruction that contains an offset in it
      if idautils.CodeRefsFrom(ea, False) or idautils.DataRefsFrom(ea):
        continue
      for i in range(ea + 1, ea + idc.ItemSize(ea)):
        h = self._cycle(h, idc.Byte(i))
    return h 
開發者ID:nirizr,項目名稱:rematch,代碼行數:12,代碼來源:identity_hash.py

示例11: data

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def data(self):
    md5 = hashlib.md5()
    for ea in idautils.FuncItems(self.offset):
      mnem_line = idc.GetMnem(ea)
      mnem_line = mnem_line.strip()
      mnem_line = mnem_line.lower()
      md5.update(mnem_line)
    return md5.hexdigest() 
開發者ID:nirizr,項目名稱:rematch,代碼行數:10,代碼來源:mnemonic_hash.py

示例12: check_for_wrapper

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def check_for_wrapper(func):
    flags = idc.GetFunctionFlags(func)
    #跳過庫函數和簡單的跳轉函數
    if flags & FUNC_LIB or flags & FUNC_THUNK:
        return
    dism_addr = list(idautils.FuncItems(func))
    #獲取函數的長度
    func_length = len(dism_addr)
    #如果函數的超過32條指令則返回
    if func_length > 0x20:
        return
    
    func_call = 0
    instr_cmp = 0
    op = None
    op_addr = None
    op_type = None
    
    #遍曆函數中的每條指令
    for ea in dism_addr:
        m = idc.GetMnem(ea)
        if m == 'call' or m == 'jmp':
            if m == 'jmp':
                temp = idc.GetOperandValue(ea, 0)
                # 忽略函數邊界內的跳轉
                if temp in dism_addr:
                    continue
            func_call += 1
            #封裝函數內不會包含多個函數調用
            if func_call == 2:
                return
            op_addr = idc.GetOperandValue(ea, 0)
            op_type = idc.GetOpType(ea, 0)
        elif m == 'cmp' or m == 'test':
            # 封裝函數內不應該包含太多的邏輯運算
            instr_cmp += 1
            if instr_cmp == 3:
                return
        else:
            continue
    
    # 所有函數內的指令都被分析過了
    if op_addr == None:
        return
    
    name = idc.Name(op_addr)
    #跳過名稱粉碎的函數名稱
    if "[" in name or "$" in name or "?" in name or "@" in name or name == "":
        return
    name = "w_" + name
    if op_type == o_near:
        if idc.GetFunctionFlags(op_addr) & FUNC_THUNK:
            rename_wrapper(name, func)
            return
    if op_type == o_mem or op_type == o_far:
        rename_wrapper(name, func)
        return 
開發者ID:ExpLife0011,項目名稱:IDAPython_Note,代碼行數:59,代碼來源:13_注釋和重命名.py

示例13: graph_down

# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import FuncItems [as 別名]
def graph_down(ea, path=set()):
    """
    Recursively collect all function calls.

    Copied with minor modifications from
    http://hooked-on-mnemonics.blogspot.com/2012/07/renaming-subroutine-blocks-and.html
    """
    path.add(ea)

    #
    # extract all the call instructions from the current function
    #

    call_instructions = []
    instruction_info = idaapi.insn_t()
    for address in idautils.FuncItems(ea):

        # decode the instruction
        if not idaapi.decode_insn(instruction_info, address):
            continue

        # check if this instruction is a call
        if not idaapi.is_call_insn(instruction_info):
            continue

        # save this address as a call instruction
        call_instructions.append(address)

    #
    # iterate through all the instructions in the target function (ea) and
    # inspect all the call instructions
    #

    for x in call_instructions:

        #  TODO
        for r in idautils.XrefsFrom(x, idaapi.XREF_FAR):
            #print(0x%08X" % h, "--calls-->", "0x%08X" % r.to)
            if not r.iscode:
                continue

            # get the function pointed at by this call
            func = idaapi.get_func(r.to)
            if not func:
                continue

            # ignore calls to imports / library calls / thunks
            if (func.flags & (idaapi.FUNC_THUNK | idaapi.FUNC_LIB)) != 0:
                continue

            #
            # if we have not traversed to the destination function that this
            # call references, recurse down to it to continue our traversal
            #

            if r.to not in path:
                graph_down(r.to, path)

    return path 
開發者ID:gaasedelen,項目名稱:prefix,代碼行數:61,代碼來源:ida_prefix.py


注:本文中的idautils.FuncItems方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。