Linux 部署DVWA靶场

Linux 部署DVWA靶场

DVWA是一款开源的网络安全漏洞实践平台,专为安全学习者设计。它涵盖了XXS、SQL注入、文件上传、文件包含、CSRF和暴力破解等多种安全漏洞环境,每个漏洞都有从简单到复杂的多个难度级别。

环境部署

安装httpd及其相关的组件

yum install -y httpd httpd-devel

image-20240423081704105

安装php及其相关组件

yum -y install php php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mysql

image-20240423081750200

安装mariadb数据库

yum install -y mariadb mariadb-server mariadb-libs mariadb-devel

image-20240423081936926

启动服务并设置自启动

systemctl start httpd
systemctl start mariadb
systemctl enable httpd
systemctl enable mariadb

打开防火墙

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

数据库初始化设置

mysql_secure_installation
Enter current password for root (enter for none):  # 刚安装密码为空,直接Enter
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y  #设置root密码
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y  #是否移除匿名用户
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y  #是否禁止使用root用户进行远程连接数据库
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y  #是否移除测试数据库
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y  #是否重新分配权限
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

测试环境是否安装成功

在浏览器中使用ip进行访问

image-20240423082839560

出现该页面表示安装成功

安装DVWA

DVWA项目github地址:

我这里下载的是中文版

下载后将压缩包上传至 /var/www/html 下

image-20240423083634319

进行解压并重命名文件夹

unzip DVWA-Chinese-main.zip
mv DVWA-Chinese-main DVWA

image-20240423083922340

进入DVWA-master/config/目录下,编辑config.inc.php文件

vim config.inc.php

配置如下

$_DVWA[ 'db_server' ]   = 'localhost';  # 将127.0.0.1修改为localhost
$_DVWA[ 'db_database' ] = 'dvwa';  # 数据库名称
$_DVWA[ 'db_user' ]     = 'root';  # 数据库账号
$_DVWA[ 'db_password' ] = 'root';  # 数据库密码
$_DVWA[ 'db_port'] = '3306';

修改 ./DVWA/hackable/uploads/ 文件夹权限

chmod 777 /var/www/html/DVWA/hackable/uploads/

编辑php配置文件php.ini该文件一般是在/etc/php.ini路径

vim /etc/php.ini

allow_url_include = Off 修改为 allow_url_include = On (大概在815行)

重启apache服务

systemctl restart httpd

通过ip/DVWA进行访问(我直接点击创建数据库了,没来得及截图,盗了一张)

image-20240423085533610

点击创建/重置数据库,底部会显示

image-20240423085653883

点击 login,进入登录页面

image-20240423085340961

posted @ 2024-07-22 14:17  测试小罡  阅读(13)  评论(0编辑  收藏  举报