【靶场搭建】-01- 在kali上搭建DVWA靶机

1.DVWA靶机

DVWA(Damn Vulnerable Web Application)是使用PHP+Mysql编写的web安全测试框架,主要用于安全人员在一个合法的环境中测试技能和工具。

2.下载DVWA

从GitHub上将DVWA的源码clone到kali上

git clone https://github.com/digininja/DVWA.git

下载完成后并解压,修改DVWA文件加的操作权限

chmod 777 -R DVWA/

启动apach2和mysql服务

┌──(root㉿kali)-[~/DVWA]
└─# service apache2 start
                                                                             
┌──(root㉿kali)-[~/DVWA]
└─# service mysql start  
                                                                             
┌──(root㉿kali)-[~/DVWA]
└─# netstat -ltnup | grep 3306
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      7388/mariadbd       
                                                                             
┌──(root㉿kali)-[~/DVWA]
└─# netstat -ltnup | grep 80  
tcp6       0      0 :::80                   :::*                    LISTEN      7185/apache2

进入MySQL数据库,并创建DVWA数据库

┌──(root㉿kali)-[~/DVWA]
└─# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 31
Server version: 10.11.6-MariaDB-1 Debian n/a

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
# 创建DVWA数据库
MariaDB [(none)]> create database dvwa;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| dvwa               |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.006 sec)
# 对数据库进行远程访问授权
# all:所有权限
# *.*:所有库下的所有表
# dvwa:新建的数据库用户名
# 127.0.0.1:允许的主机,此处就是本地地址
# “1qaz@WSX”:用户密码
MariaDB [(none)]> grant all privileges on *.* to dvwa@127.0.0.1 identified by "1qaz@WSX";
Query OK, 0 rows affected (0.018 sec)
# 设置完成后退出数据库
MariaDB [(none)]> exit;
Bye

修改DVWA的配置,首先我们先查看下DVWA的目录结构:

-rwxrwxrwx  1 root root  2883  6月13日 10:24 about.php
-rwxrwxrwx  1 root root  7134  6月13日 10:24 CHANGELOG.md
-rwxrwxrwx  1 root root   629  6月13日 10:24 compose.yml
drwxrwxrwx  2 root root  4096  6月13日 10:24 config
-rwxrwxrwx  1 root root 32485  6月13日 10:24 COPYING.txt
drwxrwxrwx  2 root root  4096  6月13日 10:24 database
-rwxrwxrwx  1 root root   807  6月13日 10:24 Dockerfile
drwxrwxrwx  3 root root  4096  6月13日 10:24 docs
drwxrwxrwx  6 root root  4096  6月13日 10:24 dvwa
drwxrwxrwx  3 root root  4096  6月13日 10:24 external
-rwxrwxrwx  1 root root  1406  6月13日 10:24 favicon.ico
drwxrwxrwx  5 root root  4096  6月13日 10:24 hackable
-rwxrwxrwx  1 root root  3678  6月13日 10:24 index.php
-rwxrwxrwx  1 root root  2053  6月13日 10:24 instructions.php
-rwxrwxrwx  1 root root  4064  6月13日 10:24 login.php
-rwxrwxrwx  1 root root   405  6月13日 10:24 logout.php
-rwxrwxrwx  1 root root   188  6月13日 10:24 phpinfo.php
-rwxrwxrwx  1 root root   154  6月13日 10:24 php.ini
-rwxrwxrwx  1 root root 25027  6月13日 10:24 README.ar.md
-rwxrwxrwx  1 root root 21777  6月13日 10:24 README.es.md
-rwxrwxrwx  1 root root 30612  6月13日 10:24 README.fa.md
-rwxrwxrwx  1 root root 20674  6月13日 10:24 README.fr.md
-rwxrwxrwx  1 root root 26188  6月13日 10:24 README.id.md
-rwxrwxrwx  1 root root 32492  6月13日 10:24 README.ko.md
-rwxrwxrwx  1 root root 29223  6月13日 10:24 README.md
-rwxrwxrwx  1 root root 21239  6月13日 10:24 README.pt.md
-rwxrwxrwx  1 root root 19838  6月13日 10:24 README.tr.md
-rwxrwxrwx  1 root root 17394  6月13日 10:24 README.zh.md
-rwxrwxrwx  1 root root    25  6月13日 10:24 robots.txt
-rwxrwxrwx  1 root root   151  6月13日 10:24 SECURITY.md
-rwxrwxrwx  1 root root  3142  6月13日 10:24 security.php
-rwxrwxrwx  1 root root   151  6月13日 10:24 security.txt
-rwxrwxrwx  1 root root  3686  6月13日 10:24 setup.php
drwxrwxrwx  2 root root  4096  6月13日 10:24 tests
drwxrwxrwx 18 root root  4096  6月13日 10:24 vulnerabilities

可以发现,DVWA包含多个目录,常用的目录为config和vulnerabilities

config目录,顾名思义存放的是DVWA的配置文件,

vulnerabilities目录存放的是DVWA包含的漏洞代码。

进入config目录,将config.inc.php.dist文件复制一份备份,然后进行配置

cp config.inc.php.dist config.inc.php
# 配置 config.inc.php
vim config.inc.php
# 修改以下配置
$_DVWA[ 'db_server' ]   = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ]     = 'dvwa';
$_DVWA[ 'db_password' ] = '1qaz@WSX';
$_DVWA[ 'db_port']      = '3306';
# 保存配置
# 重启apache

将DVWA文件夹移动到/var/www/html

mv DVWA/ /var/www/html

3.验证DVWA

浏览器中输入:http://127.0.0.1/DVWA/setup.php

进入DVWA安装检查:

在这里插入图片描述
提示我们需要打开allow_url_fopen和allow_url_include
在这里插入图片描述

allow_url_fopen用于激活URL地址形式的fopen封装,使其可以访问URL对象文件,allow_url_include则用于激活包含URL地址并将其作为文件处理的功能。

修改php.ini文件,进入/etc/php/8.2/apache2目录下

vim php.ini
# 找到allow_url_fopen和allow_url_include
allow_url_fopen = On
allow_url_include = On
# 保存后重启apache

接下来点击Create/Reset Database按钮
成功进入登陆页面:
在这里插入图片描述

默认用户名密码是:admin/password

在这里插入图片描述

那么我们就成功搭建好了DVWA靶机了。

  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值