当前位置:网站首页>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>
边栏推荐
- 【简记】解决IDE golang 代码飘红报错
- 视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革
- MySQL表字段调整
- list使用Stream流进行根据元素某属性数量相加
- 定义严苛标准,英特尔Evo 3.0正在加速PC产业升级
- Background system sending verification code function
- JS topic - console log()
- 21.[STM32]I2C协议弄不懂,深挖时序图带你编写底层驱动
- How to introduce devsecops into enterprises?
- Appium automation test foundation - appium basic operation API (I)
猜你喜欢

Anti shake and throttling

RLock锁的使用

D-snow halo solution

Appium automation test foundation - appium basic operation API (II)
![19.[STM32]HC_SR04超声波测距_定时器方式(OLED显示)](/img/fe/8f59db28823290da8e9280df06673d.jpg)
19.[STM32]HC_SR04超声波测距_定时器方式(OLED显示)

视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革

Data communication foundation OSPF Foundation

Subclasses and superclasses of abstract classes

ES6深入—ES6 Generator 函数

Write a go program with vscode in one article
随机推荐
我们为什么要学习数学建模?
具有倍数关系的时钟切换
Good article inventory
通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你
Data communication foundation - route republication
Linear DP (basic questions have been updated)
F. Weights assignment for tree edges problem solving Report
Go language programming specification combing summary
【毕业季】作为一名大二计科在校生,我有话想说
Appium automation test foundation - appium basic operation API (I)
18.[stm32] read the ROM of DS18B20 temperature sensor and realize multi-point temperature measurement
Data communication foundation ACL access control list
Data communication foundation - routing communication between VLANs
Definition of episodic and batch
项目sql中批量update的时候参数类型设置错误
Virtual base class (a little difficult)
Quick completion guide for manipulator (IX): forward kinematics analysis
五种常见的咨询公司谈判策略以及如何维护自己的利益
vant tabbar遮挡内容的解决方式
Example of lvgl display picture