From 5ae4ea4f76cc4abe61974ebc8caa5aaad96b1a60 Mon Sep 17 00:00:00 2001 From: patty5531998 <44307724+patty5531998@users.noreply.github.com> Date: Thu, 9 May 2024 03:18:09 +0800 Subject: [PATCH] Update sol.py --- lab7/sol.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lab7/sol.py b/lab7/sol.py index e69de29b..59560bf9 100644 --- a/lab7/sol.py +++ b/lab7/sol.py @@ -0,0 +1,16 @@ +import angr, sys + +proj = angr.Project("./login") + +init_state = proj.factory.entry_state() +simulation = proj.factory.simgr(init_state) +simulation.explore(find=success_condition, avoid=fail_condition) + +def success_condition(state): + return b"Login successful" in state.posix.dumps(sys.stdout.fileno()) + +def fail_condition(state): + return b"Login failed" in state.posix.dumps(sys.stdout.fileno()) + +solution = simulation.found[0] +print(solution.posix.dumps(sys.stdin.fileno()))