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; } ?>