Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
bits = 64
vex_arch = "VexArchARM64"
name = "AARCH64"
qemu_name = 'aarch64'
ida_processor = 'arm'
linux_name = 'aarch64'
triplet = 'aarch64-linux-gnueabihf'
max_inst_bytes = 4
ret_offset = 16
vex_conditional_helpers = True
syscall_num_offset = 80
call_pushes_ret = False
stack_change = -8
memory_endness = Endness.LE
register_endness = Endness.LE
instruction_endness = Endness.LE
sizeof = {'short': 16, 'int': 32, 'long': 64, 'long long': 64}
if _capstone:
cs_arch = _capstone.CS_ARCH_ARM64
cs_mode = _capstone.CS_MODE_LITTLE_ENDIAN
if _keystone:
ks_arch = _keystone.KS_ARCH_ARM64
ks_mode = _keystone.KS_MODE_LITTLE_ENDIAN
uc_arch = _unicorn.UC_ARCH_ARM64 if _unicorn else None
uc_mode = _unicorn.UC_MODE_LITTLE_ENDIAN if _unicorn else None
uc_const = _unicorn.arm64_const if _unicorn else None
uc_prefix = "UC_ARM64_" if _unicorn else None
initial_sp = 0x7ffffffffff0000
ret_instruction = b"\xC0\x03\x5F\xD6" # ret
nop_instruction = b"\x1F\x20\x03\xD5" # nop
from archinfo.arch import Arch, Register, Endness
from archinfo.arch import register_arch
class ArchBF(Arch):
memory_endness = Endness.LE
bits = 64
vex_arch = None
name = "BF"
instruction_alignment = 1
# Things I did not want to include but were necessary unfortunately :-(
# self.cs_mode = capstone.CS_MODE_LITTLE_ENDIAN if endness == 'Iend_LE' else capstone.CS_MODE_BIG_ENDIAN
# END
# registers is a dictionary mapping register names, to a tuple of
# register offset, and their width, in bytes
register_list = [
Register(name="ip", size=8, vex_offset=0),
Register(name="ptr", size=8, vex_offset=8),
Register(name="inout", size=1, vex_offset=16),
Register(name="ip_at_syscall", size=8, vex_offset=24),
You may optionally provide the ``endness`` and ``bits`` parameters (strings) to help this function out.
"""
if bits == 64 or (isinstance(bits, str) and '64' in bits):
bits = 64
elif isinstance(bits,str) and '32' in bits:
bits = 32
elif not bits and '64' in ident:
bits = 64
elif not bits and '32' in ident:
bits = 32
endness = endness.lower()
if 'lit' in endness:
endness = Endness.LE
elif 'big' in endness:
endness = Endness.BE
elif 'lsb' in endness:
endness = Endness.LE
elif 'msb' in endness:
endness = Endness.BE
elif 'le' in endness:
endness = Endness.LE
elif 'be' in endness:
endness = Endness.BE
elif 'l' in endness:
endness = 'unsure'
elif 'b' in endness:
endness = 'unsure'
else:
endness = 'unsure'
ident = ident.lower()
cls = None
def __init__(self, endness=Endness.BE):
super(ArchMIPS32, self).__init__(endness)
if endness == Endness.BE:
self.function_prologs = {
br"\x27\xbd\xff[\x00-\xff]" # addiu $sp, xxx
br"\x3c\x1c[\x00-\xff][\x00-\xff]\x9c\x27[\x00-\xff][\x00-\xff]" # lui $gp, xxx; addiu $gp, $gp, xxxx
}
self.function_epilogs = {
br"\x8f\xbf[\x00-\xff]{2}([\x00-\xff]{4}){0,4}\x03\xe0\x00\x08" # lw ra, off(sp); ... ; jr ra
}
self.qemu_name = 'mips'
self.triplet = 'mips-linux-gnu'
self.linux_name = 'mips'
if bits == 64 or (isinstance(bits, str) and '64' in bits):
bits = 64
elif isinstance(bits,str) and '32' in bits:
bits = 32
elif not bits and '64' in ident:
bits = 64
elif not bits and '32' in ident:
bits = 32
endness = endness.lower()
if 'lit' in endness:
endness = Endness.LE
elif 'big' in endness:
endness = Endness.BE
elif 'lsb' in endness:
endness = Endness.LE
elif 'msb' in endness:
endness = Endness.BE
elif 'le' in endness:
endness = Endness.LE
elif 'be' in endness:
endness = Endness.BE
elif 'l' in endness:
endness = 'unsure'
elif 'b' in endness:
endness = 'unsure'
else:
endness = 'unsure'
ident = ident.lower()
cls = None
aendness = ""
for arxs, abits, aendness, acls in arch_id_map:
def __init__(self, endness, instruction_endness=None):
if endness not in (Endness.LE, Endness.BE, Endness.ME):
raise ArchError('Must pass a valid endness: Endness.LE, Endness.BE, or Endness.ME')
if instruction_endness is not None:
self.instruction_endness = instruction_endness
if self.vex_support:
if _pyvex:
self.vex_archinfo = _pyvex.default_vex_archinfo()
else:
self._vex_archinfo = None
if endness == Endness.BE:
if self.vex_archinfo:
self.vex_archinfo['endness'] = _pyvex.vex_endness_from_string('VexEndnessBE')
self.memory_endness = Endness.BE
self.register_endness = Endness.BE
def __init__(self, endness=Endness.LE):
super(ArchPPC32, self).__init__(endness)
if endness == Endness.BE:
self.function_prologs = {
# stwu r1, -off(r1); mflr r0
br"\x94\x21[\x00-\xff]{2}\x7c\x08\x02\xa6"
}
self.function_epilogs = {
# mtlr reg; ... ; blr
br"[\x00-\xff]{2}\x03\xa6([\x00-\xff]{4}){0,6}\x4e\x80\x00\x20"
}
self.argument_register_positions = {
self.registers['r3'][0]: 0,
self.registers['r4'][0]: 1,
self.registers['r5'][0]: 2,
self.registers['r6'][0]: 3,
def __init__(self, endness=Endness.LE):
super(ArchPPC64, self).__init__(endness)
if endness == Endness.BE:
self.function_prologs = {
br"\x94\x21[\x00-\xff]{2}\x7c\x08\x02\xa6", # stwu r1, -off(r1); mflr r0
br"(?!\x94\x21[\x00-\xff]{2})\x7c\x08\x02\xa6", # mflr r0
br"\xf8\x61[\x00-\xff]{2}", # std r3, -off(r1)
}
self.function_epilogs = {
br"[\x00-\xff]{2}\x03\xa6([\x00-\xff]{4}){0,6}\x4e\x80\x00\x20" # mtlr reg; ... ; blr
}
self.triplet = 'powerpc-linux-gnu'
self.argument_register_positions = {
self.registers['r3'][0]: 0,
self.registers['r4'][0]: 1,
self.registers['r5'][0]: 2,
self.registers['r6'][0]: 3,
self.registers['r7'][0]: 4,
self.registers['r8'][0]: 5,
return bool(addr & 1)
bits = 32
vex_arch = "VexArchARM"
name = "ARMEL"
qemu_name = 'arm'
ida_processor = 'armb'
linux_name = 'arm'
triplet = 'arm-linux-gnueabihf'
max_inst_bytes = 4
ret_offset = 8
vex_conditional_helpers = True
syscall_num_offset = 36
call_pushes_ret = False
stack_change = -4
memory_endness = Endness.LE
register_endness = Endness.LE
sizeof = {'short': 16, 'int': 32, 'long': 32, 'long long': 64}
if _capstone:
cs_arch = _capstone.CS_ARCH_ARM
cs_mode = _capstone.CS_MODE_LITTLE_ENDIAN
_cs_thumb = None
if _keystone:
ks_arch = _keystone.KS_ARCH_ARM
ks_mode = _keystone.KS_MODE_ARM + _keystone.KS_MODE_LITTLE_ENDIAN
_ks_thumb = None
uc_arch = _unicorn.UC_ARCH_ARM if _unicorn else None
uc_mode = _unicorn.UC_MODE_LITTLE_ENDIAN if _unicorn else None
uc_const = _unicorn.arm_const if _unicorn else None
uc_prefix = "UC_ARM_" if _unicorn else None
#self.ret_instruction = b"\x0E\xF0\xA0\xE1" # this is mov pc, lr
ret_instruction = b"\x1E\xFF\x2F\xE1" # this is bx lr