php伪协议是什么(漏洞梳理篇之php伪协议)
PHP偽協(xié)議
首先,我們需要先了解一下我們?cè)贑TF中可能遇到的文件包含函數(shù):
1、include 2、require 3、include_once 4、require_once 5、highlight_file 6、show_source 7、readfile
8、file_get_contents 9、fopen 10、file(比較常見(jiàn))
PHP偽協(xié)議事實(shí)上就是支持的協(xié)議與封裝協(xié)議(12種)
a. file:// — 訪問(wèn)本地文件系統(tǒng)
b. http:// — 訪問(wèn) HTTP(s) 網(wǎng)址
c. ftp:// — 訪問(wèn) FTP(s) URLs
d. php:// — 訪問(wèn)各個(gè)輸入/輸出流(I/O streams)
e. zlib:// — 壓縮流
f. data:// — 數(shù)據(jù)(RFC 2397)
g. glob:// — 查找匹配的文件路徑模式
h. phar:// — PHP 歸檔
i. ssh2:// — Secure Shell 2
j. rar:// — RAR
k. ogg:// — 音頻流
l. expect:// — 處理交互式的流
是否需要截?cái)?/strong>
1、不需要截?cái)?/strong>
<?php include($_GET['file']) ?>
登錄后復(fù)制
2、需要截?cái)?(在php版本<=5.2中進(jìn)行測(cè)試是可以使用%00截?cái)嗟模?/p>
<?php include($_GET['file'].'.php') ?>
登錄后復(fù)制
file://協(xié)議
file://協(xié)議在雙off的情況下也是可以正常使用的。
allow_url_fopen :off/on
allow_url_include:off/on
file://用于訪問(wèn)本地文件系統(tǒng),在CTF中常用來(lái)讀取本地文件。
使用方法:file://文件的絕對(duì)路徑和文件名。
Eg:http://127.0.0.1/cmd.php?file=file://D:/soft/phpStudy/WWW/phpcode.txt
php://協(xié)議
php://協(xié)議的使用條件:
1. 不需要開(kāi)啟allow_url_fopen
2. php://input、 php://stdin、 php://memory 和 php://temp 需要開(kāi)啟allow_url_include。
php://filter 用于讀取源碼且在雙off的情況下也可以正常使用
allow_url_fopen :off/on (使用條件)
allow_url_include:off/on
Eg: http://127.0.0.1/cmd.php?file=php://filter/read=convert.base64-encode/resource=index.php
php://input 可以訪問(wèn)請(qǐng)求的原始數(shù)據(jù)的只讀流, 將post請(qǐng)求中的數(shù)據(jù)作為PHP代碼執(zhí)行。
allow_url_fopen :off/on
allow_url_include:on
Eg:http://127.0.0.1/cmd.php?file=php://input [POST DATA] <?php phpinfo()?>
以上內(nèi)容僅供參考!
推薦教程:PHP視頻教程
以上就是php偽協(xié)議是什么的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注風(fēng)君子博客其它相關(guān)文章!
總結(jié)
以上是生活随笔為你收集整理的php伪协议是什么(漏洞梳理篇之php伪协议)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python删除字符_Python之删除
- 下一篇: 电脑显卡怎么看好坏