[CTF]No.0003 哈希长度扩展攻击以及HashPump
来源:互联网 发布:手机淘宝 卖家中心 编辑:程序博客网 时间:2024/06/05 07:01
哈希长度扩展攻击以及HashPump
来源:群里的朋友
类别: 哈希长度扩展攻击、源码泄漏
来源:http://www.moonsos.com/post/256.html
用到工具:Linux 、 HashPump
题目:无
CTF地址:http://115.28.78.16:10026/hash/
百度网盘下载:(暂无)
进入地址
进入地址,返回一片空白。查看Header
Ip: 115.28.78.16Request URL: http://115.28.78.16:10026/hash/Request Method: POSTStatus Code: 200 OKRequest Proto: HTTP/1.1Request HeaderContent-Type:application/x-www-form-urlencoded;Response HeaderDate:Sun, 20 Aug 2017 15:05:22 GMT;Vary:Accept-Encoding;Set-Cookie:hint=295c2a4121224809b6576ab695d10b439a2a85b5; expires=Sun, 27-Aug-2017 15:05:22 GMT;Server:nginx;Connection:keep-alive;X-Powered-By:PHP/5.4.41;Content-Type:text/html;
找源码
在 http://115.28.78.16:10026/hash/.index.php.swp 可以看到源码
$flag = 'flag{????}'; $salt = '???????????????'; $username = $_POST["username"]; $password = $_POST["password"]; if (!empty($_COOKIE["token"])) { if (urldecode($username) === "admin" && urldecode($password) != "admin") { if ($COOKIE["token"] === sha1($salt . 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."); } } setcookie("hint", sha1($salt . urldecode("admin" . "admin")), time() + (60 * 60 * 24 * 7)); ?>
自行格式化
$flag = 'flag{????}'; $salt = '???????????????'; $username = $_POST["username"]; $password = $_POST["password"]; if (!empty($_COOKIE["token"])) { if (urldecode($username) === "admin" && urldecode($password) != "admin") { if ($COOKIE["token"] === sha1($salt . 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."); } } setcookie("hint", sha1($salt . urldecode("admin" . "admin")), time() + (60 * 60 * 24 * 7)); ?>
分析源码
进入地址时,$_COOKIE["token"]
为空的时候就返回一个由$salt . urldecode("admin" . "admin")
经过SHA1加密的哈希值。如果$_COOKIE["token"]
不为空,则 进行一系列的判断。
揭密
由cookies可以看出:hint=295c2a4121224809b6576ab695d10b439a2a85b5;
,扔到SHA1解密的网站解码失败,于是通过百度搜索找到几篇类似的文章(文章在下面给出)。
于是进入centOS(LINUX系统)
安装HashPump进行攻击:
git clone https://github.com/bwall/HashPumpyum install g++ libssl-dev#apt-get install g++ libssl-devcd HashPumpmakemake install
Python未测试:
pip install hashpumpy
运行HashPump
[root@iZuf6c363gqa4g5ecbbcdbZ ~]# hashpumpInput Signature: 295c2a4121224809b6576ab695d10b439a2a85b5Input Data: adminInput Key Length: 20Input Data to Add: sb2ee42cea7ef6c7ff586e06395ce316a243efd424admin\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\x00\x00\x00\x00\x00\x00\x00\xc8sb
把\x替换为%,然后把POST中的password改为下面的值,token取上面2ee42cea7ef6c7ff586e06395ce316a243efd424
讲解:
Input Signature 为COOKIES中hint的值
Input Data 为用户名
Input Key Length: 为长度(20为上面15个“?”号+admin的长度=20)
Input Data to Add: 为密码(自定义,除了admin)
至于为什么分开呢?我也不知道
提交
Ip: 115.28.78.16Request URL: http://115.28.78.16:10026/hash/Request Method: POSTStatus Code: 200 OKRequest Proto: HTTP/1.1Request HeaderCookie:token=2ee42cea7ef6c7ff586e06395ce316a243efd424;Content-Type:application/x-www-form-urlencoded;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%00%00%00%00%00%00%00%c8sbResponse HeaderContent-Type:text/html;X-Powered-By:PHP/5.4.41;Server:nginx;Date:Sun, 20 Aug 2017 14:53:17 GMT;Connection:keep-alive;Vary:Accept-Encoding;
返回文本:
Congratulations! You are a registered user.The flag is flag{ohyes_flag}
破解成功
参考
哈希长度扩展攻击以及HashPump
校赛 writeup
http://www.cnblogs.com/pcat/p/5478509.html
- [CTF]No.0003 哈希长度扩展攻击以及HashPump
- 哈希长度扩展攻击以及HashPump
- Hashpump实现哈希长度扩展攻击
- 哈希长度扩展攻击解析
- phpwind 利用哈希长度扩展攻击进行getshell
- 长度扩展攻击
- MD4长度扩展攻击
- 长度扩展攻击详解
- Hash长度扩展攻击--MD5
- hash哈希长度扩展攻击解析(记录一下,保证不忘)
- 浅析哈希长度拓展攻击
- 用MD5实现hash长度扩展攻击 By Assassin
- [CTF]No.0001 博兹瓦纳-爆破
- [CTF]No.0005 [强网杯] broken
- CTF/CTF练习平台-login1【sql约束攻击】
- 实验吧-让我进去【salt加密 哈希长度拓展攻击】
- [CTF]No.0005 [强网杯] Who are you
- 南宁杯CTF以及中科大CTF的一点总结
- window.onresize使用实例
- 数据分析之微信通讯录分析
- PAT乙级(Basic Level)真题 >A+B和C (15)
- matlab字体终极解决方案
- Java源代码阅读-HashMap篇
- [CTF]No.0003 哈希长度扩展攻击以及HashPump
- xss挑战赛-wp
- mysql性能优化之profiling
- 2018网易校招笔试题之疯狂队列
- Python随机选择
- win10+go+beego搭建用户管理系统
- Codeforces Round #381 (Div. 2) #V
- 用css做的风琴相册
- Visual Studio如何设置背景