当前位置:网站首页>CISP-PTE之PHP伪协议总结
CISP-PTE之PHP伪协议总结
2022-07-05 15:28:00 【炫彩@之星】
PHP伪协议总结
0x00 php://input
//所有测试均allow_url_fopen=On,allow_url_include=On!!!
php://input 是个可以访问请求的原始数据的只读流。 POST 请求的情况下,最好使用 php://input 来代替 $HTTP_RAW_POST_DATA,因为它不依赖于特定的 php.ini 指令。 而且,这样的情况下 $HTTP_RAW_POST_DATA 默认没有填充, 比激活 always_populate_raw_post_data 潜在需要更少的内存。 enctype=”multipart/form-data” 的时候 php://input 是无效的。
——php.net
简单说就是获取post数据。
测试代码:

文件包含变命令执行:
测试代码:
<?php$d = file_get_contents(‘php://input’);
//echo d ; @ e v a l ( d; @eval( d;@eval(d)
?>
<?php @include($_GET[“file”]); ?>

写一句话:

0x01 php://filter
php://filter 是一种元封装器, 设计用于数据流打开时的筛选过滤应用。 这对于一体式(all-in-one)的文件函数非常有用,类似 readfile()、 file() 和 file_get_contents(), 在数据流内容读取之前没有机会应用其他过滤器。
——php.net
简单说经常利用它进行base64编码,如
php://filter/read=convert.base64-encode/resource=file:///c:/windows/win.ini”
可以运用多种过滤器(字符串/转换/压缩/加密)
常用于读取文件/源码:

0x02 zip://,bzip2://,zlib://
zlib: 的功能类似 gzopen(),但是 其数据流还能被 fread() 和其他文件系统函数使用。 自 PHP 4.3.0 后这个不建议被使用,因为会和其他带“:”字符的文件名混淆; 请使用 compress.zlib:// 作为替代。
compress.zlib://、 compress.bzip2:// 和 gzopen()、bzopen() 是相等的。并且可以在不支持 fopencookie 的系统中使用。
ZIP 扩展 注册了 zip: 封装器。 自 PHP 7.2.0 和 libzip 1.2.0+ 起,加密归档开始支持密码,允许数据流中使用密码。 字节流上下文(stream contexts)中使用 ‘password’ 选项设置密码。
可选项
- zlib://file.gz
- bzip2://file.bz2
- zip://archive.zip#dir/file.txt
——php.net
简单说就是直接访问压缩包里的文件。
1. zip://
将phpinfo.txt压缩成zip,实战中可以改后缀为jpg绕过上传限制。
注意要用绝对路径+url编码#

2. zlib://

改后缀为jpg亦可,相对路径亦可。
3. bzip2://
同理于zlib://
0x03 data://
data://text/plain;base64,

不加//亦可。
也可以用来读php文件源码:
data:text/plain,<?php system(‘cat /var/www/phprotocol1.php’)?>
或者命令执行:
data:text/plain,<?php system(‘whoami’)?>
0x04 结语
ctf中常利用php伪协议,实战中或许会有奇效。

0x05 参考资料
https://www.waitalone.cn/php-file-include.html
www.freebuf.com/column/148886.html
http://php.net/manual/zh/wrappers.php
</article>
边栏推荐
- How to introduce devsecops into enterprises?
- Maximum common subsequence
- Appium自动化测试基础 — APPium基础操作API(二)
- Advanced level of static and extern
- 六种常用事务解决方案,你方唱罢,我登场(没有最好只有更好)
- [brief notes] solve the problem of IDE golang code red and error reporting
- F. Weights assignment for tree edges problem solving Report
- How difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you
- 18.[stm32] read the ROM of DS18B20 temperature sensor and realize multi-point temperature measurement
- Subclasses and superclasses of abstract classes
猜你喜欢

Arduino controls a tiny hexapod 3D printing robot

力扣今日题-729. 我的日程安排表 I

Replknet: it's not that large convolution is bad, but that convolution is not large enough. 31x31 convolution. Let's have a look at | CVPR 2022

sql中set标签的使用

ES6深入—ES6 Generator 函数

Codasip adds verify safe startup function to risc-v processor series

Why should we learn mathematical modeling?

【简记】解决IDE golang 代码飘红报错

Subclasses and superclasses of abstract classes

Which keywords will conflict with the abstract keyword
随机推荐
17. [stm32] use only three wires to drive LCD1602 LCD
基于OpenHarmony的智能金属探测器
First PR notes
Linear DP (basic questions have been updated)
Data communication foundation NAT network address translation
通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你
【简记】解决IDE golang 代码飘红报错
Noi / 1.5 06: element maximum span value of integer sequence
Optional parameters in the for loop
五种常见的咨询公司谈判策略以及如何维护自己的利益
六种常用事务解决方案,你方唱罢,我登场(没有最好只有更好)
keep-alive
Use of RLOCK lock
Lesson 4 knowledge summary
Summary of the third class
sql中查询最近一条记录
20. [stm32] realize the function of intelligent garbage can by using ultrasonic module and steering gear
如何将 DevSecOps 引入企业?
Data communication foundation - dynamic routing protocol rip
后台系统发送验证码功能