I'm a beginner programmer and thought it would be cool to create a program to loop through "all" possible passwords. On a scale of 1-10, how efficient would you rate the following "hacking program?" Is there any way to make the following code more efficient? Any algorithms or tricks that you may know of?
I've considered moving 'e' and more common letters to the beginning of my character array since those letters are used more commonly.
import sys
password = raw_input("Enter a password: ")
characters = []
lower = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
upper = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
number = ["1","2","3","4","5","6","7","8","9","0"]
symbol = ["!","@","#","$","%","^","&","*","(",")","_","+","-","="]
#Creates array with most keyboard characters
for i in range(len(lower)):
characters.append(lower[i])
for i in range(len(upper)):
characters.append(upper[i])
for i in range(len(number)):
characters.append(number[i])
for i in range(len(symbol)):
characters.append(symbol[i])
found = False
#For 1 character passwords
for a in range(len(characters)):
if (characters[a] == password):
print (characters[a])
found = True
if (found):
sys.exit()
#For 2 character passwords
for a in range(len(characters)):
for b in range(len(characters)):
if (characters[a] + characters[b] == password):
print (characters[a] + characters[b])
found = True
if (found):
sys.exit()
for a in range(len(characters)):
for b in range(len(characters)):
for c in range(len(characters)):
if (characters[a] + characters[b] + characters[c] == password):
print (characters[a] + characters[b] + characters[c])
found = True
if (found):
sys.exit()
for a in range(len(characters)):
for b in range(len(characters)):
for c in range(len(characters)):
for d in range(len(characters)):
if (characters[a] + characters[b] + characters[c] + characters[d] == password):
print (characters[a] + characters[b] + characters[c] + characters[d])
found = True
if (found):
sys.exit()
for a in range(len(characters)):
for b in range(len(characters)):
for c in range(len(characters)):
for d in range(len(characters)):
for e in range(len(characters)):
if (characters[a] + characters[b] + characters[c] + characters[d] + characters[e] == password):
print (characters[a] + characters[b] + characters[c] + characters[d] + characters[e])
found = True
if (found):
sys.exit()