diff options
| author | Axel Souchet <0vercl0k@tuxfamily.org> | 2018-09-09 06:11:00 -0700 |
|---|---|---|
| committer | serpilliere <serpilliere@users.noreply.github.com> | 2018-09-09 15:11:00 +0200 |
| commit | 8e6b39d80e9f8db8389bd2a8106d0f64b91c19e9 (patch) | |
| tree | dbf342089690704e89c10532b83d1d81709a49f4 /example | |
| parent | e61116884ac7879db08313542c6c28a8b00297c5 (diff) | |
| download | miasm-8e6b39d80e9f8db8389bd2a8106d0f64b91c19e9.tar.gz miasm-8e6b39d80e9f8db8389bd2a8106d0f64b91c19e9.zip | |
Adds Windows support and AppVeyor CI (#835)
* Get miasm to work on Windows, also add AppVeyor CI * Fix gcc jitter on Linux * Make the dse_crackme tests work on Windows * calling build and then install is less confusing than install twice * fix os.rename race condition on Windows * clean it up * Clean up after the unused cl.exe's artifacts * Use is_win instead of an additional check * Fix issue on Windows where 'w' and 'wb' modes are different * Address review feedback * setuptools is actually not required, so reverting
Diffstat (limited to 'example')
| -rw-r--r-- | example/symbol_exec/depgraph.py | 2 | ||||
| -rw-r--r-- | example/symbol_exec/dse_crackme.py | 32 |
2 files changed, 22 insertions, 12 deletions
diff --git a/example/symbol_exec/depgraph.py b/example/symbol_exec/depgraph.py index f306e6e3..260d62ab 100644 --- a/example/symbol_exec/depgraph.py +++ b/example/symbol_exec/depgraph.py @@ -103,7 +103,7 @@ for sol_nb, sol in enumerate(dg.get(current_block.loc_key, elements, assignblk_i if sat: for element in sol.constraints: try: - result = hex(sol.constraints[element].as_long()) + result = '0x%x' % sol.constraints[element].as_long() except AttributeError: result = str(sol.constraints[element]) constraints[element] = result diff --git a/example/symbol_exec/dse_crackme.py b/example/symbol_exec/dse_crackme.py index f6050486..22b6d9b1 100644 --- a/example/symbol_exec/dse_crackme.py +++ b/example/symbol_exec/dse_crackme.py @@ -8,6 +8,7 @@ This example should run on the compiled ELF x86 64bits version of #### This part is only related to the run of the sample, without DSE #### import os import subprocess +import platform from collections import namedtuple from pdb import pm from tempfile import NamedTemporaryFile @@ -16,11 +17,13 @@ from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE from miasm2.analysis.sandbox import Sandbox_Linux_x86_64 from miasm2.expression.expression import * +is_win = platform.system() == "Windows" + # File "management" my_FILE_ptr = 0x11223344 FInfo = namedtuple("FInfo", ["path", "fdesc"]) FILE_to_info = {} -TEMP_FILE = NamedTemporaryFile() +TEMP_FILE = NamedTemporaryFile(delete = False) def xxx_fopen(jitter): ''' @@ -260,7 +263,7 @@ while todo: # Prepare a solution to try, based on the clean state file_content = todo.pop() print "CUR: %r" % file_content - open(TEMP_FILE.name, "w").write(file_content) + open(TEMP_FILE.name, "wb").write(file_content) dse.restore_snapshot(snapshot, keep_known_solutions=True) FILE_to_info.clear() FILE_to_info_symb.clear() @@ -296,13 +299,20 @@ while todo: assert found == True print "FOUND !" +TEMP_FILE.close() + # Replay for real -print "Trying to launch the binary without Miasm" -crackme = subprocess.Popen([options.filename, TEMP_FILE.name], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) -stdout, stderr = crackme.communicate() -assert not stderr -stdout = stdout.strip() -print stdout -assert stdout == "OK" +if not is_win: + print "Trying to launch the binary without Miasm" + crackme = subprocess.Popen([options.filename, TEMP_FILE.name], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + stdout, stderr = crackme.communicate() + assert not stderr + os.unlink(TEMP_FILE.name) + stdout = stdout.strip() + print stdout + assert stdout == "OK" +else: + os.unlink(TEMP_FILE.name) + |