Created
September 9, 2011 22:48
-
-
Save eykd/1207523 to your computer and use it in GitHub Desktop.
Demonstrating bad password check for django_des_crypt password hashes in passlib
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
| In [4]: u.password | |
| Out[4]: u'crypt$MNVY.9ajgdvDQ$MNVY.9ajgdvDQ' | |
| In [5]: u.check_password('foo') | |
| --------------------------------------------------------------------------- | |
| ValueError Traceback (most recent call last) | |
| .../lib/python2.7/site-packages/django_extensions/management/commands/shell_plus.pyc in <module>() | |
| ----> 1 u.check_password('foo') | |
| .../src/passlib/passlib/ext/django/utils.pyc in check_password(user, raw_password) | |
| 157 cat = get_category(user) if get_category else None | |
| 158 ok, new_hash = context.verify_and_update(raw_password, hash, | |
| --> 159 category=cat) | |
| 160 if ok and new_hash: | |
| 161 user.password = new_hash | |
| .../src/passlib/passlib/context.pyc in verify_and_update(self, secret, hash, scheme, category, **kwds) | |
| 1116 | |
| 1117 def verify_and_update(self, secret, hash, scheme=None, category=None, **kwds): | |
| -> 1118 ok = self.verify(secret, hash, scheme=scheme, category=category, **kwds) | |
| 1119 if not ok: | |
| 1120 return False, None | |
| .../src/passlib/passlib/context.pyc in verify(self, secret, hash, scheme, category, **context) | |
| 1100 | |
| 1101 #use handler to verify secret | |
| -> 1102 result = handler.verify(secret, hash, **context) | |
| 1103 | |
| 1104 if mvt: | |
| .../src/passlib/passlib/utils/handlers.pyc in verify(cls, secret, hash) | |
| 462 # may wish to either override this, or override norm_checksum | |
| 463 # to normalize any checksums provided by from_string() | |
| --> 464 self = cls.from_string(hash) | |
| 465 return self.checksum == self.calc_checksum(secret) | |
| 466 | |
| .../src/passlib/passlib/handlers/django.pyc in from_string(cls, hash) | |
| 51 raise ValueError("invalid %s hash" % (cls.name,)) | |
| 52 _, salt, chk = hash.split(u"$") | |
| ---> 53 return cls(salt=salt, checksum=chk, strict=True) | |
| 54 | |
| 55 def to_string(self): | |
| .../src/passlib/passlib/utils/handlers.pyc in __init__(self, salt, salt_size, strict, **kwds) | |
| 725 #========================================================= | |
| 726 def __init__(self, salt=None, salt_size=None, strict=False, **kwds): | |
| --> 727 self.salt = self.norm_salt(salt, salt_size=salt_size, strict=strict) | |
| 728 super(HasSalt, self).__init__(strict=strict, **kwds) | |
| 729 | |
| .../src/passlib/passlib/utils/handlers.pyc in norm_salt(cls, salt, salt_size, strict) | |
| 792 for c in salt: | |
| 793 if c not in sc: | |
| --> 794 raise ValueError("invalid character in %s salt: %r" % (cls.name, c)) | |
| 795 | |
| 796 #check min size | |
| ValueError: invalid character in django_des_crypt salt: u'M' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment