blob: b26161bc88d040cdd76d8d15e01a81c1f826c2d9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import sys
import os
from optparse import OptionParser
from miasm2.arch.x86.arch import mn_x86
from miasm2.jitter.jitload import jitter_x86_32
from miasm2.jitter.jitload import bin_stream_vm
from miasm2.jitter.csts import *
from pdb import pm
filename = os.environ.get('PYTHONSTARTUP')
if filename and os.path.isfile(filename):
execfile(filename)
parser = OptionParser(usage="usage: %prog rawfiley arch address [options]")
(options, args) = parser.parse_args(sys.argv[1:])
if len(args) < 1:
parser.print_help()
sys.exit(0)
def code_sentinelle(jitter):
jitter.run = False
jitter.pc = 0
return True
myjit = jitter_x86_32()
myjit.init_stack()
fname = args[0]
data = open(fname).read()
run_addr = 0x40000000
myjit.vm.vm_add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, data)
myjit.jit.log_regs = True
myjit.jit.log_mn = True
myjit.vm_push_uint32_t(0x1337beef)
myjit.add_breakpoint(0x1337beef, code_sentinelle)
myjit.init_run(run_addr)
myjit.continue_run()
|