about summary refs log tree commit diff stats
path: root/example/asm/shellcode.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2015-03-27 16:12:19 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2015-04-01 23:47:37 +0200
commit89680eb28d75e8313ab59dbd8c31930596138bad (patch)
tree9cbdca606fcb582baf452224931fd46220133ca1 /example/asm/shellcode.py
parentd91f03ed42035c05e485aa082af5b1c03865edb7 (diff)
downloadfocaccia-miasm-89680eb28d75e8313ab59dbd8c31930596138bad.tar.gz
focaccia-miasm-89680eb28d75e8313ab59dbd8c31930596138bad.zip
Asmbloc: updt api
Diffstat (limited to 'example/asm/shellcode.py')
-rw-r--r--example/asm/shellcode.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/example/asm/shellcode.py b/example/asm/shellcode.py
index 3b22e801..3f3aa877 100644
--- a/example/asm/shellcode.py
+++ b/example/asm/shellcode.py
@@ -9,6 +9,7 @@ from miasm2.core.cpu import parse_ast
 from miasm2.core import parse_asm, asmbloc
 import miasm2.expression.expression as m2_expr
 from miasm2.analysis.machine import Machine
+from miasm2.core.interval import interval
 
 parser = ArgumentParser("Multi-arch (32 bits) assembler")
 parser.add_argument('architecture', help="architecture: " + \
@@ -34,6 +35,7 @@ except ValueError:
     size = 32
 reg_and_id = dict(machine.mn.regs.all_regs_ids_byname)
 base_expr = machine.base_expr
+dst_interval = None
 
 # Output format
 if args.PE:
@@ -50,7 +52,8 @@ if args.PE:
     addr_main = pe.rva2virt(s_text.addr)
     virt = pe.virt
     output = pe
-
+    dst_interval = interval([(pe.rva2virt(s_text.addr),
+                              pe.rva2virt(s_text.addr + s_text.size))])
 else:
     st = StrPatchwork()
 
@@ -79,7 +82,10 @@ graph = asmbloc.bloc2graph(blocs[0])
 open("graph.txt", "w").write(graph)
 
 # Apply patches
-patches = asmbloc.asm_resolve_final(machine.mn, blocs[0], symbol_pool)
+patches = asmbloc.asm_resolve_final(machine.mn,
+                                    blocs[0],
+                                    symbol_pool,
+                                    dst_interval)
 if args.encrypt:
     # Encrypt code
     ad_start = symbol_pool.getby_name_create(args.encrypt[0]).offset