本文整理汇总了Python中idc.GetFlags方法的典型用法代码示例。如果您正苦于以下问题:Python idc.GetFlags方法的具体用法?Python idc.GetFlags怎么用?Python idc.GetFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idc
的用法示例。
在下文中一共展示了idc.GetFlags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_analysis_stuff
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def post_analysis_stuff(self, results):
if results.has_formula():
self.action_selector.addItem(self.parent.HIGHLIGHT_CODE)
self.action_selector.addItem(self.parent.GRAPH_DEPENDENCY)
self.formula_area.setText(self.parent.results.formula)
if results.has_values():
self.action_selector.addItem(self.parent.DISASS_UNKNOWN_TARGET)
self.action_selector.setEnabled(True)
self.action_button.setEnabled(True)
report = HTMLReport()
report.add_title("Results", size=3)
report.add_table_header(["address", "assertion", "status", "values"])
addr = make_cell("%x" % results.target)
status = make_cell(results.get_status(), color=results.color, bold=True)
vals = ""
for value in results.values:
flag = idc.GetFlags(value)
typ = self.type_to_string(flag)
vals += "%x type:%s seg:%s fun:%s<br/>" % (value, typ, idc.SegName(value), idc.GetFunctionName(value))
report.add_table_line([addr, make_cell(cgi.escape(results.query)), status, make_cell(vals)])
report.end_table()
data = report.generate()
self.result_area.setHtml(data)
示例2: is_internal_code
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def is_internal_code(ea):
if is_invalid_ea(ea):
return False
if is_external_segment(ea):
return False
if is_code(ea):
return True
# find stray 0x90 (NOP) bytes in .text that IDA
# thinks are data items.
flags = idc.GetFlags(ea)
if idaapi.isAlign(flags):
if not try_mark_as_code(ea):
return False
return True
return False
示例3: get_symbol_name
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def get_symbol_name(from_ea, ea=None, allow_dummy=False):
if ea is None:
ea = from_ea
global _FORCED_NAMES
if ea in _FORCED_NAMES:
return _FORCED_NAMES[ea]
flags = idc.GetFlags(ea)
if not allow_dummy and idaapi.has_dummy_name(flags):
return ""
name = ""
try:
name = name or idc.GetTrueNameEx(from_ea, ea)
except:
pass
try:
name = name or idc.GetFunctionName(ea)
except:
pass
return name
示例4: get_list_of_function_instr
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def get_list_of_function_instr(addr, mode):
#TODO follow subcalls MODE_INSTRUMENT_SUBCALLS
f_start = addr
f_end = idc.FindFuncEnd(addr)
chunks = enumerate_function_chunks(f_start)
list_of_addr = list()
image_base = idaapi.get_imagebase(addr)
for chunk in chunks:
for head in idautils.Heads(chunk[0], chunk[1]):
# If the element is an instruction
if head == hex(0xffffffffL):
raise Exception("Invalid head for parsing")
if isCode(idc.GetFlags(head)):
head = head - image_base
head = str(hex(head))
head = head.replace("L", "")
head = head.replace("0x", "")
list_of_addr.append(head)
return list_of_addr
示例5: get_bbl_head
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def get_bbl_head(self, head):
"""
The function returns address of the head instruction
for the basic block.
@head - address of arbitrary instruction in the basic block.
@return - head address of the basic block.
"""
while 1:
prev_head = idc.PrevHead(head, 0)
if isFlow(idc.GetFlags(prev_head)):
head = prev_head
if prev_head >= SegEnd(head):
raise Exception("Can't identify bbl head")
continue
else:
if prev_head == hex(0xffffffffL):
return head
else:
return prev_head
break
示例6: disassemble_new_targets
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def disassemble_new_targets(self, _):
for value in self.results.values:
flag = idc.GetFlags(value)
if not idc.isCode(flag) and idc.isUnknown(flag):
res = idc.MakeCode(value)
if res == 0:
print "Try disassemble at:"+hex(value)+" KO"
# TODO: Rollback ?
else:
print "Try disassemble at:"+hex(value)+" Success !"
# ============================= RESULT WIDGET ===============================
# ===========================================================================
示例7: is_code_by_flags
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def is_code_by_flags(ea):
if not is_code(ea):
return False
flags = idc.GetFlags(ea)
return idc.isCode(flags)
示例8: read_bytes_slowly
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def read_bytes_slowly(start, end):
bytestr = []
for i in xrange(start, end):
if idc.hasValue(idc.GetFlags(i)):
bt = idc.Byte(i)
bytestr.append(chr(bt))
else:
bytestr.append("\x00")
return "".join(bytestr)
示例9: make_xref
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def make_xref(from_ea, to_ea, xref_constructor, xref_size):
"""Force the data at `from_ea` to reference the data at `to_ea`."""
if not idc.GetFlags(to_ea) or is_invalid_ea(to_ea):
DEBUG(" Not making reference (A) from {:x} to {:x}".format(from_ea, to_ea))
return
make_head(from_ea)
if is_code(from_ea):
_CREFS_FROM[from_ea].add(to_ea)
_CREFS_TO[to_ea].add(from_ea)
else:
_DREFS_FROM[from_ea].add(to_ea)
_DREFS_TO[to_ea].add(from_ea)
# If we can't make a head, then it probably means that we're at the
# end of the binary, e.g. the last thing in the `.extern` segment.
if not make_head(from_ea + xref_size):
assert idc.BADADDR == idc.SegStart(from_ea + xref_size)
idaapi.do_unknown_range(from_ea, xref_size, idc.DOUNK_EXPAND)
xref_constructor(from_ea)
if not is_code_by_flags(from_ea):
idc.add_dref(from_ea, to_ea, idc.XREF_USER|idc.dr_O)
else:
DEBUG(" Not making reference (B) from {:x} to {:x}".format(from_ea, to_ea))
示例10: is_head
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def is_head(ea):
return idc.isHead(idc.GetFlags(ea))
# Make the data at `ea` into a head.
示例11: make_head
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def make_head(ea):
flags = idc.GetFlags(ea)
if not idc.isHead(flags):
idc.SetFlags(ea, flags | idc.FF_DATA)
idaapi.autoWait()
return is_head(ea)
return True
示例12: make_array
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def make_array(ea, size):
if ea != idc.BADADDR and ea != 0:
flags = idc.GetFlags(ea)
if not idc.isByte(flags) or idc.ItemSize(ea) != 1:
idc.MakeUnknown(ea, 1, idc.DOUNK_SIMPLE)
idc.MakeByte(ea)
idc.MakeArray(ea, size)
示例13: find_xrefs
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def find_xrefs(addr):
lrefs = list(idautils.DataRefsTo(addr))
if len(lrefs) == 0:
lrefs = list(idautils.refs(addr, first, next))
lrefs = [r for r in lrefs if not idc.isCode(idc.GetFlags(r))]
return lrefs
示例14: fix_vxworks_idb
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def fix_vxworks_idb(load_address, vx_version, symbol_table_start, symbol_table_end):
current_image_base = idaapi.get_imagebase()
symbol_interval = 16
if vx_version == 6:
symbol_interval = 20
symbol_table_start += load_address
symbol_table_end += load_address
ea = symbol_table_start
shift_address = load_address - current_image_base
while shift_address >= 0x70000000:
idaapi.rebase_program(0x70000000, 0x0008)
shift_address -= 0x70000000
idaapi.rebase_program(shift_address, 0x0008)
while ea < symbol_table_end:
# for VxWorks 6 unknown symbol format
if idc.Byte(ea + symbol_table_end - 2) == 3:
ea += symbol_interval
continue
offset = 4
if idaapi.IDA_SDK_VERSION >= 700:
idc.create_strlit(idc.Dword(ea + offset), idc.BADADDR)
else:
idc.MakeStr(idc.Dword(ea + offset), idc.BADADDR)
sName = idc.GetString(idc.Dword(ea + offset), -1, idc.ASCSTR_C)
print("Found %s in symbol table" % sName)
if sName:
sName_dst = idc.Dword(ea + offset + 4)
if vx_version == 6:
sName_type = idc.Dword(ea + offset + 12)
else:
sName_type = idc.Dword(ea + offset + 8)
idc.MakeName(sName_dst, sName)
if sName_type in need_create_function:
# flags = idc.GetFlags(ea)
print("Start fix Function %s at %s" % (sName, hex(sName_dst)))
idc.MakeCode(sName_dst) # might not need
idc.MakeFunction(sName_dst, idc.BADADDR)
ea += symbol_interval
print("Fix function by symbol table finish.")
print("Start IDA auto analysis, depending on the size of the firmware this might take a few minutes.")
idaapi.autoWait()
示例15: fix_code
# 需要导入模块: import idc [as 别名]
# 或者: from idc import GetFlags [as 别名]
def fix_code(start_address, end_address):
# Todo: There might be some data in the range of codes.
offset = start_address
while offset <= end_address:
offset = idc.NextAddr(offset)
flags = idc.GetFlags(offset)
if not idc.isCode(flags):
# Todo: Check should use MakeCode or MakeFunction
# idc.MakeCode(offset)
idc.MakeFunction(offset)