ctf中md5常见绕过
字符串0e
PHP在处理哈希字符串时,会利用”!=”或”==”来对哈希值进行比较,它把每一个以”0E”开头的哈希值都解释为0,所以如果两个不同的密码经过哈希以后,其哈希值都是以”0E”开头的,那么PHP将会认为他们相同,都是0。
s878926199a
0e545993274517709034328855841020
s155964671a
0e342768416822451524974117254469
s214587387a
0e848240448830537924465865611904
s214587387a
0e848240448830537924465865611904
s878926199a
0e545993274517709034328855841020
s1091221200a
0e940624217856561557816327384675
s1885207154a
0e509367213418206700842008763514
s1502113478a
0e861580163291561247404381396064
s1885207154a
0e509367213418206700842008763514
s1836677006a
0e481036490867661113260034900752
s155964671a
0e342768416822451524974117254469
s1184209335a
0e072485820392773389523109082030
s1665632922a
0e731198061491163073197128363787
s1502113478a
0e861580163291561247404381396064
s1836677006a
0e481036490867661113260034900752
s1091221200a
0e940624217856561557816327384675
s155964671a
0e342768416822451524974117254469
s1502113478a
0e861580163291561247404381396064
s155964671a
0e342768416822451524974117254469
s1665632922a
0e731198061491163073197128363787
s155964671a
0e342768416822451524974117254469
s1091221200a
0e940624217856561557816327384675
s1836677006a
0e481036490867661113260034900752
s1885207154a
0e509367213418206700842008763514
s532378020a
0e220463095855511507588041205815
s878926199a
0e545993274517709034328855841020
s1091221200a
0e940624217856561557816327384675
s214587387a
0e848240448830537924465865611904
s1502113478a
0e861580163291561247404381396064
s1091221200a
0e940624217856561557816327384675
s1665632922a
0e731198061491163073197128363787
s1885207154a
0e509367213418206700842008763514
s1836677006a
0e481036490867661113260034900752
s1665632922a
0e731198061491163073197128363787
s878926199a
0e545993274517709034328855841020
数组绕过
<?php
highlight_file(__file__);
include "flag.php";
if (!isset($_GET['a']) || !isset($_GET['b'])) {
die("GET me a & b");
}
if ($_GET['a'] !== $_GET['b'] &&
md5($_GET['a']) === md5($_GET['b'])) {
echo $flag;
} else {
echo "No No No";
}
?>
当MD5接受的参数为数组时,其值都为0,所以构造payload:
?a[]=1&b[]=2
真实碰撞
<?php
highlight_file(__file__);
include "flag.php";
if (!isset($_GET['a']) || !isset($_GET['b'])) {
die("GET me a & b");
}
if ((string) $_GET['a'] !== (string) $_GET['b'] &&
md5($_GET['a']) === md5($_GET['b'])) {
echo $flag;
} else {
echo "No No No";
}
?>
“===”以及强制字符串类型转换,这时只能用真实碰撞了
碰撞工具fastcoll下载地址:http://www.win.tue.nl/hashclash/fastcoll_v1.0.0.5.exe.zip
创建a.txt,内容为1
运行fastcoll 输入以下参数。 -p 是源文件 -o 是输出文件
fastcoll_v1.0.0.5.exe -p a.txt -o 1.txt 2.txt
生成两个md5值相同,但实际内容不同的文件
<?php
function readmyfile($path){
$fh = fopen($path, "rb");
$data = fread($fh, filesize($path));
fclose($fh);
return $data;
}
echo '二进制hash '. md5( (readmyfile("1.txt")));
echo "<br><br>\r\n";
echo 'URLENCODE '. urlencode(readmyfile("1.txt"));
echo "<br><br>\r\n";
echo 'URLENCODE hash '.md5(urlencode (readmyfile("1.txt")));
echo "<br><br>\r\n";
echo '二进制hash '.md5( (readmyfile("2.txt")));
echo "<br><br>\r\n";
echo 'URLENCODE '. urlencode(readmyfile("2.txt"));
echo "<br><br>\r\n";
echo 'URLENCODE hash '.md5( urlencode(readmyfile("2.txt")));
echo "<br><br>\r\n";
传入两个文件输出的urlencode即可