示例#1
0
文件: mips32.py 项目: tly000/miasm
def jit_mips32_binary(args):
    loc_db = LocationDB()
    filepath, entryp = args.binary, int(args.addr, 0)
    myjit = machine.jitter(loc_db, jit_type=args.jitter)
    myjit.init_stack()

    # Log level (if available with jitter engine)
    myjit.set_trace_log(trace_instr=args.trace,
                        trace_regs=args.trace,
                        trace_new_blocks=args.log_newbloc)

    myjit.vm.add_memory_page(0, PAGE_READ | PAGE_WRITE,
                             open(filepath, 'rb').read())
    myjit.add_breakpoint(0x1337BEEF, code_sentinelle)

    # for stack
    myjit.vm.add_memory_page(0xF000, PAGE_READ | PAGE_WRITE, b"\x00" * 0x1000)

    myjit.cpu.SP = 0xF800

    myjit.cpu.RA = 0x1337BEEF
    myjit.init_run(entryp)

    # Handle debugging
    if args.debugging is True:
        dbg = debugging.Debugguer(myjit)
        cmd = debugging.DebugCmd(dbg)
        cmd.cmdloop()

    else:
        print(myjit.continue_run())
    return myjit
示例#2
0
    def run(self, addr=None):
        """
        Launch emulation (gdbserver, debugging, basic JIT).
        @addr: (int) start address
        """
        if addr is None and self.options.address is not None:
            addr = int(self.options.address, 0)

        if any([self.options.debugging, self.options.gdbserver]):
            dbg = debugging.Debugguer(self.jitter)
            self.dbg = dbg
            dbg.init_run(addr)

            if self.options.gdbserver:
                port = self.options.gdbserver
                print("Listen on port %d" % port)
                gdb = self.machine.gdbserver(dbg, port)
                self.gdb = gdb
                gdb.run()
            else:
                cmd = debugging.DebugCmd(dbg)
                self.cmd = cmd
                cmd.cmdloop()

        else:
            self.jitter.init_run(addr)
            self.jitter.continue_run()
示例#3
0
文件: msp430.py 项目: zyc1314/miasm
def jit_msp430_binary(args):
    filepath, entryp = args.binary, int(args.addr, 0)
    myjit = machine.jitter(jit_type=args.jitter)

    # Log level (if available with jitter engine)
    myjit.set_trace_log(trace_instr=args.trace,
                        trace_regs=args.trace,
                        trace_new_blocks=args.log_newbloc)

    myjit.vm.add_memory_page(0, PAGE_READ | PAGE_WRITE,
                             open(filepath, "rb").read())
    myjit.add_breakpoint(0x1337, lambda _: exit(0))

    # for stack
    myjit.vm.add_memory_page(0xF000, PAGE_READ | PAGE_WRITE, b"\x00" * 0x1000)

    myjit.cpu.SP = 0xF800

    myjit.push_uint16_t(0x1337)
    myjit.init_run(entryp)

    # Handle debugging
    if args.debugging is True:
        dbg = debugging.Debugguer(myjit)
        cmd = debugging.DebugCmd(dbg)
        cmd.cmdloop()

    else:
        print(myjit.continue_run())