0
点赞
收藏
分享

微信扫一扫

Security ❀ File Inclusion 文件包含


文章目录

  • ​​准备工作​​
  • ​​1、low​​
  • ​​2、medium​​
  • ​​3、high​​
  • ​​4、impossible​​

准备工作

修改PHP文件中allow_url_include=Off为allow_url_include=On,开启PHP允许URL包含;
​​​D:\phpstudy_pro\Extensions\php\php7.3.4nts\php.ini​​​Security ❀ File Inclusion 文件包含_php

查看三个file文件
Security ❀ File Inclusion 文件包含_本地文件_02
Security ❀ File Inclusion 文件包含_嵌套_03
Security ❀ File Inclusion 文件包含_开发语言_04

1、low

源码解析:

<?php

// The page we wish to display
$file = $_GET[ 'page' ];

?>

由于源码没有限制跳转,可以使用…/…/…/进行路径穿越;
跳转目标为下面的页面;
Security ❀ File Inclusion 文件包含_php_05

可以通过URL看到此页面路径为:http://127.0.0.1/dvwa/phpinfo.php,而我们所处的位置为http://127.0.0.1/dvwa/vulnerabilities/fi/?page=include.php,因此需要向上移动两个目录进行访问;
跳转URL:http://127.0.0.1/dvwa/vulnerabilities/fi/?page=…/…/phpinfo.php
Security ❀ File Inclusion 文件包含_嵌套_06

2、medium

源码解析:

<?php

// The page we wish to display
$file = $_GET[ 'page' ];

// Input validation 输入验证
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\"" ), "", $file );

?>

源码过滤了​​http:// https:// ../ ..\​​​四组跳转符号,可以采取嵌套,如 ​​htthttp://p:// hhttp://ttp:// httphttps://s://​​​等多组前缀进行跳转;
创建访问目标用于验证跳转是否成功;
Security ❀ File Inclusion 文件包含_开发语言_07

文件内容展示:
Security ❀ File Inclusion 文件包含_开发语言_08

跳转URL:​​http://127.0.0.1/dvwa/vulnerabilities/fi/?page=hthttp://tp://127.0.0.1/1.txt​​​Security ❀ File Inclusion 文件包含_开发语言_09

3、high

源码解析:

<?php

// The page we wish to display
$file = $_GET[ 'page' ];

// Input validation
if( !fnmatch( "file*", $file ) && $file != "include.php" ) {
// This isn't the page we want!
echo "ERROR: File not found!";
exit;
}

?>

源码限制访问内容由file开头,因此可以使用file://进行代替http://进行跳转,使用file://可以进行本地文件跳转;
跳转URL:​​​http://127.0.0.1/dvwa/vulnerabilities/fi/?page=file://d://phpstudy_pro/WWW/1.txt​​​Security ❀ File Inclusion 文件包含_php_10

4、impossible

源码解析:只允许通过include.php和三个file文件,限制其他操作

<?php

// The page we wish to display
$file = $_GET[ 'page' ];

// Only allow include.php or file{1..3}.php
if( $file != "include.php" && $file != "file1.php" && $file != "file2.php" && $file != "file3.php" ) {
// This isn't the page we want!
echo "ERROR: File not found!";
exit;
}

?>


举报

相关推荐

0 条评论