Skip to content
Permalink
a2fb3f5766
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 79 lines (53 sloc) 2.52 KB
#!python3
from brutus import Binary
# This is a starting-point for your project
# Most of the work is done for the basic task
# Intermediate will require reading from a dictionary file and creating guesses based on the contents
# For the advanced task, see the supporting module "brute_time"
def generateGuesses():
""" Creates a list of PIN guesses. Needs finishing, testing and documenting... """
#Here, the guesses are listed explicitly. We *could* write out
#1000 guesses, but the point is to use the computer to do the
#brute force work, not our fingers
#For the basic task, the only functionality you need is to replace
#the line below with code that can generate all the potential
#guesses
return ["000","001","002","003","004"]
def breakBinary(target, promptText, failText):
"""" Break into the given target binary.
Assumes "basic" level binary, with PIN codes of 000-999
Args:
target: path to the binary. e.g. "./bins/basic1"
promptText: text to look for in the output that signals a password is required. e.g. "Password:"
failText: text that indicates an attempt failed. e.g. "Password Incorrect"
Returns:
None: if no successful attempt was made
string: a successful password"""
guesses=generateGuesses()
for g in guesses:
#The actual attempt
b=Binary(target)
b.run()
success=b.attempt(promptText,g, failText)
if success:
print(f"The Guess '{g}' appears to be correct")
return g #Return the answer. No need to "break" because the return exits the function
else:
print(f"guess: {g} - Password incorrect!")
return None #If we get here, it means we didn't return earlier in the loop with a successful guess
if __name__=="__main__":
# Create a simple menu system to pick the binary we want to force
targets=[]
targets.append(["targets/basic1","Password:", "Password Incorrect"])
targets.append(["targets/basic2","Enter the secret code:", "ACCESS DENIED"])
targets.append(["targets/basic3","Got the PIN?", "NO"])
print("Basic 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")