实验吧-让我进去

让我进去

原题链接

http://ctf5.shiyanbar.com/web/kzhan.php

分析

Burp 抓包发现,Cookie有东西。
先是把source=0改成source=1,得到源码,接下来就好办了。
开始审计:

<?php
$flag = "XXXXXXXXXXXXXXXXXXXXXXX";
$secret = "XXXXXXXXXXXXXXX"; // 密码未知,但是长度已知15位

$username = $_POST["username"];
$password = $_POST["password"];

//想获取flag:
//1.usename === "admin"
//2.password != "admin"
//3.cookie["getmein"] === md5(15位未知密码.admin.$password)

if (!empty($_COOKIE["getmein"])) {
    if (urldecode($username) === "admin" && urldecode($password) != "admin") {
        if ($COOKIE["getmein"] === md5($secret . urldecode($username . $password))) {
            echo "Congratulations! You are a registered user.\n";
            die ("The flag is ". $flag);
        }
        else {
            die ("Your cookies don't match up! STOP HACKING THIS SITE.");
        }
    }
    else {
        die ("You are not an admin! LEAVE.");
    }
}

//这里给出了sample-hash = md5(15位未知密码."adminadmin") = 571580b26c65f306376d4f64e53cb5c7
setcookie("sample-hash", md5($secret . urldecode("admin" . "admin")), time() + (60 * 60 * 24 * 7));

if (empty($_COOKIE["source"])) {
    setcookie("source", 0, time() + (60 * 60 * 24 * 7));
}
else {
    if ($_COOKIE["source"] != 0) {
        echo ""; // This source code is outputted here
    }
}

这里,我是用HashPump构造攻击payload,
以下为参考链接,因为遇到两三次了,但是一直没太看懂原理,打算抽个时间总结一下。
HashPump安装与使用

hash哈希长度扩展攻击解析(记录一下,保证不忘)

科普哈希长度扩展攻击(Hash Length Extension Attacks)

Everything you need to know about hash length extension attacks

ldl@ubuntu:~$ hashpump
Input Signature: 571580b26c65f306376d4f64e53cb5c7
Input Data: admin
Input Key Length: 20
Input Data to Add: ldl
8286d89e3fdcf07389c3f6d635ab94b0
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\x00ldl

\x00改成%00即可。

payload:

**Cookie**
getmein=8286d89e3fdcf07389c3f6d635ab94b0;
**POST**
username=admin&password=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%00ldl
11129189-7cf54ca98b9d08aa.png

flag

CTF{cOOkieS_4nd_hAshIng_G0_w3LL_t0g3ther}

知识点

hash长度扩展攻击

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值