Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
107 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,70 @@ | ||
#!python3 | ||
from brutus import Binary | ||
|
||
|
||
def maxPos(seq): | ||
""" Given a list of numbers, return the **position** of the largest | ||
Args: | ||
seq: the list to be searched | ||
Returns: | ||
an integer position of the largest number in `seq` | ||
""" | ||
maxNum=seq[0] | ||
maxPos=0 | ||
for i in range(len(seq)): | ||
if seq[i]>maxNum: | ||
maxNum=seq[i] | ||
maxPos=i | ||
return maxPos | ||
|
||
|
||
# def averageTry(target, promptText, failText, guess, repeats=2): | ||
# # Provided to assist. If you use it, document it properly... :) | ||
# # Runs multiple attempts at cracking the binary, returning the | ||
# # success AND the average length of time each try took | ||
# results=[] | ||
# success=False | ||
# for i in range(repeats): | ||
# b=Binary(target) | ||
# b.run() | ||
# result=b.timedAttempt(promptText,guess, failText) | ||
# success=result[0] | ||
# results.append(result[1]) | ||
# return (success,sum(results)/len(results)) | ||
|
||
def breakBinary(target, promptText, failText): | ||
|
||
|
||
#Your code here | ||
# Suggested algorithm: | ||
|
||
#1. Use an accumulator for the current guess | ||
#2. in a loop, try the current guess plus each letter of the alphabest and see which one takes longest | ||
#3. If it is the correct password, end | ||
#4. If not, add the current best letter to the guess and repeat... | ||
pass | ||
|
||
|
||
|
||
if __name__=="__main__": | ||
|
||
|
||
# Create a simple menu system to pick the binary we want to force | ||
targets=[] | ||
targets.append(["targets/advanced1","Password:", "Password Incorrect"]) | ||
targets.append(["targets/advanced2","Password:", "Password Incorrect"]) | ||
targets.append(["targets/advanced3","Password:", "Password Incorrect"]) | ||
|
||
print("Intermediate Binary Breaker") | ||
print("Which binary do you want to brute force?") | ||
|
||
for c in range(len(targets)): | ||
print(f"{c}: {targets[c][0]}") | ||
|
||
selection=int(input("Enter the number of the binary to be forced: ")) | ||
|
||
if 0 <= selection < len(targets): | ||
target=targets[selection] | ||
breakBinary(target[0],target[1],target[2]) | ||
else: | ||
print("Invalid selection") |
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,14 @@ | ||
import pytest | ||
import sys | ||
sys.path.append("./src/") | ||
|
||
|
||
#You will need to write tests for your own functions, or change tests for ones you modify | ||
|
||
from brute_advanced import maxPos | ||
|
||
|
||
def test_maxPos(): | ||
assert maxPos([1,2,3])==2 | ||
assert maxPos([1])==0 | ||
assert maxPos([1,-10])==0 |