Home

Awesome

Dockerized DVWA

Install | Start | Stop | Usage | Features | Configuration | Capture the flag | Tools | FAQ | Sec Tools | License

Tag build nightly License

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.

https://github.com/digininja/DVWA

DVWA has an official Docker image available at Dockerhub, however by the time of writing this image did not receive any recent updates.

If you need an always up-to-date version or arm64 images, you can use the here provided Docker Compose setup. The image is built every night against the latest master branch of the DVWA and pushed to Dockehub.

Additionally this Docker image comes with a few CTF challenges that require you to completely compromise the machine and reach root access. Read here for details.

Available Architectures: amd64, arm64

:whale: Available Docker image versions

Docker

Rolling releaess

The following Docker image tags are rolling releases and are built and updated every night.

nightly

Docker TagGit RefPHPAvailable Architectures
latestmasterlatestamd64, arm64
php-8.1master8.1amd64, arm64
php-8.0master8.0amd64, arm64
php-7.4master7.4amd64, arm64
php-7.3master7.3amd64, arm64
php-7.2master7.2amd64, arm64
php-7.1master7.1amd64, arm64
php-7.0master7.0amd64, arm64
php-5.6master5.6amd64, arm64

:tada: Install

Clone repository from GitHub:

git clone https://github.com/cytopia/docker-dvwa

:zap: Start

Inside the cloned repository (docker-dvwa/ directory):

make start

:no_entry_sign: Stop

Inside the cloned repository (docker-dvwa/ directory):

make stop

:computer: Usage

After running make start you can access DVWA in your browser via:

:star: Features

:wrench: Configuration

This setup allows you to configure a few settings via the .env file.

VariableDefaultSettings
PHP_VERSION8.1PHP version to run DVWA (5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 or 8.1)
LISTEN_PORT8000Local port for the web server to listen on
RECAPTCHA_PRIV_KEYRequired to make the captcha module work. (See FAQ section below)
RECAPTCHA_PUB_KEYRequired to make the captcha module work. (See FAQ section below)
PHP_DISPLAY_ERRORS0Set to 1 to display PHP errors (if you want a really easy mode)

The following .env file variables are default settings and their values can also be changed from within the web interface:

VariableDefaultSettings
SECURITY_LEVELmediumAdjust the difficulty level for the challenges<sup>[1]</sup><br/> (low, medium, high or impossible)
PHPIDS_ENABLED0Set to 1 to enable PHP WAF/IDS<sup>[2]</sup> (off by default)
PHPIDS_VERBOSE0Set to 1 to display WAF/IDS reasons for blocked requests

<sup>[1]</sup> For the SECURITY_LEVEL changes to take effect, you will have to clear your cookies. Alternatively change it in the web interface.<br/> <sup>[2]</sup> WAF (Web Application Firewall) / IDS (Intrusion Detection System)

:pirate_flag: Capture the flag

Additionally to the default DVWA features, this flavour also contains a few flags that can be captured via various means (including local privilege escalation).

How to play?

Let me know on :bird: Twitter if you've solved them and how easy/difficult they were.

:gear: Tools

The DVWA Docker image contains the following tools assisting you in solving the challenges and also allowing you to gain access via reverse shells.

:bulb: FAQ

<details><summary><strong>Q:</strong> I want to proxy through <a href="https://portswigger.net/burp">BurpSuite</a>, but it does not work on <code>localhost</code> or <code>127.0.0.1</code>.</summary> <p><br/> Browsers ususally bypass <code>localhost</code> or <code>127.0.0.1</code> for proxy traffic. One solution is to add an alternative hostname to <code>/etc/hosts</code> and access the application through that.<br/><br/> <code>/etc/hosts</code>:
127.0.0.1  dvwa

Then use <a href="http://dvwa:8000">http://dvwa:8000</a> in your browser.

</p> </details> <details><summary><strong>Q:</strong> How can I run DVWA with a different PHP version?</summary> <p><br/> The here provided Docker images are built against all common PHP versions and you can easily select your version of choice in the <a href="https://github.com/cytopia/docker-dvwa/blob/master/.env-example#L1">.env</a> prior startup. To do so, just uncomment the version of choice and restart the Docker Compose stack:<br/> <code>.env</code>
# PHP VERSION
# -----------
# Uncomment one of the PHP versions you want to use for DVWA
#PHP_VERSION=5.6
#PHP_VERSION=7.0
#PHP_VERSION=7.1
#PHP_VERSION=7.2
#PHP_VERSION=7.3
#PHP_VERSION=7.4
#PHP_VERSION=8.0
PHP_VERSION=8.1
</p> </details> <details><summary><strong>Q:</strong> How can I reset the database and start fresh?</summary> <p><br/> The database uses a Docker volume and you can simply remove it via:<br/>
# the command below will stop all running container,
# remove their state and delete the MySQL docker volume.
make reset
</p> </details> <details><summary><strong>Q:</strong> How can I view Apache access or error log files?</summary> <p><br/> Log files are piped to <i>stderr</i> from the Docker container and you can view them via:<br/>
make logs
</p> </details> <details><summary><strong>Q:</strong> How can I get a shell on the web server container?</summary> <p><br/> <strong><img class="emoji" alt="warning" height="20" width="20" src="https://github.githubassets.com/images/icons/emoji/unicode/26a0.png"> Note:</strong> Doing so is basically cheating, you are supposed to gain access to the machine via exploitation.<br/><br/> You can enter the running web server container as root via:<br/>
make enter
</p> </details> <details><summary><strong>Q:</strong> How do I setup the reCAPTCHA key?</summary> <p><br/> Go to <a href="https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a> and generate your captcha as shown below:<br/> <ul> <li>Ensure to choose <code>reCAPTCHA v2</code></li> <li>Ensure to add <i>all</i> domains you plan on using</li> </ul> <a href="doc/captcha-01.png"><img src="doc/captcha-01-thumb.png" /></a> <ul> <li>Add <code>SITE KEY</code> to the <code>RECAPTCHA_PUB_KEY</code> variable in your <code>.env</code> file</li> <li>Add <code>SECRET KEY</code> to the <code>RECAPTCHA_PRIV_KEY</code> variable in your <code>.env</code> file</li> </ul> <a href="doc/captcha-02.png"><img src="doc/captcha-02-thumb.png" /></a> </p> </details> <details><summary><strong>Q:</strong> How can I access/view the MySQL database?</summary> <p><br/> <strong><img class="emoji" alt="warning" height="20" width="20" src="https://github.githubassets.com/images/icons/emoji/unicode/26a0.png"> Note:</strong> Doing so is basically cheating, but if you really need to, you can do so.<br/><br/> This Docker image bundles <a href="https://www.adminer.org/">Adminer</a> (a PHP web interace similar to phpMyAdmin) and you can access it here: <a href="http://localhost:8000/adminer.php">http://localhost:8000/adminer.php</a><br/> <ul> <li><strong>Server:</strong> <code>dvwa_db</code></li> <li><strong>Username:</strong> <code>root</code></li> <li><strong>Password:</strong> <code>rootpass</code></li> </ul> <img src="doc/adminer.png" /> </p> </details> <details><summary><strong>Q:</strong> How can I build the Docker image locally?</summary> <p><br/> To build or rebuild the Docker image against new updates in <a href="https://github.com/digininja/DVWA">DVWA master branch</a>, simply do the following:<br/>
# This is builing the image for the default PHP version
make rebuild

# This is building the image with PHP 8.0
make rebuild VERSION=8.0

# Rebuild PHP 8.1 for arm64 platform
make rebuild VERSION=8.0 ARCH=linux/arm64
</p> </details>

:rocket: Deployment

AWS

Terraform

This repository ships a Terraform module to deploy DVWA on AWS.

cd aws/
cp terraform.tfvars-example terraform.tfvars

terraform init
terraform apply

For more information see Terraform module.

Kubernetes

Kubernetes

This repository ships Kubernetes resources to deploy DVWA on K8s or minikube.

cd k8s/
kubectl apply -f .

For more information see k8s.

:lock: cytopia sec tools

Below is a list of sec tools and docs I am maintaining, which might come in handy working on DVWA.

NameCategoryLanguageDescription
offsecDocumentationMarkdownOffsec checklist, tools and examples
header-fuzzEnumerationBashFuzz HTTP headers
smtp-user-enumEnumerationPython 2+3SMTP users enumerator
urlbusterEnumerationPython 2+3Mutable web directory fuzzer
pwncatPivotingPython 2+3Cross-platform netcat on steroids
badcharsReverse EngineeringPython 2+3Badchar generator
fuzzaReverse EngineeringPython 2+3TCP fuzzing tool

:page_facing_up: License

MIT License

Copyright (c) 2021 cytopia