本文整理汇总了Python中idautils.Segments方法的典型用法代码示例。如果您正苦于以下问题:Python idautils.Segments方法的具体用法?Python idautils.Segments怎么用?Python idautils.Segments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idautils
的用法示例。
在下文中一共展示了idautils.Segments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_call_map
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def create_call_map(self, ftype):
assert_ida_available()
import idc
import idautils
seg_mapping = {idc.SegName(x): (idc.SegStart(x), idc.SegEnd(x)) for x in idautils.Segments()}
imports = seg_mapping[".idata"] if ftype == PE else seg_mapping['.plt']
start, stop = seg_mapping[".text"]
current = start
while current <= stop:
inst = current
if idc.GetMnem(inst) in ["call", "jmp"]:
value = idc.GetOperandValue(inst, 0)
name = idc.GetOpnd(inst, 0)
if imports[0] <= value <= imports[1]:
entry = self.config.call_map.add()
entry.address = inst
entry.name = name
current = idc.NextHead(current, stop)
示例2: initialize_data_offsets
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def initialize_data_offsets():
"""Convert offsets in data segments into offsets in IDA.
Segment names must be initialized with segments.initialize_segments() first.
"""
# Normally, for user-space programs, this operation would be dangerous because there's a good
# chance that a valid userspace address would happen to show up in regular program data that is
# not actually an address. However, since kernel addresses are numerically much larger, the
# chance of this happening is much less.
for seg in idautils.Segments():
name = idc.SegName(seg)
if not (name.endswith('__DATA_CONST.__const') or name.endswith('__got')
or name.endswith('__DATA.__data')):
continue
for word, ea in idau.ReadWords(seg, idc.SegEnd(seg), addresses=True):
if idau.is_mapped(word, value=False):
idc.OpOff(ea, 0, 0)
示例3: initialize_stub_symbols
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def initialize_stub_symbols(make_thunk=True):
"""Populate IDA with information about the stubs in an iOS kernelcache.
Search through the kernelcache for stubs (__stubs sections) and rename each stub function
according to the target function it calls.
Arm64 only.
Options:
make_thunk: Set the thunk attribute for each stub function. Default is True.
"""
next_stub = internal.make_name_generator(kernelcache_stub_suffix)
for ea in idautils.Segments():
segname = idc.SegName(ea)
if not segname.endswith('__stubs'):
continue
_log(3, 'Processing segment {}', segname)
_process_stubs_section(ea, make_thunk, next_stub)
示例4: _find_prelink_info_segments
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def _find_prelink_info_segments():
"""Find all candidate __PRELINK_INFO segments (or sections).
We try to identify any IDA segments with __PRELINK_INFO in the name so that this function will
work both before and after automatic rename. A more reliable method would be parsing the
Mach-O.
"""
segments = []
# Gather a list of all the possible segments.
for seg in idautils.Segments():
name = idc.SegName(seg)
if '__PRELINK_INFO' in name or name == '__info':
segments.append(seg)
if len(segments) < 1:
_log(0, 'Could not find any __PRELINK_INFO segment candidates')
elif len(segments) > 1:
_log(1, 'Multiple segment names contain __PRELINK_INFO: {}',
[idc.SegName(seg) for seg in segments])
return segments
示例5: print_section_list
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def print_section_list():
for s in idautils.Segments():
seg = idaapi.getseg(s)
print("%s" % idc.SegName(s))
print(" - start address: 0x%x" % seg.startEA)
print(" - sclass: 0x%x" % seg.sclass)
print(" - orgbase: 0x%x" % seg.orgbase)
print(" - flags: 0x%x" % seg.flags)
print(" - align: 0x%x" % seg.align)
print(" - comb: 0x%x" % seg.comb)
print(" - perm: 0x%x" % seg.perm)
print(" - bitness: 0x%x" % seg.bitness)
print(" - sel: 0x%x" % seg.sel)
# print(' - defsr: 0x%x' % seg.defsr)
print(" - type: 0x%x" % seg.type)
print(" - color: 0x%x" % seg.color)
示例6: get_line_comments
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def get_line_comments():
"""
Iterate through every address in a segment and check for comments
:return: Dict containing line comments
"""
last_comment = ''
comments = {}
for ea in idautils.Segments():
segm = ida_segment.getseg(ea)
name = ida_segment.get_segm_name(segm)
if name == 'LOAD':
continue
for i in range(segm.start_ea, segm.end_ea):
comment = get_single_line_comment(i)
if comment and comment != last_comment:
comments[i] = comment
last_comment = comment
return comments
示例7: get_sections
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def get_sections():
"""
Get section names and start/end addrs from IDA database
:return: Dict containing section info
"""
sections = {}
for ea in idautils.Segments():
segm = ida_segment.getseg(ea)
name = ida_segment.get_segm_name(segm)
if name == 'LOAD':
continue
curr = {}
curr['start'] = segm.start_ea
curr['end'] = segm.end_ea
sections[name] = curr
return sections
示例8: getx86CodeSize
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def getx86CodeSize(ea=None):
'''
For a given EA, finds the code size. Returns 16 for-16bit, 32 for 32-bit, or 64 for 64-bit.
If no EA is given, searches through all segments for a code segment to use.
'''
if using_ida7api:
return getx86CodeSize_ida7(ea)
if ea is None:
for seg in idautils.Segments():
if idc.GetSegmentAttr(seg, idc.SEGATTR_TYPE) == idc.SEG_CODE:
ea = seg
break
if ea is None:
raise RuntimeError('Could not find code segment to use for getx86CodeSize')
bitness = idc.GetSegmentAttr(ea, idc.SEGATTR_BITNESS)
if bitness == 0:
return 16
elif bitness == 1:
return 32
elif bitness == 2:
return 64
raise RuntimeError('Bad bitness')
示例9: init_seginfo
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def init_seginfo(self):
#print("seg len:%d\n" % len(list(idautils.Segments())))
for seg in idautils.Segments():
segname = idc.SegName(seg)
if segname.startswith('func_'):
self.segstarts[idc.SegStart(seg)] = segname
self.segends[idc.SegEnd(seg)] = segname
#print("segname:%s\n" % segname)
#print("add_func() called ret:%d" % add_func(idc.SegStart(seg), idc.SegEnd(seg)))
示例10: update_mapping
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def update_mapping(self):
pass
self.fun_mapping = {idc.GetFunctionName(x): (idaapi.get_func(x).startEA, idaapi.get_func(x).endEA-1) for x in
idautils.Functions()}
self.seg_mapping = {idc.SegName(x): (idc.SegStart(x), idc.SegEnd(x)) for x in idautils.Segments()}
示例11: numSegments
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def numSegments(self):
"""Return the number of the segments in the binary.
Return Value:
number of segments in the binary
"""
return len(list(idautils.Segments()))
# Overridden base function
示例12: enum_segments
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def enum_segments():
for segstart in idautils.Segments():
segend = idc.get_segm_end(segstart)
segname = idc.get_segm_name(segstart)
yield segstart, segend, segname
示例13: get_segments
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def get_segments():
'''
fetch the segments in the current executable.
'''
for segstart in idautils.Segments():
segend = idaapi.getseg(segstart).end_ea
segsize = segend - segstart
segname = str(idc.SegName(segstart)).rstrip('\x00')
segbuf = get_segment_buffer(segstart)
yield Segment(segstart, segend, segname, segbuf)
示例14: enum_segments
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def enum_segments():
for ea in idautils.Segments():
seg = ida_segment.getseg(ea)
yield Segment(seg.start_ea, seg.end_ea, seg.name)
示例15: save_sstring
# 需要导入模块: import idautils [as 别名]
# 或者: from idautils import Segments [as 别名]
def save_sstring(s):
"""
Save a short string inside the idb.
"""
min_segment_addr = min(list(idautils.Segments()))
# Keep the string as a regular comment on the first instruction:
idc.MakeComm(min_segment_addr,s)