PHP偽協議


file:// — 訪問本地文件系統
http:// — 訪問 HTTP(s) 網址
ftp:// — 訪問 FTP(s) URLs
php:// — 訪問各個輸入/輸出流(I/O streams)
zlib:// — 壓縮流
data:// — 數據(RFC 2397)
glob:// — 查找匹配的文件路徑模式
phar:// — PHP 歸檔
ssh2:// — Secure Shell 2
rar:// — RAR
ogg:// — 音頻流
expect:// — 處理交互式的流

常用php://

  1. php://input

    php://input代表可以訪問請求的原始數據,簡單來說POST請求的情況下,php://input可以獲取到post的數據。

    比較特殊的一點,enctype=”multipart/form-data” 的時候 php://input 是無效的。

  2. php://output

    php://output 是一個只寫的數據流, 允許你以 print 和 echo 一樣的方式 寫入到輸出緩沖區。

  3. php://filter

    php://filter 是一種元封裝器。結合include(),file_get_contents(),file_put_contents()使用,include()經常會造成任意文件讀取漏洞,而file_get_contents()和file_put_contents()這樣函數下,常常會構成getshell等更嚴重的漏洞。


    語法格式

    resource=<要過濾的數據流>   //這個參數是必須的。它指定了你要篩選過濾的數據流。
    read=<讀鏈的篩選列表>       //該參數可選。可以設定一個或多個過濾器名稱,以管道符(|)分隔。
    write=<寫鏈的篩選列表>      //該參數可選。可以設定一個或多個過濾器名稱,以管道符(|)分隔。
    <;兩個鏈的篩選列表>        //任何沒有以 read= 或 write= 作前綴 的篩選器列表會視情況應用於讀或寫鏈。
    
    php://filter/read=convert.base64-encode/resource=flag.php
                 or         
                 write      過濾器 
    

    • convert.*\

      convert.base64-encode & convert.base64-decode //base64 加解密

      https://www.php.net/manual/zh/filters.convert.php

    • string.*

      string.rot13

      string.toupper //大寫

      string.tolower //小寫

      string.strip_tags //返回給定的字符串 str 去除空字符、HTML 和 PHP 標記后的結果

      p神先用string.strip_tags去除代碼,后用convert.base64-decode還原webshell(webshell是base64編碼的,所以不會被去除)很好玩。

      php://filter/write=string.strip_tags|convert.base64-encode/resource=shell.php

      p神的文章在后面鏈接有


      https://www.php.net/manual/zh/filters.php



  4. data://

    data://text/plain;(base64,base64編碼后的字符串) 執行php代碼

  5. phar://

    zip壓縮包 phar://test.zip/test.txt 可執行test.txt里的代碼



參考連接

https://zhuanlan.zhihu.com/p/49206578

https://www.leavesongs.com/PENETRATION/php-filter-magic.html

https://lorexxar.cn/2016/09/14/php-wei/

https://www.smi1e.top/文件包含漏洞與php偽協議/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM