本文整理汇总了Python中idc.Byte方法的典型用法代码示例。如果您正苦于以下问题:Python idc.Byte方法的具体用法?Python idc.Byte怎么用?Python idc.Byte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idc
的用法示例。
在下文中一共展示了idc.Byte方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_leb128
# 需要导入模块: import idc [as 别名]
# 或者: from idc import Byte [as 别名]
def read_leb128(ea, signed):
""" Read LEB128 encoded data
"""
val = 0
shift = 0
while True:
byte = idc.Byte(ea)
val |= (byte & 0x7F) << shift
shift += 7
ea += 1
if (byte & 0x80) == 0:
break
if shift > 64:
DEBUG("Bad leb128 encoding at {0:x}".format(ea - shift/7))
return idc.BADADDR
if signed and (byte & 0x40):
val -= (1<<shift)
return val, ea
示例2: read_word
# 需要导入模块: import idc [as 别名]
# 或者: from idc import Byte [as 别名]
def read_word(ea, wordsize=WORD_SIZE):
"""Get the word at the given address.
Words are read using Byte(), Word(), Dword(), or Qword(), as appropriate. Addresses are checked
using is_mapped(). If the address isn't mapped, then None is returned.
"""
if not is_mapped(ea, wordsize):
return None
if wordsize == 1:
return idc.Byte(ea)
if wordsize == 2:
return idc.Word(ea)
if wordsize == 4:
return idc.Dword(ea)
if wordsize == 8:
return idc.Qword(ea)
raise ValueError('Invalid argument: wordsize={}'.format(wordsize))
示例3: read_bytes_slowly
# 需要导入模块: import idc [as 别名]
# 或者: from idc import Byte [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)
示例4: xor
# 需要导入模块: import idc [as 别名]
# 或者: from idc import Byte [as 别名]
def xor(size, key, buff):
for index in range(0, size):
cur_addr = buff + index
temp = idc.Byte(cur_addr) ^ key
idc.PatchByte(cur_addr, temp)
示例5: data
# 需要导入模块: import idc [as 别名]
# 或者: from idc import Byte [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
示例6: data
# 需要导入模块: import idc [as 别名]
# 或者: from idc import Byte [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
示例7: append_bytes
# 需要导入模块: import idc [as 别名]
# 或者: from idc import Byte [as 别名]
def append_bytes(instr, addr):
for j in range(instr.size):
sig.append(Byte(addr))
addr += 1
return addr
示例8: fix_vxworks_idb
# 需要导入模块: import idc [as 别名]
# 或者: from idc import Byte [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()
示例9: getByte
# 需要导入模块: import idc [as 别名]
# 或者: from idc import Byte [as 别名]
def getByte(self, ea):
if idaapi.IDA_SDK_VERSION < 700:
return idc.Byte(ea)
else:
return idc.get_wide_byte(ea)
示例10: getString
# 需要导入模块: import idc [as 别名]
# 或者: from idc import Byte [as 别名]
def getString(ea, maxLen=0x200):
'''Returns up to 0x200 bytes, until a null is found'''
if using_ida7api:
return getString_ida7(ea, maxLen)
i = 0
retList = []
while i < maxLen:
b = idc.Byte(ea+i)
if b == 0x00:
break
retList.append(chr(b))
i += 1
return ''.join(retList)