Skip to content

[LAB8] 3135553034 #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lab2/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ test('Application: notifySelected()', () => {
mockWrite.mock.restore();
mockSend.mock.restore();
});
=======
const { Application, MailSystem } = require('./main');

// TODO: write your tests here
// Remember to use Stub, Mock, and Spy when necessary

const { Application, MailSystem } = require('./main');
33 changes: 28 additions & 5 deletions lab8/solve.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
#!/usr/bin/env python3

import angr,sys
import angr
import claripy
import sys

def main():
secret_key = b""
sys.stdout.buffer.write(secret_key)
def solve_binary(binary_path, input_len=8, success_msg=b"Correct!"):
proj = angr.Project(binary_path, auto_load_libs=False)

user_input = claripy.BVS("user_input", input_len * 8)
state = proj.factory.full_init_state(stdin=user_input)

simgr = proj.factory.simulation_manager(state)

def is_successful(s):
output = s.posix.dumps(sys.stdout.fileno())
return success_msg in output

simgr.explore(find=is_successful)

if simgr.found:
solution_state = simgr.found[0]
result = solution_state.solver.eval(user_input, cast_to=bytes)
return result[:input_len]
else:
return b"[!] Not found\n"

def main():
binary = "./chal"
flag = solve_binary(binary)
sys.stdout.buffer.write(flag)

if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading