Skip to content

Commit 292e3d6

Browse files
committed
can pass validate.sh
1 parent 5abdc32 commit 292e3d6

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lab8/solve.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,20 @@
66
def main():
77
proj = angr.Project("./chal", auto_load_libs=False)
88

9-
chars = [claripy.BVS(f'c{i}', 8) for i in range(8)]
9+
# 8 symbolic bytes + null terminator
10+
chars = [claripy.BVS(f'byte_{i}', 8) for i in range(8)]
1011
null = claripy.BVV(0, 8)
1112
input_bytes = claripy.Concat(*chars + [null])
1213

13-
input_stream = angr.SimFileStream(name='stdin', content=input_bytes, has_end=False)
14-
15-
state = proj.factory.entry_state(
16-
stdin=input_stream,
17-
add_options={
18-
angr.options.ZERO_FILL_UNCONSTRAINED_MEMORY,
19-
angr.options.ZERO_FILL_UNCONSTRAINED_REGISTERS
20-
}
21-
)
14+
# Use simpler entry_state() to avoid memory initialization complexity
15+
state = proj.factory.entry_state(stdin=input_bytes)
2216

17+
# Constrain input to printable ASCII
2318
for c in chars:
2419
state.solver.add(c >= 0x20, c <= 0x7e)
2520

2621
simgr = proj.factory.simgr(state)
22+
2723
simgr.explore(
2824
find=lambda s: b"CTF{" in s.posix.dumps(1),
2925
avoid=lambda s: b"Wrong key" in s.posix.dumps(1)

0 commit comments

Comments
 (0)