Skip to content

Instantly share code, notes, and snippets.

@wray
Created January 28, 2018 20:45
Show Gist options
  • Save wray/b9216aa3be8edce93a2283abae12d9ea to your computer and use it in GitHub Desktop.
Save wray/b9216aa3be8edce93a2283abae12d9ea to your computer and use it in GitHub Desktop.
Simple example for brute force pin guessing
import time
import itertools
def brute_force_digits(pin):
""" Uses itertools to create a cartesian product of the possible pins """
for guess in list(itertools.product(list(range(10)),repeat=len(str(pin)))):
if pin == int(len(str(pin))*'%d' % (guess)):
return guess
if __name__ == '__main__':
""" This will start breaking down on a 8 digit pin (i7 16GB) """
print('Provide a digit-only pin to be brute-forced guessed')
pin = input()
t1 = time.time()
guess = brute_force_digits(int(pin))
print('Found: ' + str(guess))
t2 = time.time()
print('Elapsed time was ' + str(t2-t1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment