diff options
| author | Camille Mougey <camille.mougey@cea.fr> | 2014-11-03 19:12:35 +0100 |
|---|---|---|
| committer | Camille Mougey <camille.mougey@cea.fr> | 2014-11-03 19:34:32 +0100 |
| commit | acb866d6d401e5cfbdb01c4a888fe8017c472281 (patch) | |
| tree | 8ea852ff0dd90a9a779eca035ce133dbfd1f1759 /example/test_dis.py | |
| parent | d224bd8b0e75afb551f8e94d8e4036c9f5132e79 (diff) | |
| download | miasm-acb866d6d401e5cfbdb01c4a888fe8017c472281.tar.gz miasm-acb866d6d401e5cfbdb01c4a888fe8017c472281.zip | |
TestDis: update example to use Container
Diffstat (limited to 'example/test_dis.py')
| -rw-r--r-- | example/test_dis.py | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/example/test_dis.py b/example/test_dis.py index dc3f7274..ba0d7921 100644 --- a/example/test_dis.py +++ b/example/test_dis.py @@ -2,8 +2,7 @@ import sys import os import time -from miasm2.core.bin_stream import bin_stream_elf, bin_stream_pe, bin_stream_str -from elfesteem import * +from miasm2.analysis.binary import Container from miasm2.core.asmbloc import * from miasm2.expression.simplifications import expr_simp from optparse import OptionParser @@ -95,36 +94,13 @@ if options.bw != None: if options.funcswd != None: options.funcswd = int(options.funcswd) -log.info('load binary') -b = open(fname).read() - -default_addr = 0 -bs = None -if b.startswith('MZ'): - try: - e = pe_init.PE(b) - if e.isPE() and e.NTsig.signature_value == 0x4550: - bs = bin_stream_pe(e.virt) - default_addr = e.rva2virt(e.Opthdr.AddressOfEntryPoint) - except: - log.error('Cannot read PE!') -elif b.startswith('\x7fELF'): - try: - e = elf_init.ELF(b) - bs = bin_stream_elf(e.virt) - default_addr = e.Ehdr.entry - except: - log.error('Cannot read ELF!') - - -if bs is None or options.shiftoffset is not None: - - if options.shiftoffset is None: - options.shiftoffset = "0" - shift = int(options.shiftoffset, 16) - log.warning('fallback to string input (offset=%s)' % hex(shift)) - bs = bin_stream_str(b, shift=shift) +log.info('Load binary') +with open(fname) as fdesc: + cont = Container.from_stream(fdesc, addr=options.shiftoffset) +default_addr = cont.entry_point +bs = cont.bin_stream +e = cont.executable log.info('ok') mdis = dis_engine(bs) |