Ir al contenido

Installation Documentation: DVWA (Damn Vulnerable Web App)

Environment: Ubuntu Server Technology: LAMP Stack (Linux, Apache, MySQL, PHP)

0views

Environment: Ubuntu Server Technology: LAMP Stack (Linux, Apache, MySQL, PHP)

First, we will ensure that the web server, the database, and PHP are installed with the necessary extensions.

Ventana de terminal
sudo apt update
sudo apt install apache2 mariadb-server mariadb-client php php-mysqli php-gd php-mbstring php-xml git composer -y
# Nota: Aunque instalamos el paquete mariadb-server, en este entorno actúa como MySQL nativo.

We will clone the official repository into the web directory and assign permissions to the Apache user (www-data).

Ventana de terminal
cd /var/www/html/
sudo git clone [https://github.com/digininja/DVWA.git](https://github.com/digininja/DVWA.git) dvwa
sudo chown -R www-data:www-data /var/www/html/dvwa/
sudo chmod -R 755 /var/www/html/dvwa/

To avoid errors in the API modules, we will install the Composer dependencies:

Ventana de terminal
cd /var/www/html/dvwa/vulnerabilities/api
sudo composer install
sudo chown -R www-data:www-data vendor/

We will create the database and the user manually.

Accessing MySQL:

Ventana de terminal
sudo mysql

Execute SQL commands:

CREATE DATABASE dvwa;
CREATE USER 'dvwa_user'@'localhost' IDENTIFIED BY 'password123!';
GRANT ALL PRIVILEGES ON dvwa.* TO 'dvwa_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

We will copy the example file and edit the credentials.

Ventana de terminal
cd /var/www/html/dvwa/config/
sudo cp config.inc.php.dist config.inc.php
sudo nano config.inc.php

We will make the following changes:

  • db_user: ‘dvwa_user’
  • db_password: ‘password123!’
  • db_database: ‘dvwa’

To make the vulnerabilities work (LFI/RFI), we will edit php.ini:

Ventana de terminal
sudo nano /etc/php/8.3/apache2/php.ini

We will make the following changes:

  • allow_url_fopen = On
  • allow_url_include = On

DVWA is optimized for older MariaDB. To make it work on modern MySQL, we must correct the IF NOT EXISTS syntax that causes an error when creating columns.

File: /var/www/html/dvwa/dvwa/includes/DBMS/MySQL.phpAction: We will remove the phrase IF NOT EXISTS on lines ~68 and ~173.

Corrected code (example):

// Antes (Error)
$alter_users = "ALTER TABLE users ADD COLUMN IF NOT EXISTS role VARCHAR(20) DEFAULT 'user';";
// Después (Corregido)
$alter_users = "ALTER TABLE users ADD COLUMN role VARCHAR(20) DEFAULT 'user';";

We will restart Apache:

Ventana de terminal
sudo systemctl restart apache2

We will access http://TU_IP/dvwa/setup.php via browser and click “Create / Reset Database”.