From f53349168d443a0fa3049f2cd7dcc665c7400276 Mon Sep 17 00:00:00 2001 From: James Shuttleworth Date: Wed, 7 Oct 2020 18:45:18 +0100 Subject: [PATCH] Set up testing framework for brutus and future code --- .gitignore | 3 +++ Makefile | 30 ++++++++++++++++++++++++++++++ requirements.txt | 3 +++ src/brutus.py | 2 +- test/test_brutus.py | 8 ++++++++ test/testbin | Bin 0 -> 8576 bytes test/testbin.c | 22 ++++++++++++++++++++++ 7 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 requirements.txt create mode 100644 test/test_brutus.py create mode 100755 test/testbin create mode 100644 test/testbin.c 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 0000000000000000000000000000000000000000..3a73082d4dfe876a61814a8cd0f0c0f7f573b369 GIT binary patch literal 8576 zcmeHMU2I&%6`u9l$tF1KCFGAln@b>S(lm=5oM0d+UjHQ5t@G1hLs3XB>)o}zjrT{p zcZ-u&twjK7l_pp!t@2U{6&1B=ALvV!2h=(kC8g>^@&H6oq<{d~w5V=@G^Him@60`C zeed;dsj5Eofmz*q=6rL`nVB;`cjoMOd;51a1OiG@P<>eu7g_8eom|klmNOuoszWWo z`*Z4MwFrEp#+>p_hoIC+SJ|}C5aU5m((7n&06)E%<%CKLi8gUrEfTrTL4_)1Xn^#n zt&__%3u@?$&=l)I~LA4?ByZ@+ykxn(S!Esbv(@7TU& zdwaB)i*D8ZCi^72d+(sGiN;%8OKo0(hcGH%ml*B1cakEM^LG@Qu;C6i>PU|X3uly~>{b#+@? zqwUq)*6226^$qN?lBq&!Bwe&qg@HZYW4UZss9}xdUICGlUyWkgiUkv&DDg31tLtCV^ zNcBs)?84pabjF4AlGiG8E_|sN0ln(Nd8^ZF1T><9Tk|z{}eJ$G-Z|;%6xpvZm3)^kG~k2);jd6Y->PK zWkVz0E$cdwBYu>MW-nKeHhdfcPp+N4p!vTNPhFdx()@eGQ2xcmCwS)hb`-R zH1rafLGxtOSy1z?t7iEf`$lx}7_sQ$vO|^2!_k&?k7@gdrm0u+JWQ5J@Z`2fwV6%V zpl_bN7BtIq=GmEh&A>VH;x&5>493`CGa0OBZ(=8jsnYG{@tvzFH%RSiHc#wa3vOl^ zx;$gzb*||~@BwPh1U2k~X_!QRNc_<3FeE64(P~YaCmJ_wgos)0z1lW~j_x2=lzT6s z?e`#ihV*BO*D4kB#LDLvQ)hZF|9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SZK|B5Odx0A)<0f>2U+)GuzZv*)oGKRVtBHbLv`fRo(S({0CRujIN>Dh70$RzO zH8PePijP@IJ69-L@zS_T(>yDi+zaj!s$@LXR>!6qBqOX!OQ9y{%Ev;?ay99|E-t z4jq*o!ltQ0UPZGxI~9#}^=+}^Bg~CtOVOcH8lm%aQbmayjUyHiO&-m{o;b0^ss1#3gbtuN@GH0zNd0n76)O62kCJ)Ke59=C%l+zpV00G|eYvLzm3tXPbYgSDs>8_9ok#TLd@NM%i_(6P6M6*tbcYgN z&e1|!xh8-6r2+Im4f#~`<-9Fa?sZbXzyFW1eis{*bGcBtSCalJJbwLCz{n?ZJeTi` zP<*jHiQ4K;WiW1iIp+(_yM>XDFfa5epT3@qB*W)bX)mi)+b{T!eERagtc3X_`~Nf6mulqvA@rbB#MH0|?U((N=C`!n(RAKtXtO|i%x7Hc VbxP^XU0Z(#UtO<>AXC5ozW^5y=pz6C literal 0 HcmV?d00001 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"); + } +}