本文整理匯總了Python中idautils.CodeRefsFrom方法的典型用法代碼示例。如果您正苦於以下問題:Python idautils.CodeRefsFrom方法的具體用法?Python idautils.CodeRefsFrom怎麽用?Python idautils.CodeRefsFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類idautils
的用法示例。
在下文中一共展示了idautils.CodeRefsFrom方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_succs
# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import CodeRefsFrom [as 別名]
def get_succs(ea):
return [x for x in idautils.CodeRefsFrom(ea, True)]
示例2: refine_results
# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import CodeRefsFrom [as 別名]
def refine_results(self):
likely_retag = 0
fp_retag = 0
fn_retag = 0
for rtn_addr, candidates in self.functions_candidates.items():
for addr in sorted(candidates):
res = self.results[addr]
val = sum([x in res.predicate for x in ["(0 :: 2)", "7x", "7y", u"²"]])
final_status = res.status
alive, dead = res.alive_branch, res.dead_branch
if res.status == self.po.NOT_OPAQUE:
if val != 0:
fn_retag += 1
final_status = self.po.OPAQUE
jmp_target = [x for x in idautils.CodeRefsFrom(addr, 0)][0]
next_target = [x for x in idautils.CodeRefsFrom(addr, 1) if x != jmp_target][0]
alive, dead = (next_target, jmp_target) if idc.GetDisasm(addr)[:2] == "jz" else (jmp_target, next_target)
self.functions_spurious_instrs[rtn_addr].update(res.dependency+[addr])
elif res.status == self.po.OPAQUE:
if val == 0:
fp_retag += 1
final_status = self.po.NOT_OPAQUE
elif res.status == self.po.LIKELY:
if val == 0:
final_status = self.po.NOT_OPAQUE
else:
final_status = self.po.OPAQUE
jmp_target = [x for x in idautils.CodeRefsFrom(addr, 0)][0]
next_target = [x for x in idautils.CodeRefsFrom(addr, 1) if x != jmp_target][0]
alive, dead = (next_target, jmp_target) if idc.GetDisasm(addr)[:2] == "jz" else (jmp_target, next_target)
self.functions_spurious_instrs[rtn_addr].update(res.dependency+[addr])
likely_retag += 1
self.results[addr] = AddrRet(final_status, res.k, res.dependency, res.predicate, res.distance, alive, dead)
print "Retag: FP->OK:%d" % fp_retag
print "Retag: FN->OP:%d" % fn_retag
print "Retag: Lkl->OK:%d" % likely_retag
示例3: make_po_pair
# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import CodeRefsFrom [as 別名]
def make_po_pair(ea, alive):
dead = [x for x in idautils.CodeRefsFrom(ea, True) if x != alive]
return alive, dead[0]
示例4: propagate_dead_code
# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import CodeRefsFrom [as 別名]
def propagate_dead_code(self, ea, op_map):
prevs = [x for x in idautils.CodeRefsTo(ea, True) if x not in self.marked_addresses and
not self.dead_br_of_op(ea, x, op_map)]
if prevs: # IF there is no legit predecessors
idc.SetColor(ea, idc.CIC_ITEM, 0x0000ff)
self.marked_addresses[ea] = None
succs = [x for x in idautils.CodeRefsFrom(ea, True)]
for succ in succs:
self.propagate_dead_code(succ, op_map)
else:
return
示例5: crefs_from
# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import CodeRefsFrom [as 別名]
def crefs_from(self):
"""Destination addresses of code references from this line."""
return idautils.CodeRefsFrom(self.ea, 1)
示例6: __init__
# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import CodeRefsFrom [as 別名]
def __init__(self, addr):
self.addr = addr
self.dests = set(idautils.CodeRefsFrom(addr, True))
self.jmps = set(idautils.CodeRefsFrom(addr, False))
falls = self.dests - self.jmps
self.fall = list(falls)[0] if falls else None
示例7: data
# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import CodeRefsFrom [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
示例8: find_function_callees
# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import CodeRefsFrom [as 別名]
def find_function_callees( func_ea, maxlvl ):
callees = []
visited = set()
pending = set( (func_ea,) )
lvl = 0
while len(pending) > 0:
func_ea = pending.pop()
visited.add(func_ea)
func_name = idc.GetFunctionName(func_ea)
if not func_name: continue
callees.append(func_ea)
func_end = idc.FindFuncEnd(func_ea)
if func_end == idaapi.BADADDR: continue
lvl +=1
if lvl >= maxlvl: continue
all_refs = set()
for line in idautils.Heads(func_ea, func_end):
if not ida_bytes.isCode(get_flags(line)): continue
ALL_XREFS = 0
refs = idautils.CodeRefsFrom(line, ALL_XREFS)
refs = set( filter( lambda x: not (x >= func_ea and x <= func_end),
refs) )
all_refs |= refs
all_refs -= visited
pending |= all_refs
return callees
示例9: getCodeOutRefs
# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import CodeRefsFrom [as 別名]
def getCodeOutRefs(self, offset):
return [(offset, ref_to) for ref_to in idautils.CodeRefsFrom(offset, True)]
示例10: _ida_refresh_nodes
# 需要導入模塊: import idautils [as 別名]
# 或者: from idautils import CodeRefsFrom [as 別名]
def _ida_refresh_nodes(self, _):
"""
Refresh function node metadata against an open IDA database.
"""
function_metadata = self
function_metadata.nodes = {}
# get function & flowchart object from IDA database
function = idaapi.get_func(self.address)
flowchart = idaapi.qflow_chart_t("", function, idaapi.BADADDR, idaapi.BADADDR, 0)
#
# now we will walk the flowchart for this function, collecting
# information on each of its nodes (basic blocks) and populating
# the function & node metadata objects.
#
for node_id in xrange(flowchart.size()):
node = flowchart[node_id]
#
# the node current node appears to have a size of zero. This means
# that another flowchart / function owns this node so we can just
# ignore it...
#
if node.start_ea == node.end_ea:
continue
# create a new metadata object for this node
node_metadata = NodeMetadata(node.start_ea, node.end_ea, node_id)
#
# establish a relationship between this node (basic block) and
# this function metadata (its parent)
#
function_metadata.nodes[node.start_ea] = node_metadata
# compute all of the edges between nodes in the current function
for node_metadata in itervalues(function_metadata.nodes):
edge_src = node_metadata.edge_out
for edge_dst in idautils.CodeRefsFrom(edge_src, True):
if edge_dst in function_metadata.nodes:
function_metadata.edges[edge_src].append(edge_dst)