标题: Hash Length Extension Attack备忘 https://scz.617.cn/misc/201606161423.txt 攻击原理参看: -------------------------------------------------------------------------- Hash Length extension attack https://en.wikipedia.org/wiki/Length_extension_attack Everything you need to know about hash length extension attacks - Ron Bowes [2012-09-25] https://blog.skullsecurity.org/2012/everything-you-need-to-know-about-hash-length-extension-attacks https://github.com/iagox86/hash_extender https://github.com/iagox86/hash_extender/archive/master.zip (C版源代码) (写得很好,推荐) HashPump - https://github.com/bwall/HashPump https://github.com/bwall/HashPump/archive/master.zip (C版源代码,有Python扩展) Hash Length Extension attack online http://sakurity.com/lengthextension (第一个框填已知哈希值,第二个框填LEN(secret||data),第三个框填otherdata) Hash Length Extension Attacks - Douglass Clem [2012-03-30] https://www.whitehatsec.com/blog/hash-length-extension-attacks/ http://www.freebuf.com/articles/web/31756.html (中译版) (从WWW利用角度介绍这种攻击方式) -------------------------------------------------------------------------- 抽象简介如下: -------------------------------------------------------------------------- 已知: LEN(secret) data HASH(secret||data) 可以计算: HASH(secret||data||padding||otherdata) padding不是任意值,受HASH()及LEN(secret||data)限制,由于LEN(secret)、data、 已知,HASH()也已知,所以padding可以确定,细节参看Ron Bowes的文章。 otherdata是任意值。 不要求知道secret,只要求知道LEN(secret),后者可以暴力猜测。 可以攻击MD4、MD5、SHA-1、SHA-256、SHA-512,不能攻击MD2、SHA-384。 -------------------------------------------------------------------------- 有很多办法抵御这种攻击,比如: a. 使用HMAC算法,这个算法1996年就提出来了 b. 使用HASH(secret||HASH(secret||data)) c. 使用HASH(data||secret),而不是HASH(secret||data)