about summary refs log tree commit diff stats
path: root/gen_trace.py
diff options
context:
space:
mode:
authorTheofilos Augoustis <theofilos.augoustis@gmail.com>2023-12-08 16:17:35 +0100
committerTheofilos Augoustis <theofilos.augoustis@gmail.com>2023-12-08 16:17:35 +0100
commit4a5584d8f69d8ff511285387971d8cbf803f16b7 (patch)
tree11c9e104fadc9b47f3f423f4be3bf0be34edf4f8 /gen_trace.py
parent0cf4f736fd5d7cd99f00d6c5896af9a608d2df8b (diff)
downloadfocaccia-4a5584d8f69d8ff511285387971d8cbf803f16b7.tar.gz
focaccia-4a5584d8f69d8ff511285387971d8cbf803f16b7.zip
Adapt symbolic compare to new transform interface
Also implement a `MiasmSymbolicTransform.concat` function that
concatenates two transformations. Some minor adaptions to the eval_expr
code was necessary to remove some assumptions that don't work if the
resolver state returns symbols instead of concrete values.

Remove obsolete utilities that were used for angr.

Co-authored-by: Theofilos Augoustis <theofilos.augoustis@gmail.com>
Co-authored-by: Nicola Crivellin <nicola.crivellin98@gmail.com>
Diffstat (limited to 'gen_trace.py')
-rw-r--r--gen_trace.py63
1 files changed, 0 insertions, 63 deletions
diff --git a/gen_trace.py b/gen_trace.py
deleted file mode 100644
index ec5cb86..0000000
--- a/gen_trace.py
+++ /dev/null
@@ -1,63 +0,0 @@
-import argparse
-import lldb
-import lldb_target
-
-def record_trace(binary: str,
-                 args: list[str] = [],
-                 func_name: str | None = 'main') -> list[int]:
-    """
-    :param binary:    The binary file to execute.
-    :param args:      Arguments to the program. Should *not* include the
-                      executable's location as the usual first argument.
-    :param func_name: Only record trace of a specific function.
-    """
-    # Set up LLDB target
-    target = lldb_target.LLDBConcreteTarget(binary, args)
-
-    # Skip to first instruction in `main`
-    if func_name is not None:
-        result = lldb.SBCommandReturnObject()
-        break_at_func = f'b -b {func_name} -s {target.module.GetFileSpec().GetFilename()}'
-        target.interpreter.HandleCommand(break_at_func, result)
-        target.run()
-
-    # Run until main function is exited
-    trace = []
-    while not target.is_exited():
-        thread = target.process.GetThreadAtIndex(0)
-
-        # Break if the traced function is exited
-        if func_name is not None:
-            func_names = [thread.GetFrameAtIndex(i).GetFunctionName() \
-                          for i in range(0, thread.GetNumFrames())]
-            if func_name not in func_names:
-                break
-        trace.append(target.read_register('pc'))
-        thread.StepInstruction(False)
-
-    return trace
-
-def parse_args():
-    prog = argparse.ArgumentParser()
-    prog.add_argument('binary',
-                      help='The executable to trace.')
-    prog.add_argument('-o', '--output',
-                      default='breakpoints',
-                      type=str,
-                      help='File to which the recorded trace is written.')
-    prog.add_argument('--args',
-                      default=[],
-                      nargs='+',
-                      help='Arguments to the executable.')
-    return prog.parse_args()
-
-def main():
-    args = parse_args()
-    trace = record_trace(args.binary, args.args)
-    with open(args.output, 'w') as file:
-        for addr in trace:
-            print(hex(addr), file=file)
-    print(f'Generated a trace of {len(trace)} instructions.')
-
-if __name__ == '__main__':
-    main()