php伪协议
<p>php伪协议是ctf中的一个考点,目前比较熟悉的伪协议有php://filter, php://input, data://text/plain, file://,后续补充。</p><p>要成功应用伪协议需要php.ini文件的allow_url_fopen 默认开启</p>
<p> allow_url_include 默认关闭</p>
<p><strong>file://伪协议</strong></p>
<p>此协议可以在双off的情况下使用,用于访问本地文件</p>
<p>使用方法:file://文件绝对路径和文件名 如http://127.0.0.1/cmd.php?file=file://D:/soft/phpStudy/WWW/phpcode.txt</p>
<p> </p>
<p><strong>data://text/plain协议</strong></p>
<p>此协议需要在双on的情况下才能使用,很常用的数据流构造器,将读取后面base编码字符串后解码的数据作为数据流的输入</p>
<p>使用方法:data://text/plain;base64,base64编码字符 如http://127.0.0.1/cmd.php?file=data://text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=</p>
<p> data://text/plain,字符 如http://127.0.0.1/cmd.php?file=data://text/plain,<?php phpinfo()?></p>
<p> </p>
<p><strong>php:input协议</strong></p>
<p>此协议需要allow_url_include为on,可以访问请求的原始数据的只读流, 将post请求中的数据作为PHP代码执行。当传入的参数作为文件名打开时,可以将参数设为php://input,同时post想设置的文件内容,php执行时会将post内容当作文件内容。</p>
<p>使用方法:php://input,然后post需要执行的数据 如http://127.0.0.1/cmd.php?file=php://input 然后在post中<?php phpinfo() ?><img src="https://img2018.cnblogs.com/common/1937742/202002/1937742-20200208105940639-1014101743.png"></p>
<p> </p>
<p><strong>php://filter协议</strong></p>
<p>在双off的情况下也可使用,读取文件并进行显示或写入</p>
<table border="0">
<thead>
<tr align="center" valign="middle"><th><span style="font-size: 14pt">名称</span></th><th><span style="font-size: 14pt">描述</span></th></tr>
</thead>
<tbody>
<tr align="center" valign="middle">
<td><span style="font-size: 14pt">resource=<要过滤的数据流></span></td>
<td><span style="font-size: 14pt">这个参数是必须的。它指定了你要筛选过滤的数据流。</span></td>
</tr>
<tr align="center" valign="middle">
<td><span style="font-size: 14pt"><em>read=<读链的筛选列表></em></span></td>
<td><span style="font-size: 14pt">该参数可选。可以设定一个或多个过滤器名称,以管道符(|)分隔</span></td>
</tr>
<tr align="center" valign="middle">
<td><span style="font-size: 14pt"><em>write=<写链的筛选列表></em></span></td>
<td><span style="font-size: 14pt">该参数可选。可以设定一个或多个过滤器名称,以管道符(|)分隔</span></td>
</tr>
<tr align="center" valign="middle">
<td><span style="font-size: 14pt"><em><;两个链的筛选列表></em></span></td>
<td>
<p><span style="font-size: 14pt">任何没有以 <em>read=</em> 或 <em>write=</em> 作前缀 的筛选器列表会视情况应用于读或写链。</span></p>
</td>
</tr>
</tbody>
</table>
<p>使用方法:php://filter/read=convert.base64-encode/resource=文件名(对文件进行base64编码并读取显示) 如</p>
<p>http://127.0.0.1/cmd.php?file=php://filter/read=convert.base64-encode/resource=./cmd.php</p>
<p> 参考地址:https://www.leavesongs.com/PENETRATION/php-filter-magic.html</p>
<p> https://www.cnblogs.com/dubhe-/p/9997842.html</p>
<p> https://www.freebuf.com/column/148886.html</p><br><br>
来源:https://www.cnblogs.com/weak-chicken/p/12275806.html
頁:
[1]