diff options
| author | Camille Mougey <camille.mougey@cea.fr> | 2015-01-18 18:24:13 +0100 |
|---|---|---|
| committer | Camille Mougey <camille.mougey@cea.fr> | 2015-01-23 17:24:43 +0100 |
| commit | 488cb99d4d61a0b3b176f7e3c53431872fc234ef (patch) | |
| tree | 8d443acb6c92669cdeaa50a40af3496917a9448f /example/jitter/x86_32.py | |
| parent | 829f8b98a658532b40382640223c0c3ea12ab15c (diff) | |
| download | miasm-488cb99d4d61a0b3b176f7e3c53431872fc234ef.tar.gz miasm-488cb99d4d61a0b3b176f7e3c53431872fc234ef.zip | |
Example: Move jitter's examples to a `jitter` directory
Diffstat (limited to 'example/jitter/x86_32.py')
| -rw-r--r-- | example/jitter/x86_32.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/example/jitter/x86_32.py b/example/jitter/x86_32.py new file mode 100644 index 00000000..1b2aa012 --- /dev/null +++ b/example/jitter/x86_32.py @@ -0,0 +1,41 @@ +import os +from argparse import ArgumentParser +from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE +from miasm2.analysis.machine import Machine + +from pdb import pm + + +filename = os.environ.get('PYTHONSTARTUP') +if filename and os.path.isfile(filename): + execfile(filename) + +parser = ArgumentParser(description="x86 32 basic Jitter") +parser.add_argument("filename", help="x86 32 shellcode filename") +parser.add_argument("-j", "--jitter", + help="Jitter engine. Possible values are : tcc (default), llvm", + default="tcc") +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).read() +run_addr = 0x40000000 +myjit.vm.add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, data) + +myjit.jit.log_regs = True +myjit.jit.log_mn = True +myjit.push_uint32_t(0x1337beef) + +myjit.add_breakpoint(0x1337beef, code_sentinelle) + +myjit.init_run(run_addr) +myjit.continue_run() +del(myjit) |