def init_jitter(loc_db): global data, run_addr # Create jitter myjit = Machine("x86_32").jitter(loc_db, sys.argv[1]) myjit.vm.add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, data) # Init jitter myjit.init_stack() myjit.set_trace_log() myjit.push_uint32_t(0x1337beef) myjit.add_breakpoint(0x1337beef, code_sentinelle) return myjit
def init_jitter(): global data, run_addr # Create jitter myjit = Machine("x86_32").jitter(sys.argv[1]) myjit.vm.add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, data) # Init jitter myjit.init_stack() myjit.set_trace_log() myjit.push_uint32_t(0x1337beef) myjit.add_breakpoint(0x1337beef, code_sentinelle) return myjit
from pdb import pm parser = ArgumentParser(description="x86 32 basic Jitter") parser.add_argument("filename", help="x86 32 shellcode filename") parser.add_argument("-j", "--jitter", help="Jitter engine (default is 'gcc')", default="gcc") args = parser.parse_args() def code_sentinelle(jitter): jitter.run = False jitter.pc = 0 return True myjit = Machine("x86_32").jitter(args.jitter) myjit.init_stack() data = open(args.filename, 'rb').read() run_addr = 0x40000000 myjit.vm.add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, data) myjit.set_trace_log() myjit.push_uint32_t(0x1337beef) myjit.add_breakpoint(0x1337beef, code_sentinelle) myjit.init_run(run_addr) myjit.continue_run()
if __name__ == "__main__": parser = ArgumentParser(description="x86 64 basic Jitter") parser.add_argument("filename", help="x86 64 shellcode filename") parser.add_argument("-j", "--jitter", help="Jitter engine (default is 'gcc')", default="gcc") parser.add_argument("--verbose", "-v", action="store_true", help="Verbose mode") args = parser.parse_args() loc_db = LocationDB() myjit = Machine("x86_64").jitter(loc_db, args.jitter) myjit.init_stack() with open(args.filename, 'rb') as f: data = f.read() run_addr = 0x40000000 myjit.vm.add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, data) if args.verbose: myjit.set_trace_log() myjit.push_uint64_t(0x1337beef) myjit.add_breakpoint(0x1337beef, code_sentinelle) # Add routine catching syscalls myjit.add_exception_handler(EXCEPT_SYSCALL, log_syscalls) myjit.run(run_addr)