Angr
Bruteforce but smart
Symbolic Execution
import angr, claripy
target = angr.Project('a.out', auto_load_libs=False)
input_len = 15 # Discovered with manual analysis at a glance
inp = [claripy.BVS('flag_%d' %i, 8) for i in range(input_len)]
# Define an array of 8 bit vectors ffor each char of the flag
flag = claripy.Concat(*inp + [claripy.BVV(b'\n')])
st = target.factory.full_init_state(args=["./a.out"], stdin=flag)
# Create a simulation with our flag symbols as stdin
for k in inp:
st.solver.add(k < 0x7f)
st.solver.add(k > 0x20)
# Add constraints that the characters should be printable
sm = target.factory.simulation_manager(st)
sm.run()
y = []
for x in sm.deadended:
# Out of the simulations that exit, record
# any that output SUCCESS
if b"SUCCESS" in x.posix.dumps(1):
y.append(x)
#grab the first ouptut
valid = y[0].posix.dumps(0)
print(valid)Last updated
Was this helpful?