DVWA 黑客攻防演练(四)文件包含 File Inclusion

栏目: 服务器 · Apache · 发布时间: 6年前

内容简介:文件包含(file Inclusion)是一种很常见的攻击方式,主要是通过修改请求中变量从而访问了用户不应该访问的文件。还可以通过这个漏洞加载不属于本网站的文件等。下面一起来看看 DVWA 中的文件包含漏洞。原本也不知道是什么意思,然后尝试点击一下 File1 就显示 File1 的内容了。而且发现 url 变成了 http://192.168.31.166:5678/vulnerabilities/fi/?page=file1.phpHacker 就在浏览器中输入了 http://192.168.31.1

文件包含(file Inclusion)是一种很常见的攻击方式,主要是通过修改请求中变量从而访问了用户不应该访问的文件。还可以通过这个漏洞加载不属于本网站的文件等。下面一起来看看 DVWA 中的文件包含漏洞。

低级

DVWA 黑客攻防演练(四)文件包含 File Inclusion

原本也不知道是什么意思,然后尝试点击一下 File1 就显示 File1 的内容了。而且发现 url 变成了 http://192.168.31.166:5678/vulnerabilities/fi/?page=file1.php

DVWA 黑客攻防演练(四)文件包含 File Inclusion

Hacker 就在浏览器中输入了 http://192.168.31.166:5678/vulnerabilities/fi/?page=/etc/apache2/apache2.conf

代码如下

<?php
// The page we wish to display 
$file = $_GET['page'];
?>

觉得主要问题还是对文件路径没有验证,还能这样玩

  • 输入 /etc/passwd 能看到服务器的用户信息的
  • url 是 http://192.168.0.110:5678/vulnerabilities/fi/?page=http://www.baidu.com 直接显示百度主页

中级

<?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://192.168.0.110:5678/vulnerabilities/fi/?page=HTTP://www.baidu.com 比如输入的是全路径 http://192.168.0.110:5678/vulnerabilities/fi/?page=/etc/apache2/apache2.conf

高级

高级代码终于有输入验证了,只有文件名是有 file 开头的文件才能打开

<?php

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

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

?>

好像也没什么问题了, http://192.168.0.110:5678/vulnerabilities/fi/?page=/etc/apache2/apache2.conf 之类的也打不开了。

此时 Hacker 输入了 http://192.168.0.110:5678/vulnerabilities/fi/?page=file:///etc/apache2/apache2.conf 就完美绕过

或者输入了 http://192.168.31.166:5678/vulnerabilities/fi/?page=file4.php,就中奖了。

DVWA 黑客攻防演练(四)文件包含 File Inclusion

DVWA上根本没有列出此文件!这是个隐藏文件来的,这而这代码的漏洞就是能显示隐藏的文件!这与需求不符。

不可能

再看看不可能的代码

<?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;
}
?>

感觉有点滑稽。哈哈哈哈 这里的文件列表应该从读文件或者读数据库的方式获取比较好吧。这样不够优雅。


以上所述就是小编给大家介绍的《DVWA 黑客攻防演练(四)文件包含 File Inclusion》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Paradigms of Artificial Intelligence Programming

Paradigms of Artificial Intelligence Programming

Peter Norvig / Morgan Kaufmann / 1991-10-01 / USD 77.95

Paradigms of AI Programming is the first text to teach advanced Common Lisp techniques in the context of building major AI systems. By reconstructing authentic, complex AI programs using state-of-the-......一起来看看 《Paradigms of Artificial Intelligence Programming》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具