Last active
March 16, 2018 07:31
-
-
Save Satak/50f69ba6b01137777f417176721a14af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crypt | |
def crypt_test(password, salt, checksum='my43charchecksum'): | |
'''Test only the logic without crypt library''' | |
correct = 'iCeCream9999' | |
if password == correct: | |
return 'prefix {} suffix'.format(checksum) | |
return 'prefix something else suffix' | |
def main(): | |
# beginning of the plaintext password | |
pw_part = 'iCeCream' | |
# random checksum of the real unknow password | |
checksum = 'my43charchecksum' | |
# random salt | |
salt_string = '$mysaltstring' # remember to put $ sign first! | |
# sha256 method | |
method = '$5' | |
# final salt string for the function | |
salt = method + salt_string | |
# iteration to know the real password e.g. 'iCeCream6070' | |
for number in range(10000): | |
password = pw_part + str(number).zfill(4) | |
# crypt library works only with Unix-like systems | |
# example usage: crypt.crypt('plaintext', '$5$mysalt') | |
# example output of crypt.crypt: '$5$mysalt$PGffDtysDjNOnNi/r6.0ECtKy5dsVtaqwZ1VYFuGoUC' | |
if checksum in crypt.crypt(password, salt): | |
print('password is:', password) | |
break | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment