diff --git a/.gitignore b/.gitignore index 0da3749..0d7bd4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ *~ /dictionaries/reductor.py +/brute_venv/ +/html/ +/src/__pycache__/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7fbfccb --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +VENV=brute_venv +INVENV = $(shell pip3 -V | grep $(VENV)) +current_dir = $(shell pwd) + +prereqs: venvcheck FORCE + pip install -r requirements.txt + +venv: FORCE + python3 -m venv $(VENV) + +docs: + pdoc --html ./src/brutus.py --force + +venvcheck: +ifeq ($(INVENV),) + $(error You should only run this from within the venv. Use '. ./$(VENV)/bin/activate') +else + @echo "venv check passed\n" +endif + +test/testbin: test/testbin.c + $(CC) -o test/testbin test/testbin.c + +test: FORCE venvcheck test/testbin + py.test -v tests/ + + + + +FORCE: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e67a70d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +pdoc3 +pytest +pexpect diff --git a/src/brutus.py b/src/brutus.py index e446591..f24999d 100644 --- a/src/brutus.py +++ b/src/brutus.py @@ -21,7 +21,7 @@ class Binary: """ Reads data from the standard output of the binary. Returns: None: if there is no data - A string containing the next line of output if available.""" + A String: containing the next line of output if available.""" if self.proc.eof(): return None return self.proc.readline() diff --git a/test/test_brutus.py b/test/test_brutus.py new file mode 100644 index 0000000..6dfcd9e --- /dev/null +++ b/test/test_brutus.py @@ -0,0 +1,8 @@ +import pytest +import sys +sys.path.append("./src/") + +import brutus + +# You can import your source files here, too +# So you can test the functions you create diff --git a/test/testbin b/test/testbin new file mode 100755 index 0000000..3a73082 Binary files /dev/null and b/test/testbin differ diff --git a/test/testbin.c b/test/testbin.c new file mode 100644 index 0000000..f5b931c --- /dev/null +++ b/test/testbin.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include + +int main(void) +{ + char* actualPw = "swordfish"; //Of course + char guess[20]; + printf ("Enter the password: "); + fgets ( guess, 80, stdin ); + + //Strip the \n, replace with 0 + guess[strcspn(guess, "\n")] = 0; + printf("You entered [%s]\n",guess); + if(strcmp(guess,actualPw)==0){ + printf("Password Correct\n"); + }else{ + printf("Password Incorrect\n"); + } +}