当前位置:网站首页>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>
边栏推荐
- List de duplication and count the number
- 定义严苛标准,英特尔Evo 3.0正在加速PC产业升级
- [brief notes] solve the problem of IDE golang code red and error reporting
- The computer is busy, and the update is a little slow
- 对象和类的关系
- 记录一下树莓派搭建环境中遇到的坑。。。
- MySQL表字段调整
- 21. [STM32] I don't understand the I2C protocol. Dig deep into the sequence diagram to help you write the underlying driver
- RLock锁的使用
- Memo 00
猜你喜欢

Data communication foundation NAT network address translation

Research and practice of super-resolution technology in the field of real-time audio and video

Detailed explanation of C language branch statements

Li Kou today's question -729 My schedule I

五种常见的咨询公司谈判策略以及如何维护自己的利益

vlunhub- BoredHackerBlog Social Network

通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你

Advanced level of static and extern
![21.[STM32]I2C协议弄不懂,深挖时序图带你编写底层驱动](/img/f4/2c935dd9933f5cd4324c29c41ab221.png)
21.[STM32]I2C协议弄不懂,深挖时序图带你编写底层驱动

verilog实现计算最大公约数和最小公倍数
随机推荐
SQL injection sqllabs (basic challenges) 1-10
Fundamentals of data communication - Principles of IP routing
list使用Stream流进行根据元素某属性数量相加
vulnhub-Root_ this_ box
Six common transaction solutions, you sing, I come on stage (no best, only better)
通过的英特尔Evo 3.0整机认证到底有多难?忆联科技告诉你
Appium自动化测试基础 — APPium基础操作API(一)
CODING DevSecOps 助力金融企业跑出数字加速度
Information collection of penetration test
wxml2canvas
Bubble sort, insert sort
Lesson 4 knowledge summary
JS topic - console log()
项目sql中批量update的时候参数类型设置错误
The computer is busy, and the update is a little slow
Codasip adds verify safe startup function to risc-v processor series
lv_ font_ Conv offline conversion
JS knowledge points-01
Subclasses and superclasses of abstract classes
Noi / 1.5 37: mercenaries