Skip to content

Commit 078bea6

Browse files
committed
feat: Lab6 for symbolic execution init commit
1 parent c6b4f45 commit 078bea6

File tree

6 files changed

+70
-0
lines changed

6 files changed

+70
-0
lines changed

Lab6/1.txt

Whitespace-only changes.

Lab6/2.txt

Whitespace-only changes.

Lab6/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.PHONY: all run run1 run2 clean
2+
3+
all:
4+
gcc -o chal -no-pie chal.c
5+
6+
run: run1 run2
7+
8+
run1: all
9+
@cat 1.txt | ./chal
10+
11+
run2: all
12+
@cat 2.txt | ./chal
13+
14+
clean:
15+
rm -f chal

Lab6/ans

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enter the secret key: Correct! The flag is: CTF{symbolic_execution_for_the_win}

Lab6/solve.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python3
2+
3+
import angr,sys
4+
5+
def main():
6+
secret_key = b""
7+
sys.stdout.buffer.write(secret_key)
8+
9+
10+
if __name__ == '__main__':
11+
main()

Lab6/validate.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# Check for unwanted files
4+
for file in *; do
5+
if [[ $file != "solve.py" && $file != "chal.c" && $file != "Makefile" && $file != "README.md" && $file != "validate.sh" && $file != "ans" ]]; then
6+
echo "[!] Unwanted file detected: $file."
7+
exit 1
8+
fi
9+
done
10+
11+
test_path="${BASH_SOURCE[0]}"
12+
solution_path="$(realpath .)"
13+
tmp_dir=$(mktemp -d -t lab6-XXXXXXXXXX)
14+
answer=""
15+
16+
cd $tmp_dir
17+
18+
rm -rf *
19+
cp $solution_path/Makefile .
20+
cp $solution_path/ans .
21+
cp $solution_path/*.c .
22+
cp $solution_path/*.py .
23+
24+
make
25+
make run > out
26+
result=$(diff --strip-trailing-cr ans out)
27+
if [[ -n $result ]]; then
28+
echo "[!] Expected: "
29+
cat ans
30+
echo ""
31+
echo "[!] Actual: "
32+
cat out
33+
echo ""
34+
exit 1
35+
else
36+
echo "[V] Pass"
37+
fi
38+
39+
rm -rf $tmp_dir
40+
41+
exit 0
42+
43+
# vim: set fenc=utf8 ff=unix et sw=2 ts=2 sts=2:

0 commit comments

Comments
 (0)