Last active
May 21, 2018 18:31
-
-
Save yarjor/a8fd8633f2bdb06d0007263f34bb2af9 to your computer and use it in GitHub Desktop.
[Hash length extension attack (MD5)] #hash #crypto #attack #signature #links
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
| from hashlib import md5 | |
| import struct | |
| secret = 'secret' | |
| data = 'data' | |
| fullstring = secret + data | |
| signature = md5(fullstring).hexdigest() | |
| # Known are signature and data! | |
| original_padding = 'I' + \ | |
| (56 - 1 - len(fullstring)) + \ | |
| struct.pack('<Q', len(fullstring) * 8) | |
| append = 'append' | |
| attack_string = data + original_padding + append | |
| md = md5('') # here we should update the md5 function with our known signature as state | |
| attack_sign = md(append) |
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
| https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks | |
| https://github.com/cbornstein/python-length-extension/blob/master/pymd5.py | |
| # Also pip install hashpumpy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment