当前位置:网站首页>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 difficult is it to pass the certification of Intel Evo 3.0? Yilian technology tells you
- 19.[STM32]HC_ SR04 ultrasonic ranging_ Timer mode (OLED display)
- Six common transaction solutions, you sing, I come on stage (no best, only better)
- 项目sql中批量update的时候参数类型设置错误
- Optional parameters in the for loop
- Appium自动化测试基础 — APPium基础操作API(一)
- vlunhub- BoredHackerBlog Moriarty Corp
- Appium自动化测试基础 — APPium基础操作API(二)
- vulnhub-FirstBlood
- F. Min cost string problem solving Report
猜你喜欢
把 ”中台“ 的思想迁移到代码中去
Clock switching with multiple relationship
abstract关键字和哪些关键字会发生冲突呢
研发效能度量指标构成及效能度量方法论
vulnhub-Root_ this_ box
Li Kou today's question -729 My schedule I
[brief notes] solve the problem of IDE golang code red and error reporting
16. [stm32] starting from the principle, I will show you the DS18B20 temperature sensor - four digit digital tube displays the temperature
swiper. JS to achieve barrage effect
【 note 】 résoudre l'erreur de code IDE golang
随机推荐
vant popup+其他组件的组合使用,及避坑指南
SQL injection sqllabs (basic challenges) 11-20
wxml2canvas
CSRF, XSS science popularization and defense
17.[STM32]仅用三根线带你驱动LCD1602液晶
Analytic hierarchy process of mathematical modeling (including Matlab code)
vant tabbar遮挡内容的解决方式
The visual experience has been comprehensively upgraded, and Howell group and Intel Evo 3.0 have jointly accelerated the reform of the PC industry
list集合根据对象某属性求和,最大值等
This article takes you through the addition, deletion, modification and query of JS processing tree structure data
Definition of episodic and batch
Background system sending verification code function
MySQL overview
Noi / 1.5 37: mercenaries
The OBD deployment mode of oceanbase Community Edition is installed locally
vlunhub- BoredHackerBlog Moriarty Corp
Temporary cramming before DFS examination
Data communication foundation NAT network address translation
【 note 】 résoudre l'erreur de code IDE golang
Bubble sort, insert sort