グレッグ・ヒューギルの最初のポイントは強調する価値があります。私のノートブックでは、システム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クラスを作成する必要はなく、古いクラスでhexdigestをモンキーパッチするだけで済みました。
とにかく、主要なセキュリティハザードであるのはハッシュのビット数ではないという点まで+1します。