-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
login: login.o | ||
|
||
login.o: login.c | ||
|
||
.PHONY: clean | ||
clean: | ||
rm login login.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Lab7 | ||
|
||
## Introduction | ||
|
||
In this lab, you will write a python script with Angr to find the password in executalbe file named 'login'. | ||
|
||
## Preparation (Important!!!) | ||
|
||
1. Sync fork your branch (e.g., `SQLab:311XXXXXX`) | ||
2. `git checkout -b lab7` (**NOT** your student ID !!!) | ||
|
||
## Requirement | ||
|
||
1. (100%) Detect the condition that login will print 'Login successful' if login success and print 'Login failed' if login fail, find the input of successful condition by Angr. | ||
|
||
Please note that you must not alter files other than `sol.py` or just print the input. You will get 0 points if | ||
|
||
1. you modify other files to achieve requirements. | ||
2. you can't pass all CI on your PR. | ||
|
||
## Submission | ||
|
||
You need to open a pull request to your branch (e.g. 311XXXXXX, your student number) and contain the code that satisfies the abovementioned requirements. | ||
|
||
Moreover, please submit the URL of your PR to E3. Your submission will only be accepted when you present at both places. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
int encrypt(int a1, int a2) { | ||
if ( a1 <= 0x40 || a1 > 90 ) { | ||
puts("Login failed"); | ||
exit(1); | ||
} | ||
return (0x1F * a2 + a1 - 65) % 26 + 65; | ||
} | ||
|
||
int main(void) { | ||
char secret[0x20] = "VXRRJEURXDASBFHM"; | ||
char pwd[0x20] = {0}; | ||
|
||
printf("Enter the password: "); | ||
scanf("%16s", pwd); | ||
for ( int j = 0; j < 0x10; ++j ) | ||
pwd[j] = encrypt(pwd[j], j + 8); | ||
if ( !strcmp(secret, pwd) ) | ||
puts("Login successful"); | ||
else | ||
puts("Login failed"); | ||
return 0; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# Check for unwanted files | ||
for file in *; do | ||
if [[ $file != "login.c" && $file != "sol.py" && $file != "Makefile" && $file != "README.md" && $file != "validate.sh" ]]; then | ||
echo "[!] Unwanted file detected: $file." | ||
exit 1 | ||
fi | ||
done | ||
|
||
test_path="${BASH_SOURCE[0]}" | ||
solution_path="$(realpath .)" | ||
tmp_dir=$(mktemp -d -t lab7-XXXXXXXXXX) | ||
answer="" | ||
|
||
cd $tmp_dir | ||
|
||
pip install angr | ||
rm -rf * | ||
cp $solution_path/Makefile . | ||
cp $solution_path/*.c . | ||
cp $solution_path/sol.py . | ||
|
||
make | ||
result=$(python3 sol.py) | ||
if [[ $result != "b'HETOBRCUVWOBFEBB'" ]]; then | ||
echo "[!] Expected: " | ||
echo "b'HETOBRCUVWOBFEBB'" | ||
echo "" | ||
echo "[!] Actual: " | ||
echo $result | ||
echo "" | ||
exit 1 | ||
else | ||
echo "[V] Pass" | ||
fi | ||
|
||
rm -rf $tmp_dir | ||
|
||
exit 0 | ||
|
||
# vim: set fenc=utf8 ff=unix et sw=2 ts=2 sts=2: |