Greg Hewgill的第一點值得強調。我剛剛發現 - 有些令我驚訝 - 在我的筆記本上,系統hashlib.py對全世界開放。因此,擊敗上述認證很簡單:
localhost-2:coding $ cat hashcrack.py
class always_equal(object):
def __eq__(self, other):
return True
class sha512(object):
def __init__(self, password):
pass
def hexdigest(self):
return always_equal()
localhost-2:coding $ cat hashcrack.py >> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py
localhost-2:coding $ cat notsosecure.py
import hashlib
theInput = raw_input("Enter password: ")
theHashed = hashlib.sha512(theInput).hexdigest()
if theHashed == "35211b890b19afebfabc3451f04d150f1423bcb54ff7d62095677d7af7560fcvb56c112e879288836cb506853516c5dbd1d779cfaedf4a2f6f6a303600c0c589":
print "Correct!"
localhost-2:coding $ python notsosecure.py
Enter password: pwned
Correct!
試想想起來了,我甚至沒有需要作出新的SHA512類,在舊我可以簡單地monkeypatched hexdigest。
反正+1到,它不是在你的散列位的數量是占主導地位的安全隱患點..
來源
2012-01-06 04:58:37
DSM
+1 for always always equal – 2013-03-03 16:09:46