first commit
This commit is contained in:
51
CPE449/passwordAttacks/dictionary.py
Normal file
51
CPE449/passwordAttacks/dictionary.py
Normal file
@ -0,0 +1,51 @@
|
||||
import crypt
|
||||
from hmac import compare_digest as compare_hash
|
||||
import sys
|
||||
|
||||
|
||||
passwordFileArg = sys.argv[1]
|
||||
passwordList = sys.argv[2]
|
||||
passwordHashLines = [ ]
|
||||
hashesAndSalt = []
|
||||
userIDs = [ ]
|
||||
hashesFromFile = []
|
||||
hashArr = []
|
||||
index = 0
|
||||
|
||||
passwordFile = open(passwordFileArg)
|
||||
passwordHashes = passwordFile.readlines()
|
||||
|
||||
for line in passwordHashes:
|
||||
passwordHashLines.append(line)
|
||||
passwordHashArr = passwordHashLines[index].split(":")
|
||||
# Store salt + hashes, and hashes seperately as well
|
||||
hash = passwordHashArr[1]
|
||||
hashesAndSalt.append(hash)
|
||||
passHash = hash.split("$")
|
||||
userIDs.append(passwordHashArr[0])
|
||||
hashArr.append(passHash[3])
|
||||
# Use hashes
|
||||
hashesFromFile.append(passwordHashArr[1])
|
||||
index += 1
|
||||
|
||||
passwordFile.close()
|
||||
index = 0
|
||||
|
||||
# Check hashes against passwords from file
|
||||
passwordListFile = open(passwordList)
|
||||
passwordList = passwordListFile.readlines()
|
||||
|
||||
# inner loop inside a loop over the password hashes
|
||||
for hashedPassword in hashArr:
|
||||
for password in passwordList:
|
||||
# Compare hashes
|
||||
cmpHash = crypt.crypt(password.rstrip().lstrip(), hashesAndSalt[index])
|
||||
cmpHashPass = cmpHash.split("$")
|
||||
cmpHashPass = cmpHashPass[3]
|
||||
# print(cmpHashPass + " Password Hash: " + hashedPassword)
|
||||
if compare_hash(cmpHashPass, hashedPassword):
|
||||
print("Match found for userid " + userIDs[index] + ". Password = " + password)
|
||||
break
|
||||
else:
|
||||
print("No match was found for " + userIDs[index] + ".")
|
||||
index += 1
|
3546
CPE449/passwordAttacks/dictionary.txt
Normal file
3546
CPE449/passwordAttacks/dictionary.txt
Normal file
File diff suppressed because it is too large
Load Diff
3546
CPE449/passwordAttacks/password-2011.lst
Normal file
3546
CPE449/passwordAttacks/password-2011.lst
Normal file
File diff suppressed because it is too large
Load Diff
3546
CPE449/passwordAttacks/rainbow_table.txt
Normal file
3546
CPE449/passwordAttacks/rainbow_table.txt
Normal file
File diff suppressed because it is too large
Load Diff
23
CPE449/passwordAttacks/rainbowtable.py
Normal file
23
CPE449/passwordAttacks/rainbowtable.py
Normal file
@ -0,0 +1,23 @@
|
||||
import sys
|
||||
import hashlib
|
||||
|
||||
passwordListFile = sys.argv[1]
|
||||
passwords = [ ]
|
||||
hashArr = []
|
||||
hashDictonary = { }
|
||||
index = 0
|
||||
|
||||
passwordFile = open(passwordListFile)
|
||||
passwordList = passwordFile.readlines()
|
||||
|
||||
for password in passwordList:
|
||||
passCleanEncoded = password.rstrip().lstrip().encode("utf_16_le")
|
||||
hash = hashlib.new("md4")
|
||||
hash.update(passCleanEncoded)
|
||||
hashDictonary[hash.hexdigest()] = password
|
||||
|
||||
hashDictonarySorted = sorted(hashDictonary)
|
||||
|
||||
for hashEntry in hashDictonarySorted:
|
||||
msg = hashEntry + ":" + hashDictonary[hashEntry]
|
||||
print(msg.rstrip())
|
3
CPE449/passwordAttacks/shadow
Normal file
3
CPE449/passwordAttacks/shadow
Normal file
@ -0,0 +1,3 @@
|
||||
tommy:$6$HFQQdE2g$g0eyz6UN.c4Pg1tiQgdPPPXdQ1fEOwttCwzSah/Jo4RE9Eac4H7pgksaNLI/WSIyN8tNtCX4NaAq6Uwz.o.4W1:17400:0:99999:7:::
|
||||
mathis:$6$niptplk1$.mMMVx4T375WhFkDN5RWEaD93HcmDCx3aBQrn2ZalbiRpl4FB2Rww/BeCPEfSYbegjPvoHM2llQmk/VBbSxWj.:17400:0:99999:7:::
|
||||
tristan:$6$MWwusFJx$KCoO1wiWKtE.7j/7UiwD.1jXmOckMb5X4GGt1DotLS0laXdFga5n3wGfu43FC/Opxki7mY6Yf9XT.cBGN.pkp0:17400:0:99999:7:::
|
Reference in New Issue
Block a user