Created
March 3, 2015 01:00
-
-
Save andresriancho/84305716967ee9c3b88a to your computer and use it in GitHub Desktop.
Hash length extension attack
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
| >>> import hashlib | |
| >>> secret = 'areallylongsecret' | |
| >>> data = 'product_id=321&price=890.99' | |
| >>> hashlib.md5(secret + data).hexdigest() | |
| '99180b25a0c8a2b4e4981165a7223a8b' | |
| $ hashpump | |
| Input Signature: 99180b25a0c8a2b4e4981165a7223a8b | |
| Input Data: product_id=321&price=890.99 | |
| Input Key Length: 17 | |
| Input Data to Add: price=1.00 | |
| c685c55aaa1da2097873fca8c5cdf72b | |
| product_id=321&price=890.99\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x01\x00\x00\x00\x00\x00\x00price=1.00 | |
| >>> import hashlib | |
| >>> secret = 'areallylongsecret' | |
| >>> data = 'product_id=321&price=890.99\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00`\x01\x00\x00\x00\x00\x00\x00price=1.00' | |
| >>> received_signature = 'c685c55aaa1da2097873fca8c5cdf72b' | |
| >>> if hashlib.md5(secret + data).hexdigest() == received_signature: | |
| ... print 'Signature is correct' | |
| ... else: | |
| ... print 'Reject transaction' | |
| ... | |
| Signature is correct | |
| >>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment