Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@unittest.skipUnless(archr._angr_available, "angr required")
def test_stack(self):
import angr
t = archr.targets.DockerImageTarget('archr-test:stackprinter64').build().start()
reference_str = t.run_command(aslr=False).stdout.read()
dsb = archr.arsenal.DataScoutBow(t)
apb = archr.arsenal.angrProjectBow(t, dsb)
asb = archr.arsenal.angrStateBow(t, apb)
project = apb.fire(use_sim_procedures=False)
state = asb.fire(add_options={angr.sim_options.STRICT_PAGE_ACCESS}) # for now
simgr = project.factory.simulation_manager(state)
simgr.run()
assert len(simgr.errored) == 0
assert len(simgr.deadended) == 1
assert len(sum(simgr.stashes.values(), [])) == 1
@unittest.skipUnless(archr._angr_available, "angr required")
def test_angr_catflag(self):
with archr.targets.DockerImageTarget('archr-test:cat-flag').build().start() as t:
dsb = archr.arsenal.DataScoutBow(t)
apb = archr.arsenal.angrProjectBow(t, dsb)
asb = archr.arsenal.angrStateBow(t, apb)
project = apb.fire()
state = asb.fire()
simgr = project.factory.simulation_manager(state)
simgr.run()
assert len(simgr.errored) == 0
assert len(simgr.deadended) == 1
assert simgr.one_deadended.posix.dumps(1) == b"archr-flag\n"
@unittest.skipUnless(archr._angr_available, "angr required")
def test_angr_tracing(self):
target = archr.targets.LocalTarget(os.path.join(test_location, '../../binaries/tests/x86_64/true'))
dsb = archr.arsenal.DataScoutBow(target)
apb = archr.arsenal.angrProjectBow(target, dsb)
asb = archr.arsenal.angrStateBow(target, apb)
qtb = archr.arsenal.QEMUTracerBow(target)
trace = qtb.fire()
p = apb.fire()
s = asb.fire()
tech = trace.tracer_technique()
simgr = p.factory.simulation_manager(s)
simgr.use_technique(tech)
simgr.run()
assert len(simgr.traced) == 1
import contextlib
import subprocess
import tempfile
import logging
import signal
import shutil
import glob
import re
import os
l = logging.getLogger("archr.arsenal.qemu_tracer")
from . import ContextBow
from .. import _angr_available
if _angr_available:
import angr
class QemuTraceResult:
# results
returncode = None
signal = None
crashed = None
timed_out = None
# introspection
trace = None
crash_address = None
base_address = None
magic_contents = None
core_path = None