Skip to content

Instantly share code, notes, and snippets.

@tsangtmc
Last active August 29, 2015 14:06
Show Gist options
  • Save tsangtmc/f9955102ee1e879acda8 to your computer and use it in GitHub Desktop.
Save tsangtmc/f9955102ee1e879acda8 to your computer and use it in GitHub Desktop.
Rates a list of passwords based on complexity, prints out list with rating for each password
###########################################################
# This script will simply take in a list of password then #
# print out the same list with a rating of the password #
# complexity after it (separated by a tab) #
# + keep in mind the rules are very simple #
# + keep in mind you need to edit the static paths #
# to your files #
# - Disclaimer - I'm not responsible for how you use this #
# this was created for personal usage and for educational #
# purposes #
# CopyLeft Jason Tsang Mui Chung (tsangtmc@gmail.com) #
###########################################################
# 8 characters or more (1 points)
# 16 or more characters (additional 1 point)
# upper case and lowercase (1 point)
# numbers (1 point)
# special charaters (1 point)
# contains common passwords (-1 point)
# to be atleast strong you need a score of 3 (8 or more chars, upper and lower case, numbers or special characters)
# anything less than strong.. is well not good
import re
def CheckPassword(password):
strength = ['Very Weak','Weak','Medium','Strong','Very Strong']
weakwords = ['password','p@ssw0rd','passw0rd','pa$$word','p@$$word','p@$$w0rd','pa$$w0rd','p@s$w0rd','p@$sw0rd','pas$w0rd','pa$sw0rd',
'p@s$word','p@$sword','pas$word','pa$sword','password1','password!','password2','password@','password3','password4','password5',
'password12','password!1','password2345','password@1','password1@','password@2','password2@','password123','password12345','password!@',
'pass','p@ss','pa$$','pa$s','pas$','p@$s','p@s$',
'admin','@dmin','@dm1n','adm1n','administrator','@dministrator','@dministr@tor','administr@tor','@dm1nistrator','@dm1n1strator',
'@dmin1strator','@dm1n1str@t0r','@dmin1strat0r','@dmin1str@t0r','@dm1nistr@t0r','@dm1nistr@tor','adm1nistrat0r', 'adm1nistrator',
'adm1n1strator', 'admin1strator','adm1n1str@t0r','admin1strat0r','admin1str@t0r','adm1nistr@t0r','adm1nistr@tor','adm1nistrat0r']
score = 0
if len(password) < 8:
return strength[0]
if len(password) >=8:
score = score + 1
if len(password) >=16:
score = score + 1
if re.search('\d+',password):
score = score + 1
if re.search('[a-z]',password) and re.search('[A-Z]',password):
score = score + 1
if re.search('.,[,!,@,#,$,%,^,&,*,(,),_,~,-,]',password):
score = score + 1
temppass = password.lower
temppass = str(temppass)
temppass = temppass.replace('\n','')
temppass = temppass.replace('\r','')
# if it is one of the common nono words then automatic zero score
if temppass in weakwords:
print ("COMMON")
return strength[0]
for i in range(0, len(weakwords)):
weakword = weakwords[i]
if weakword in str(temppass):
score = score -1
if (score >= 4):
score = 4
return strength[score]
def main():
with open("C:\\Users\\jtsang\\Documents\\password review\\passwords.txt") as f:
for line in f:
tempscore = CheckPassword(line)
print line +" is "+tempscore
with open("C:\\Users\\jtsang\\Documents\\password review\\passwordresults.txt", "a") as myfile:
line = str(line)
line = line.replace('\n','')
line = line.replace('\r','')
myfile.write(line + "\t" + tempscore + "\n")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment