CTF-MD5碰撞
创建日期:
题目
<?php
$cmd=$_GET['cmd'];
if ((string)$_POST['a'] !== (string)$_POST['b'] && md5($_POST['a']) === md5($_POST['b'])) {
echo `$cmd`;
} else {
echo ("die");
}
?>
可以看到:a!==b并且md5(a)===md5(b)
工具:fastcoll
下载地址:https://www.win.tue.nl/hashclash/fastcoll_v1.0.0.5.exe.zip
使用教程:
-
创建一个a.txt文件,输入任意内容
-
指令fastcoll_v1.0.0.5.exe -p a.txt -o 1.txt 2.txt
程序运行之后,1.txt和2.txt的内容不同,但是hash值相同
生成便于提交的URL编码的验证脚本
<?php
function readmyfile($path){
$fh = fopen($path, "rb");
$data = fread($fh, filesize($path));
fclose($fh);
return $data;
}
$a = urlencode(readmyfile("./1.txt"));
$b = urlencode(readmyfile("./2.txt"));
$aa=urldecode($a);
$bb=urldecode($b);
if ((string)$aa !== (string)$bb && md5($aa) === md5($bb)) {
echo $a."\n".$b;
}
?>
- 版权声明:遵循CC 4.0 BY-SA版权协议,转载请发邮件征求作者同意,并附上原文出处链接及本声明。
- 合规声明: 本文仅限于技术交流,请读者遵守当地法律,如造成侵权、违法、犯罪行为,与本文无关。如本文存在侵权,请通过邮箱联系。
- 作者: Yalois
- 邮箱: yalois.xy@foxmail.com
- 主页: www.sky233.top
- 不能确保文章内容完全正确,欢迎各位纠错。