<?php
if (isset($_GET[id]) && floatval($_GET[id]) !== '1' && substr($_GET[id], -1) === '9') {
include 'config.php';
$id = mysql_real_escape_string($_GET[id]);
$sql="select * from cetc007.user where id='$id'";
$result = mysql_query($sql);
$result = mysql_fetch_object($result);
} else {
$result = False;
die();
}
if(!$result)die("<br >something wae wrong ! <br>");
if($result){
echo "id: ".$result->id."</br>";
echo "name:".$result->user."</br>";
$_SESSION['admin'] = True;
}
?>
<?php
if ($_SESSION['admin']) {
$con = $_POST['con'];
$file = $_POST['file'];
$filename = "backup/".$file;
if(preg_match('/.+\.ph(p[3457]?|t|tml)$/i', $filename)){
die("Bad file extension");
}else{
chdir('uploaded');
$f = fopen($filename, 'w');
fwrite($f, $con);
fclose($f);
}
}
?>
传参con file 满足preg_match(‘/.+.ph(p[3457]?|t|tml)$/i’, $filename)
<!--参考文献-->
!--https://www.php.net/manual/zh/function.preg-match.php--
!--https://www.runoob.com/php/php-preg_match.html--
int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )
[ ] 模式分隔符后的”i”标记这是一个大小写不敏感的搜索
[ ] 模式中的 \b 标记一个单词边界,所以只有独立的单词会被匹配
[ ] \A Start of string
[ ] \z End of string
[ ] . Any single character
[ ] \s Any whitespace character
[ ] \S Any non-whitespace character
[ ] \d Any digit
[ ] \D Any non-digit
[ ] \w Any word character (letter, number, underscore)
[ ] \W Any non-word character
[ ] $ End of line
/.+\.ph(p[3457]?|t|tml)$/i
大小写不敏感
.php结尾不行及其拓展名
fwrite($f, $con); f 文件名 con文件内容
chdir() 函数改变当前的目录。
POST
con=一句话木马
file=文件/.
.会被忽略
/不影响读取
GET
id=1-9
page=flag.php
submit=submit
用户名 | 金币 | 积分 | 时间 | 理由 |
---|---|---|---|---|
veek | 30.00 | 0 | 2021-02-18 10:10:48 |
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.