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 1/2] 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())) From 620087796772d6264faf54d906fa0d368912c606 Mon Sep 17 00:00:00 2001 From: patty5531998 <44307724+patty5531998@users.noreply.github.com> Date: Thu, 9 May 2024 03:23:05 +0800 Subject: [PATCH 2/2] Update sol.py --- lab7/sol.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lab7/sol.py b/lab7/sol.py index 59560bf9..b5d2ec85 100644 --- a/lab7/sol.py +++ b/lab7/sol.py @@ -1,16 +1,17 @@ import angr, sys +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()) + 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()))