import
angr
import
claripy
import
sys
p
=
angr.Project(
"/home/pwn/Desktop/angr/angr_ctf/dist/03_angr_symbolic_registers"
)
start_address
=
0x08048980
initial_state
=
p.factory.blank_state(addr
=
start_address)
pass0
=
claripy.BVS(
'pass0'
,
32
)
pass1
=
claripy.BVS(
'pass1'
,
32
)
pass2
=
claripy.BVS(
'pass2'
,
32
)
initial_state.regs.eax
=
pass0
initial_state.regs.ebx
=
pass1
initial_state.regs.edx
=
pass2
sm
=
p.factory.simulation_manager(initial_state)
def
good(state):
return
b
'Good Job'
in
state.posix.dumps(
1
)
def
bad(state):
return
b
'Try again'
in
state.posix.dumps(
1
)
sm.explore(find
=
good,avoid
=
bad)
if
sm.found:
found_state
=
sm.found[
0
]
password0
=
found_state.solver.
eval
(pass0)
password1
=
found_state.solver.
eval
(pass1)
password2
=
found_state.solver.
eval
(pass2)
print
(
hex
(password0),
hex
(password1),
hex
(password2))