Skip to content

Instantly share code, notes, and snippets.

@LukeMurphey
Created May 13, 2013 17:15
Show Gist options
  • Save LukeMurphey/5569869 to your computer and use it in GitHub Desktop.
Save LukeMurphey/5569869 to your computer and use it in GitHub Desktop.
Computes the minimal set of codes to attempt in order to open a GE Supra lockbox. This script will generate the codes necessary to perform a brute-force attack on a Supra lockbox. By default, the script outputs all 4 digit codes. Set the first argument to another value (e.g. "supra_codes.py 5") in order to generate codes with more or less digits…
"""
Computes the minimal set of codes to open a GE Supra lock box (such as http://www.amazon.com/Security-Keysafe-Cabinet-Assorted-Colors/dp/B000VL4TSW).
"""
import sys
def remove_values_from_list(the_list, val):
the_list_copy = the_list[:]
if val in the_list_copy:
the_list_copy.remove(val)
return the_list_copy
def get_permutations( possibles, length, current=None ):
# Base case
if length == 0:
return
permutations = []
# Remove the existing item
if current is not None:
possibles = remove_values_from_list(possibles, current)
# Get the list
for p in possibles:
if length > 1:
# Recurse and get the permutations
new_list = get_permutations(possibles, length - 1, p)
# Add each permutation
for new_list_entry in new_list:
# Make the new permutation
new_permutation = new_list_entry[:]
new_permutation.append(p)
# If the permutation is unique, then add it
if sorted(new_permutation) not in permutations:
permutations.append( sorted(new_permutation) )
else:
permutations.append( [p] )
return permutations
def perm_to_str( permutation ):
s = ""
for p in permutation:
s = s + str(p)
return s
def tostr(combo):
print combo
return "".join(combo)
# Determine the length to use from the CLI arguments
if len(sys.argv) > 1:
code_length = int(sys.argv[1])
else:
code_length = 4
possibles = [0,1,2,3,4,5,6,7,8,9]
for perm in get_permutations(possibles, code_length):
print perm_to_str(perm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment