示例#1
0
class SimBPF(SimUserland):
    # Syscalls are for lamers
    SYSCALL_TABLE = {}

    def __init__(self, *args, **kwargs):
        super(SimBPF, self).__init__(*args, name="BPF", **kwargs)

    def state_blank(self, data_region_size=0x8000, **kwargs):  # pylint:disable=arguments-differ
        state = super(SimBPF, self).state_blank(**kwargs)  # pylint:disable=invalid-name
        return state


class SimBPFSyscall(SimCC):
    ARG_REGS = []
    # RETURN_VAL = ""
    ARCH = ArchBPF

    @staticmethod
    def _match(arch, args, sp_delta):  # pylint: disable=unused-argument
        # doesn't appear anywhere but syscalls
        return False

    @staticmethod
    def syscall_num(state):
        return state.regs.inout


register_simos('BPF', SimBPF)
register_syscall_cc('BPF', 'default', SimBPFSyscall)
register_default_cc('BPF', SimCCBPF)
示例#2
0
from .arch_riscv import ArchRISCV


class SimCCRISCV(SimCC):
    ARG_REGS = ['a0', 'a1', 'a2', 'a3', 'a4', 'a5']
    FP_ARG_REGS = []  # expand in case the floating point extension is added
    STACK_ALIGNMENT = 16
    RETURN_ADDR = SimRegArg('ra', 4)
    RETURN_VAL = SimRegArg('a0', 4)
    ARCH = ArchRISCV


class SimRISCVSyscall(SimCC):
    ARG_REGS = ['a0', 'a1', 'a2', 'a3', 'a4', 'a5']
    RETURN_VAL = SimRegArg('a0', 4)
    RETURN_ADDR = SimStackArg(4, 4)
    ARCH = ArchRISCV

    @staticmethod
    def _match(arch, args, sp_delta):  # pylint: disable=unused-argument
        # doesn't appear anywhere but syscalls
        return False

    @staticmethod
    def syscall_num(state):
        return state.regs.a7


register_syscall_cc('RISCV', 'Linux', SimRISCVSyscall)
register_default_cc('RISCV', SimCCRISCV)
示例#3
0

class SimBFSyscall(SimCC):
    """
    This defines our syscall format.
    Obviously this is pretty dumb, for BrainFuck
    This is really just here to make the two simprocedures work.
    """

    # No need to pull the regs out, we always just want ptr straight up.
    # THis is usually a list of string register names.
    ARG_REGS = [ 'ptr' ]
    # We never return anything to registers, but if we did, we'd use a RegArg object here.
    #RETURN_VAL = ""
    ARCH = ArchBF
    RETURN_ADDR = SimRegArg('ip_at_syscall', 8)

    @staticmethod
    def _match(arch, args, sp_delta):   # pylint: disable=unused-argument
        # doesn't appear anywhere but syscalls
        return False

    @staticmethod
    def syscall_num(state):
        return state.regs.inout


register_simos('bf', SimBF)
register_syscall_cc('BF','default',SimBFSyscall)
register_default_cc('BF',SimCCUnknown)
示例#4
0
    def state_blank(self, data_region_size=0x8000, **kwargs):
        # pylint:disable=arguments-differ
        state = super(SimMSP430, self).state_blank(**kwargs)  # pylint:disable=invalid-name
        # PTR starts halfway through memory
        return state

    def state_entry(self, **kwargs):
        state = super(SimMSP430, self).state_entry(**kwargs)
        return state


class SimMSP430Syscall(SimCC):
    ARG_REGS = []
    #RETURN_VAL = ""
    ARCH = ArchMSP430

    @staticmethod
    def _match(arch, args, sp_delta):  # pylint: disable=unused-argument
        # doesn't appear anywhere but syscalls
        return False

    @staticmethod
    def syscall_num(state):
        return state.regs.inout


register_simos('Standalone App', SimMSP430)
register_syscall_cc('MSP430', 'default', SimMSP430Syscall)
register_default_cc('MSP430', SimCCMSP430)
示例#5
0
        print(state)
        print(state.mem)
        # PTR starts halfway through memory
        return state

    def state_entry(self, **kwargs):
        state = super(SimGameboy, self).state_entry(**kwargs)
        print(state)
        print(state.mem)
        return state


class SimGameboySyscall(SimCC):
    ARG_REGS = []
    #RETURN_VAL = ""
    ARCH = ArchGameboy

    @staticmethod
    def _match(arch, args, sp_delta):  # pylint: disable=unused-argument
        # doesn't appear anywhere but syscalls
        return False

    @staticmethod
    def syscall_num(state):
        return state.regs.inout


register_simos('Standalone App', SimGameboy)
#register_syscall_cc('Gameboy', 'default', SimGameboySyscall)
register_default_cc('Gameboy', SimCCGameboy)