本文整理匯總了Python中idc.GetManyBytes方法的典型用法代碼示例。如果您正苦於以下問題:Python idc.GetManyBytes方法的具體用法?Python idc.GetManyBytes怎麽用?Python idc.GetManyBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類idc
的用法示例。
在下文中一共展示了idc.GetManyBytes方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: chunk_from_path
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import GetManyBytes [as 別名]
def chunk_from_path(path):
assert_ida_available()
import idc
chunk = chunk_t()
for i in xrange(len(path)):
body = chunk.body.add()
body.typeid = body.INSTRUCTION
inst = body.instruction
inst.thread_id = 0
addr = path[i]
inst.address = addr
inst.opcode = idc.GetManyBytes(addr, idc.NextHead(addr)-addr)
try:
next_a = path[i+1]
inf1 = inst.concrete_infos.add()
inf1.next_address = next_a
inf1.typeid = inf1.NEXT_ADDRESS
except IndexError:
pass
inf2 = inst.concrete_infos.add()
inf2.typeid = inf2.NOT_RETRIEVED
return chunk
示例2: add_initial_state_action
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import GetManyBytes [as 別名]
def add_initial_state_action(self):
from_addr = self.initial_state_from_field.text()
to_addr = self.initial_state_to_field.text()
if from_addr == "" or to_addr == "":
print "One of the two fields from/to is empty"
return
try:
from_addr = int(from_addr, 16)
to_addr = int(to_addr, 16)
if to_addr <= from_addr:
print "'To' address must be strictly superior than 'from'"
else:
raw = base64.b64encode(idc.GetManyBytes(from_addr, to_addr-from_addr+1))
self.initial_state_list.addItem("%x -> %x: %s" % (from_addr, to_addr, raw))
except ValueError:
print "From or To cannot be converted to address"
示例3: _read_struct_member_once
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import GetManyBytes [as 別名]
def _read_struct_member_once(ea, flags, size, member_sid, member_size, asobject):
"""Read part of a struct member for _read_struct_member."""
if idc.isByte(flags):
return read_word(ea, 1), 1
elif idc.isWord(flags):
return read_word(ea, 2), 2
elif idc.isDwrd(flags):
return read_word(ea, 4), 4
elif idc.isQwrd(flags):
return read_word(ea, 8), 8
elif idc.isOwrd(flags):
return read_word(ea, 16), 16
elif idc.isASCII(flags):
return idc.GetManyBytes(ea, size), size
elif idc.isFloat(flags):
return idc.Float(ea), 4
elif idc.isDouble(flags):
return idc.Double(ea), 8
elif idc.isStruct(flags):
value = read_struct(ea, sid=member_sid, asobject=asobject)
return value, member_size
return None, size
示例4: decode_here_clicked
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import GetManyBytes [as 別名]
def decode_here_clicked(self):
inst = idc.here()
if not idc.isCode(idc.GetFlags(inst)):
print "Not code instruction"
else:
raw = idc.GetManyBytes(inst, idc.NextHead(inst)-inst)
s = to_hex(raw)
self.decode_ir(s)
示例5: _get_func_data
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import GetManyBytes [as 別名]
def _get_func_data(func_addr):
"""
Get function's data
"""
logger.debug('_get_func_data: {}'.format(func_addr))
func_length = _get_func_length(func_addr)
if func_length is None:
return None
func_data = idc.GetManyBytes(func_addr,func_length)
if func_data is None:
return None
# raise FCatalogClientError('Failed reading function {:X} data'.\
# format(func_addr))
return str(func_data)
示例6: getData
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import GetManyBytes [as 別名]
def getData(self):
#獲取起始地址和結束地址之間的數據,並將它們存入object.buffer中
self.ogLen = self.end - self.start
self.buffer = ''
try:
for byte in idc.GetManyBytes(self.start, self.ogLen):
self.buffer = self.buffer + byte
except:
self.start = False
return
示例7: get_segment_buffer
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import GetManyBytes [as 別名]
def get_segment_buffer(segstart):
"""
fetch the bytes of the section that starts at the given address.
if the entire section cannot be accessed, try smaller regions until it works.
"""
segend = idaapi.getseg(segstart).endEA
buf = None
segsize = segend - segstart
while buf is None:
buf = idc.GetManyBytes(segstart, segsize - 1)
if buf is None:
segsize -= 0x1000
return buf
示例8: decodeString
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import GetManyBytes [as 別名]
def decodeString(strLoc, count, const1):
buff = idc.GetManyBytes(strLoc, count)
decString = decodeSoguBytes20100921_strings(buff, 0, count, const1)
return decString
示例9: __init__
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import GetManyBytes [as 別名]
def __init__(self, ea, info, cs):
"""Initialization function."""
# Init the node structure
node_t.__init__(self)
# Check if it's a code instruction
try:
is_c = is_code(get_flags(ea))
except:
is_c = isCode(GetFlags(ea))
if not is_c:
raise CodeException
#
# fill node_t struct
#
# NodeInfo
self.info = NodeInfo()
inst_elements = []
try:
size = create_insn(ea)
bytes = get_bytes(ea, size)
except:
size = MakeCode(ea)
bytes = GetManyBytes(ea, size)
(address, size, mnemonic, op_str) = next(cs.disasm_lite(bytes, ea, count=1))
self.info.opcode = mnemonic
self.info.inst_str = self.info.opcode + " " + op_str
splitted = op_str.split(", ")
self.info.nargs = 0
if len(splitted) >= 1:
self.info.arg1 = splitted[0]
self.info.nargs += 1
if len(splitted) >= 2:
self.info.arg2 = splitted[1]
self.info.nargs += 1
if len(splitted) >= 3:
self.info.arg3 = splitted[2]
self.info.nargs += 1
# No node will be root but this is acceptable for CFGs
self.info.is_root = False
self.info.address = ea
self.info.has_address = True
# node_t
self.node_id = self._genid()
示例10: get_padded_bytes
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import GetManyBytes [as 別名]
def get_padded_bytes(self, size):
result = "\x00" * size
ranges_left = [MemoryRange(self.address, self.address + size)]
segment_count = idaapi.get_segm_qty()
valid_memory_ranges = []
for i in range(segment_count):
segment = idaapi.getnseg(i)
# Skip segments with unstable data
if segment.type == idaapi.SEG_XTRN:
continue
valid_memory_ranges.append(
MemoryRange(segment.startEA, segment.endEA)
)
while len(ranges_left) > 0:
# Get a requested memory range and remove it from the list
current_range = ranges_left.pop()
intersection = None
for memory_range in valid_memory_ranges:
start = max(current_range.start, memory_range.start)
end = min(current_range.end, memory_range.end)
if end > start:
intersection = MemoryRange(start, end)
break
# No segment can satisfy any part of requested range
if intersection is None:
continue
chunk = idc.GetManyBytes(
intersection.start, intersection.end - intersection.start
)
if chunk is None:
print(
"[librgb] Some bytes are unreadable in %s..%s"
% (
idc.atoa(intersection.start),
idc.atoa(intersection.end),
)
)
continue
result = (
result[0 : intersection.start - self.address]
+ chunk
+ result[intersection.end - self.address :]
)
assert len(result) == size
# If necessary, enqueue ranges unsatisfied by chosen mem segment
range1 = MemoryRange(current_range.start, intersection.start)
range2 = MemoryRange(intersection.end, current_range.end)
if range1.length > 0:
ranges_left.append(range1)
if range2.length > 0:
ranges_left.append(range2)
assert len(result) == size
return result