Damn Vulnerable Web Application (DVWA) is a PHP/MySQL web application that is damn vulnerable.

Overview

DAMN VULNERABLE WEB APPLICATION

Damn Vulnerable Web Application (DVWA) is a PHP/MySQL web application that is damn vulnerable. Its main goal is to be an aid for security professionals to test their skills and tools in a legal environment, help web developers better understand the processes of securing web applications and to aid both students & teachers to learn about web application security in a controlled class room environment.

The aim of DVWA is to practice some of the most common web vulnerabilities, with various levels of difficulty, with a simple straightforward interface. Please note, there are both documented and undocumented vulnerabilities with this software. This is intentional. You are encouraged to try and discover as many issues as possible.


WARNING!

Damn Vulnerable Web Application is damn vulnerable! Do not upload it to your hosting provider's public html folder or any Internet facing servers, as they will be compromised. It is recommended using a virtual machine (such as VirtualBox or VMware), which is set to NAT networking mode. Inside a guest machine, you can download and install XAMPP for the web server and database.

Disclaimer

We do not take responsibility for the way in which any one uses this application (DVWA). We have made the purposes of the application clear and it should not be used maliciously. We have given warnings and taken measures to prevent users from installing DVWA on to live web servers. If your web server is compromised via an installation of DVWA, it is not our responsibility, it is the responsibility of the person/s who uploaded and installed it.


License

This file is part of Damn Vulnerable Web Application (DVWA).

Damn Vulnerable Web Application (DVWA) is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Damn Vulnerable Web Application (DVWA) is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Damn Vulnerable Web Application (DVWA). If not, see https://www.gnu.org/licenses/.


Internationalisation

This file is available in multiple languages:

If you would like to contribute a translation, please submit a PR. Note though, this does not mean just run it through Google Translate and send that in, those will be rejected.


Download

While there are various versions of DVWA around, the only supported version is the latest source from the official GitHub repository. You can either clone it from the repo:

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

Or download a ZIP of the files.


Installation

Please make sure your config/config.inc.php file exists. Only having a config.inc.php.dist will not be sufficient and you'll have to edit it to suit your environment and rename it to config.inc.php. Windows may hide the trailing extension.

Installation Videos

Windows + XAMPP

The easiest way to install DVWA is to download and install XAMPP if you do not already have a web server setup.

XAMPP is a very easy to install Apache Distribution for Linux, Solaris, Windows and Mac OS X. The package includes the Apache web server, MySQL, PHP, Perl, a FTP server and phpMyAdmin.

XAMPP can be downloaded from: https://www.apachefriends.org/en/xampp.html

Simply unzip dvwa.zip, place the unzipped files in your public html folder, then point your browser to: http://127.0.0.1/dvwa/setup.php

Linux Packages

If you are using a Debian based Linux distribution, you will need to install the following packages (or their equivalent):

apt-get -y install apache2 mariadb-server php php-mysqli php-gd libapache2-mod-php

The site will work with MySQL instead of MariaDB but we strongly recommend MariaDB as it works out of the box whereas you have to make changes to get MySQL to work correctly.

Database Setup

To set up the database, simply click on the Setup DVWA button in the main menu, then click on the Create / Reset Database button. This will create / reset the database for you with some data in.

If you receive an error while trying to create your database, make sure your database credentials are correct within ./config/config.inc.php. This differs from config.inc.php.dist, which is an example file.

The variables are set to the following by default:

$_DVWA[ 'db_server'] = '127.0.0.1';
$_DVWA[ 'db_port'] = '3306';
$_DVWA[ 'db_user' ] = 'dvwa';
$_DVWA[ 'db_password' ] = 'p@ssw0rd';
$_DVWA[ 'db_database' ] = 'dvwa';

Note, if you are using MariaDB rather than MySQL (MariaDB is default in Kali), then you can't use the database root user, you must create a new database user. To do this, connect to the database as the root user then use the following commands:

mysql> create database dvwa;
Query OK, 1 row affected (0.00 sec)

mysql> create user dvwa@localhost identified by 'p@ssw0rd';
Query OK, 0 rows affected (0.01 sec)

mysql> grant all on dvwa.* to dvwa@localhost;
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Other Configuration

Depending on your Operating System, as well as version of PHP, you may wish to alter the default configuration. The location of the files will be different on a per-machine basis.

Folder Permissions:

  • ./hackable/uploads/ - Needs to be writeable by the web service (for File Upload).
  • ./external/phpids/0.6/lib/IDS/tmp/phpids_log.txt - Needs to be writable by the web service (if you wish to use PHPIDS).

PHP configuration:

  • allow_url_include = on - Allows for Remote File Inclusions (RFI) [allow_url_include]
  • allow_url_fopen = on - Allows for Remote File Inclusions (RFI) [allow_url_fopen]
  • safe_mode = off - (If PHP <= v5.4) Allows for SQL Injection (SQLi) [safe_mode]
  • magic_quotes_gpc = off - (If PHP <= v5.4) Allows for SQL Injection (SQLi) [magic_quotes_gpc]
  • display_errors = off - (Optional) Hides PHP warning messages to make it less verbose [display_errors]

File: config/config.inc.php:

Default Credentials

Default username = admin

Default password = password

...can easily be brute forced ;)

Login URL: http://127.0.0.1/login.php

Note: This will be different if you installed DVWA into a different directory.


Docker Container

Please ensure you are using aufs due to previous MySQL issues. Run docker info to check your storage driver. If it isn't aufs, please change it as such. There are guides for each operating system on how to do that, but they're quite different so we won't cover that here.


Troubleshooting

These assume you are on a Debian based distro, such as Debian, Ubuntu and Kali. For other distros, follow along, but update the command where appropriate.

"Access denied" running setup

If you see the following when running the setup script it means the username or password in the config file do not match those configured on the database:

Database Error #1045: Access denied for user 'notdvwa'@'localhost' (using password: YES).

The error is telling you that you are using the username notdvwa.

The following error says you have pointed the config file at the wrong database.

SQL: Access denied for user 'dvwa'@'localhost' to database 'notdvwa'

It is saying that you are using the user dvwa and trying to connect to the database notdvwa.

The first thing to do is to double check what you think you put in the config file is what is actually there.

If it matches what you expect, the next thing to do is to check you can log in as the user on the command line. Assuming you have a database user of dvwa and a password of p@ssw0rd, run the following command:

mysql -u dvwa -pp@ssw0rd -D dvwa

Note: There is no space after the -p

If you see the following, the password is correct:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.3.22-MariaDB-0ubuntu0.19.10.1 Ubuntu 19.10

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 [dvwa]>

As you can connect on the command line, it is likely something wrong in the config file, double check that and then raise an issue if you still can't get things working.

If you see the following, the username or password you are using is wrong. Repeat the Database Setup steps and make sure you use the same username and password throughout the process.

ERROR 1045 (28000): Access denied for user 'dvwa'@'localhost' (using password: YES)

If you get the following, the user credentials are correct but the user does not have access to the database. Again, repeat the setup steps and check the database name you are using.

ERROR 1044 (42000): Access denied for user 'dvwa'@'localhost' to database 'dvwa'

The final error you could get is this:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

This is not an authentication issue but tells you that the database server is not running. Start it with the following

sudo service mysql start

Unknown authentication method

With the most recent versions of MySQL, PHP can no longer talk to the database in its default configuration. If you try to run the setup script and get the following message it means you have configuration.

Database Error #2054: The server requested authentication method unknown to the client.

You have two options, the easiest is to uninstall MySQL and install MariaDB. The following is the official guide from the MariaDB project:

https://mariadb.com/resources/blog/how-to-migrate-from-mysql-to-mariadb-on-linux-in-five-steps/

Alternatively, follow these steps:

  1. As root, edit the following file: /etc/mysql/mysql.conf.d/mysqld.cnf

  2. Under the line [mysqld], add the following: default-authentication-plugin=mysql_native_password

  3. Restart the database: sudo service mysql restart

  4. Check the authentication method for your database user:

    mysql> select Host,User, plugin from mysql.user where mysql.user.User = 'dvwa';
    +-----------+------------------+-----------------------+
    | Host      | User             | plugin                |
    +-----------+------------------+-----------------------+
    | localhost | dvwa             | caching_sha2_password |
    +-----------+------------------+-----------------------+
    1 rows in set (0.00 sec)
  5. You'll likely see caching_sha2_password. If you do, run the following command:

    mysql> ALTER USER dvwa@localhost IDENTIFIED WITH mysql_native_password BY 'p@ssw0rd';
  6. Re-running the check, you should now see mysql_native_password.

    mysql> select Host,User, plugin from mysql.user where mysql.user.User = 'dvwa';
    +-----------+------+-----------------------+
    | Host      | User | plugin                |
    +-----------+------+-----------------------+
    | localhost | dvwa | mysql_native_password |
    +-----------+------+-----------------------+
    1 row in set (0.00 sec)

After all that, the setup process should now work as normal.

If you want more information see the following page: https://www.php.net/manual/en/mysqli.requirements.php.

Database Error #2002: No such file or directory.

The database server is not running. In a Debian based distro this can be done with:

sudo service mysql start

Errors "MySQL server has gone away" and "Packets out of order"

There are a few reasons you could be getting these errors, but the most likely is the version of database server you are running is not compatible with the version of PHP.

This is most commonly found when you are running the latest version of MySQL as PHP and it do not get on well. Best advice, ditch MySQL and install MariaDB as this is not something we can support.

For more information, see:

https://www.ryadel.com/en/fix-mysql-server-gone-away-packets-order-similar-mysql-related-errors/

SQL Injection won't work on PHP v5.2.6.

PHP 5.x reached end of life in January 2019 so we would recommend running DVWA with a current 7.x version, if you must use 5.x...

If you are using PHP v5.2.6 or above, you will need to do the following in order for SQL injection and other vulnerabilities to work.

In .htaccess:

Replace:

<IfModule mod_php5.c>
    php_flag magic_quotes_gpc off
    #php_flag allow_url_fopen on
    #php_flag allow_url_include on
IfModule>

With:

<IfModule mod_php5.c>
    magic_quotes_gpc = Off
    allow_url_fopen = On
    allow_url_include = On
IfModule>

Command Injection won't work

Apache may not have high enough privileges to run commands on the web server. If you are running DVWA under Linux make sure you are logged in as root. Under Windows log in as Administrator.

Why can't the database connect on CentOS?

You may be running into problems with SELinux. Either disable SELinux or run this command to allow the web server to talk to the database:

setsebool -P httpd_can_network_connect_db 1

Anything else

For the latest troubleshooting information please read both open and closed tickets in the git repo:

https://github.com/digininja/DVWA/issues

Before submitting a ticket, please make sure you are running the latest version of the code from the repo. This is not the latest release, this is the latest code from the master branch.

If raising a ticket, please submit at least the following information:

  • Operating System
  • The last 5 lines from the web server error log directly after whatever error you are reporting occurs
  • If it is a database authentication problem, go through the steps above and screenshot each step. Submit these along with a screenshot of the section of the config file showing the database user and password.
  • A full description of what is going wrong, what you expect to happen, and what you have tried to do to fix it. "login broken" is no enough for us to understand your problem and to help fix it.

SQLite3 SQL Injection

Support for this is limited, before raising issues, please ensure you are prepared to work on debugging, do not simply claim "it does not work".

By default, SQLi and Blind SQLi are done against the MariaDB/MySQL server used by the site but it is possible to switch to do the SQLi testing against SQLite3 instead.

I am not going to cover how to get SQLite3 working with PHP, but it should be a simple case of installing the php-sqlite3 package and making sure it is enabled.

To make the switch, simply edit the config file and add or edit these lines:

$_DVWA["SQLI_DB"] = "sqlite";
$_DVWA["SQLITE_DB"] = "sqli.db";

By default it uses the file database/sqli.db, if you mess it up, simply copy database/sqli.db.dist over the top.

The challenges are exactly the same as for MySQL, they just run against SQLite3 instead.


Links

Homepage: https://dvwa.co.uk/

Project Home: https://github.com/digininja/DVWA

Created by the DVWA team

You might also like...
A framework for building rich, data-driven applications in PHP and MySQL

Xataface A framework for building rich, data-driven applications in PHP and MySQL License GPL Requirements PHP 5.2 or higher MySQL 5 or higher Install

LibreNMS is an auto-discovering PHP/MySQL/SNMP based network monitoring system

LibreNMS is an auto-discovering PHP/MySQL/SNMP based network monitoring which includes support for a wide range of network hardware and operating systems including Cisco, Linux, FreeBSD, Juniper, Brocade, Foundry, HP and many more.

Project of Simple Blog using: HTML, CSS, PHP, MYSQL, and BOOTSTRAP
Project of Simple Blog using: HTML, CSS, PHP, MYSQL, and BOOTSTRAP

Project-Stormwind Project of Simple Blog using: HTML, CSS, PHP, MYSQL, and BOOTSTRAP Functions : A personal blog about Blizzard and their work Main Th

Hotel Management System using MySQL, Php, Ajax, Jquery and HTML
Hotel Management System using MySQL, Php, Ajax, Jquery and HTML

Hotel-Management-System-Ajax-PHP-Mysql A hotel management system in which clients can perform operations such as booking a room and event. It is possi

Examination system using PHP and mysql

online-examination-systen-in-php Online Examination System Today Online Examination System has become a fast growing examination method because of its

Online-examination-System in PHP and Mysql using XAMPP server

online-examination-systen-in-php Online Examination System Today Online Examination System has become a fast growing examination method because of its

A MySQL-PHP based hotel reservation system
A MySQL-PHP based hotel reservation system

hotel-reservation-system A MySQL-PHP based hotel reservation system We have created a Hotel Reservation system, which can be used by the Hotel clients

Bolt is a simple CMS written in PHP. It is based on Silex and Symfony components, uses Twig and either SQLite, MySQL or PostgreSQL.

⚠️ Note - Not the latest version This is the repository for Bolt 3. Please know that Bolt 5 has been released. If you are starting a new project, plea

Desarrollo de una aplicación muy sencilla, desarrollada con HTML - Bootstrap - PHP - (PDO)- Mysql. (Login - Registro - Create Read Update Delete)
Desarrollo de una aplicación muy sencilla, desarrollada con HTML - Bootstrap - PHP - (PDO)- Mysql. (Login - Registro - Create Read Update Delete)

php-mysql-aplicacion-web Desarrollo de una aplicación muy sencilla, desarrollada con HTML - Bootstrap - PHP - (PDO)- Mysql. (Login - Registro - Create

Comments
  • Chinese language support

    Chinese language support

    Thanks for the DVWA! It help me to learn and it's really good for beginers. Expecting Chinese language support, as many Chinese students use it with poor English.

    Need Chinese language support For:

    1. README.md
    2. Contents in pages, including help Pages.
    3. Code comments.

    Planning to implement it and Pull. Is it encouraged ?

    opened by inVains 13
  • Kubernetes support for DVMA

    Kubernetes support for DVMA

    There was not support for running DVMA on containerized environments in the project added support for building a container and chart to run it on Kubernetes. This is using my docker registry soheileizadi but I assume you will change it to a community registry and crate Github action to build it. It is also working with older 1.9 version of the project not the latest. You can review build and deployment guide in README

    opened by seizadi 24
  • Added a bad CAPTCHA vulnerability

    Added a bad CAPTCHA vulnerability

    This added vulnerability is aimed at playing with image recognition/OCR to guess/identify bad CAPTCHA codes. As opposite to "Insecure CAPTCHA", there's no vulnerability on the validation logic but instead the CAPTCHA is generated using weak configurations.

    It also has the advantage that can be used in isolated environments where the DVWA doesn't have Internet access and ReCaptcha can't be used. The library used is https://github.com/claviska/simple-php-captcha (MIT license).

    Let me know if you think it would be a good addition or if it need some aspect to be worked on. Otherwise I left it here for if someone else has a requirement similar to this one.

    opened by martingalloar 1
Releases(2.0.1)
  • 2.0.1(Sep 13, 2020)

  • 2.0(Aug 5, 2020)

  • v1.9(Oct 5, 2015)

    • Added a dedicated objective (or "flag") for file include. (@g0tmi1k)
    • Added a warning to any module that requires a certain configuration. (@g0tmi1k)
    • Added comments to all source code that would be visible via DVWA modules. (@g0tmi1k)
    • Added CSRF token to pre-auth forms (login/setup/security pages). (@g0tmi1k + @Shinkurt)
    • Added HttpOnly cookie flag on impossible levels. (@g0tmi1k)
    • Added more detail to the documentation. (@g0tmi1k)
    • Added PDO to all impossible levels requiring MySQL. (@g0tmi1k)
    • Added PHPIDS options into the config file. (@g0tmi1k)
    • Added system check to setup. (@g0tmi1k)
    • Added various information to all help pages for every module. (@g0tmi1k)
    • Changed brute force medium to be harder due to sleep. (@g0tmi1k)
    • Changed file include landing page + added 3x example pages. (@g0tmi1k)
    • Changed file include medium to be harder due to more filters. (@g0tmi1k)
    • Changed HTTP REFERER check for medium level CSRF. (@g0tmi1k)
    • Changed input box for medium level with SQLi + SQLi Blind. (@g0tmi1k)
    • Changed SQLi + SQLi Blind to be $_POST rather than $_GET. (@g0tmi1k)
    • Changed SQLi Blind to be a real example of the vulnerability. (@g0tmi1k)
    • Fixed brute force and file upload impossible levels, as they were vulnerable. (@g0tmi1k + @Shinkurt)
    • Fixed bug with file fnclude page not loading. (@g0tmi1k)
    • Fixed CAPTCHA bug to read URL parameters on impossible. (@g0tmi1k)
    • Fixed CAPTCHA bug where the form wouldn't be visible. (@g0tmi1k)
    • Fixed CAPTCHA bug where the URL parameters were not being used for low + medium. (@g0tmi1k)
    • Fixed CSRF medium level bug when not on localhost. (@g0tmi1k)
    • Fixed setup bug with custom URL path. (@g0tmi1k)
    • Removed PostgreSQL DB support. (@g0tmi1k)
    • Renamed 'Command Execution' to 'Command Injection'. (@g0tmi1k)
    • Renamed 'high' level to 'impossible' and created new vectors for 'high'. (@g0tmi1k)
    • Updated README and documentation. (@g0tmi1k)
    • Various code cleanups in the core PHP files+CSS. (@g0tmi1k)
    • Various setup improvements (e.g. redirection + limited menu links). (@g0tmi1k)
    Source code(tar.gz)
    Source code(zip)
Owner
Robin Wood
Hacker, coder, climber, runner. Co-founder of the SteelCon conference.
Robin Wood
PHP, MySQL and JS based web chat application

About The Project Chat Application coded in PHP, CSS3 and JS. This is just a project to learn and improve understanding on certain topics. This is not

Neil 8 Apr 18, 2022
Open Source Voucher Management System is a web application for manage voucher. used PHP with Laravel Framework and use MySQL for Database.

Voucher Management System is a web application for manage voucher. You can create and manage your voucher. Voucher Management System is used PHP with Laravel Framework and use MySQL for Database.

Artha Nugraha Jonar 34 Sep 17, 2022
Web application for the health record of the Hemal's Thalasseamia Patients. Technologies PHP, JavaScript, HTML, W3.CSS and MySQL

Web application for the health record of the Hemal's Thalasseamia Patients. Technologies PHP, JavaScript, HTML, W3.CSS and MySQL

Thilrash Gowzul Ameen 1 Dec 15, 2021
Um chat web feito com HTML, CSS, SASS, JS, PHP e MYSQL

ChatWeb Tecnologias Front-end usadas: Pré processador CSS: Linguagem de programação usada: Projeto hospedado no: Editor de texto usado: Objetivos: Par

Adriel Cavalcante 4 Oct 27, 2022
A Responsive Web Chat App Using Php , MySql and JavaScript

Web-Chat-App A Responsive Web Chat App Using Php , MySql and JavaScript Prerequisites XAMPP [Php Runtime Environment] click HERE To Download XAMPP Set

Luttapi 4 Jul 12, 2022
Mibew Messenger - open-source live support application written in PHP and MySQL

Mibew Messenger is an open-source live support application written in PHP and MySQL. It enables one-on-one chat assistance in real-time directly from your website.

Mibew Messenger 443 Dec 13, 2022
DomainMOD is an open source application written in PHP & MySQL used to manage your domains and other internet assets in a central location

DomainMOD is an open source application written in PHP & MySQL used to manage your domains and other internet assets in a central location. DomainMOD also includes a Data Warehouse framework that allows you to import your web server data so that you can view, export, and report on your live data.

DomainMOD 349 Jan 8, 2023
A web interface for MySQL and MariaDB

phpMyAdmin A web interface for MySQL and MariaDB. https://www.phpmyadmin.net/ Code status Download You can get the newest release at https://www.phpmy

phpMyAdmin 6.3k Jan 2, 2023
Shoutit is a PHP powered shoutbox which uses mySQL to store shouts

This is a very basic PHP/MySQL application. built to prove my usuage of basic php + MySQL. It is very easy to use, has error checking, and very fast. Users can post shouts along with their names & comment.

Roman Hossain Shaon 10 Oct 10, 2022
Bulit PHP Twitter Clone IN OOP style and using MYSQL Database.

Bulit PHP Twitter Clone IN OOP style and using MYSQL Database. AJAX and Jquery for requests without reloading like Follow/unfollow, like, Search users, Show popups like comment , User lists, etc.

Amin 47 Dec 3, 2022