php - 请帮助我理解这个 PHP hack,我怎样才能绕过这个 re
问题描述
我找到了一个php代码,它只能包含这个主题的一个文件,但是这个文件包含数字。它必须绕过这个re。
我尝试使用 file_put_contents 生成具有其他文件名的文件,但仅生成 index.html 中的代码。可以运行 PHP。所以我认为只能绕过这个重新,没有竞争条件
<?php
include_once("fl2g.php");
$filename = $_GET['filename'];
$filename = $_GET['content'];
if(preg_match("/[^a-z\.]/", $filename) == 1) {
echo "Hacker";
die();
}
$files = scandir('./');
foreach($files as $file) {
if(is_file($file)){
if ($file !== "index.php") {
unlink($file);
}
}
}
file_put_contents($filename, $content );
?>
我希望绕过这个重新
解决方案
正则表达式状态:“^”匹配任何不在集合“az”中的字符。(小写“a”到“z”,句号“.”)
Preg_match() 的返回值为 1 如果为假,则为 0 如果为真。
if (preg_match("\[^a-z\.]\", "abc.xyz") == 1)
// would return true(?) because preg_match() returns false , but false = 1; so it returns true. i think :/
那么它似乎删除了目录中的所有文件?
编辑:要在文件名中添加一个数字,您只需附加这样的内容
$filename = "001".$filename; //makes "001ZZZ"
我对 php/regex 有点生疏了
推荐阅读
- regex - 如何解码 URL 中不必要的 url 编码字符?
- vue.js - Javascript 在服务器上启用错误 Kendo + Vue.js
- java - 将使用事件循环的 C++/Qt 线程转换为使用 Dispatchers 的 C#(或 java)线程的可能性
- python - 如何使用 python 中的 lxml 模块按子元素对我的 xml 文件进行排序?
- r - R中pcpr2包中的Datamatrix格式问题
- python - 关于 Euler 项目 8. 问题我在哪里做错了?
- laravel-8 - Laravel 加强两因素身份验证
- google-bigquery - 基于日期/时间字段的分区的分区到期倒计时
- java - 我的导航抽屉不会用(recyclerview、tablayout 和 viewpager inside fragment)打开个人资料片段
- python - python中a=b=class_name(value)和a=class_name(value) b=class_name(value)的区别[不重复]