A hands-on home lab that deploys a vulnerable web app (DVWA) on Ubuntu, attacks it from Kali Linux, and shows how SafeLine WAF detects and mitigates attacks (SQL injection, HTTP flood, custom deny rules, and more).
- Deploy DVWA (Damn Vulnerable Web App) on an Ubuntu VM.
- Launch a basic SQL injection attack from Kali Linux.
- Demonstrate SafeLine WAF protecting the application.
- Explore WAF features: HTTP flood defense, auth gateway, custom deny rules.
- Host machine with β₯ 8 GB RAM and β₯ 50 GB free disk.
- VirtualBox installed (latest).
- Internet connection on host and VMs.
- Basic Linux command-line knowledge.
- Optional: ability to install packages and manage services on Ubuntu.
[ Kali VM ] βββ
ββ (LAN via bridged adapter) ββ [ Host Network Router / Switch ]
[ Ubuntu VM (DVWA + SafeLine WAF) ] βββ
- Kali: attacker machine (Kali Linux).
- Ubuntu: DVWA (Apache/PHP/MySQL) and SafeLine WAF (reverse proxy).
- All VMs use Bridged Networking so they share the host network and can resolve via /etc/hosts or DNS.
NOTE: run commands on the appropriate VM (Kali or Ubuntu). Use
sudowhere needed.
-
Download & install VirtualBox: https://www.virtualbox.org/wiki/Downloads
-
Create two VMs:
- Kali Linux (Name:
KaliLinux) β 2+ GB RAM, 20 GB disk. - Ubuntu Server (Name:
UbuntuServer) β 2+ GB RAM, 20+ GB disk.
- Kali Linux (Name:
-
In each VM: set Network Adapter β Bridged Adapter (choose host NIC).
-
(Optional) Install Guest Additions in each VM for better UX.
# Update & essentials
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y net-tools git opensslGet the VM IP:
ifconfig # or `ip a`Install Apache, PHP, and MySQL:
sudo apt-get install -y apache2 php php-mysql mysql-server
sudo mysql_secure_installation # follow prompts, set strong root passwordcd /var/www/html
sudo git clone https://github.com/digininja/DVWA.git
sudo chown -R www-data:www-data DVWA
sudo chmod -R 755 DVWAEdit DVWA config (if needed):
/var/www/html/DVWA/config/config.inc.php β update DB settings:
$DBMS = 'MySQL';
$db = 'dvwa';
$user = 'dvwa_user';
$pass = 'p@ssw0rd';
$host = 'localhost';Create DB & user:
sudo mysql -u root -p
CREATE DATABASE dvwa;
CREATE USER 'dvwa_user'@'localhost' IDENTIFIED BY 'p@ssw0rd';
GRANT ALL ON dvwa.* TO 'dvwa_user'@'localhost';
FLUSH PRIVILEGES;
exitInitialize DVWA in browser: http://<Ubuntu-IP>/DVWA/setup.php β Create/Reset Database
Edit Apache ports:
sudo nano /etc/apache2/ports.conf
# change Listen 80 β Listen 8080Edit virtual host:
sudo nano /etc/apache2/sites-available/000-default.conf
# change <VirtualHost *:80> to <VirtualHost *:8080>
sudo systemctl restart apache2Access DVWA at: http://<Ubuntu-IP>:8080/DVWA
sudo mysql -u root -p
USE dvwa;
CREATE TABLE test_users (
id INT NOT NULL AUTO_INCREMENT,
username VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL,
PRIMARY KEY (id)
);
INSERT INTO test_users (username, password) VALUES
('alice','alice123'),('bob','bob123'),('admin','admin123');
exit/etc/hosts on both Ubuntu and Kali:
<Ubuntu-IP> dvwa.local
Now access: http://dvwa.local:8080/DVWA
(Optional) Set up BIND9 if you want a local DNS server β see docs for details.
sudo mkdir -p /etc/ssl/dvwa
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/ssl/dvwa/dvwa.key \
-out /etc/ssl/dvwa/dvwa.crt(Answer prompt values or use -subj to automate.)
Follow SafeLine instructions and the video link. The lab used the provider script.
Automatic install (example):
bash -c "$(curl -fsSLk https://waf.chaitin.com/release/latest/manager.sh)" -- --en- Follow on-screen prompts.
- The installer will provide admin username/password and console URL (often port
9443).
Import SSL certificate into SafeLine In the SafeLine web UI β SSL Certificates: import:
/etc/ssl/dvwa/dvwa.crt(certificate)/etc/ssl/dvwa/dvwa.key(private key)
Onboard application:
- Domain:
www.dvwa.local(or chosen domain) - Backend (reverse proxy):
http://<Ubuntu-IP>:8080 - Remove port 80 from the virtual host; leave 443 only (WAF handles HTTPS).
- Attach the uploaded SSL certificate.
- Open browser on Kali β
http://dvwa.local:8080/DVWA(or via WAFhttps://www.dvwa.local/). - Login DVWA (default:
admin/password) β set Security to low. - Go to SQL Injection module and test payloads such as:
admin' OR '1'='1
' OR 1=1 --
- Observe the vulnerability results in DVWA.
- SafeLine should detect and block injection attempts (if WAF policy set to blocking).
- Check WAF logs and dashboards for blocked events and rules triggered.
- If blocking is enabled, you will see block pages or error responses.
- HTTP Flood defense: enable DoS mitigation and set RPS thresholds. Test with
ab,siege, or custom scripts from Kali. - Auth Sign-In: enable the WAF authentication gateway to prompt visitors before accessing DVWA.
- Custom Deny Rule: block Kali IP (e.g.,
192.168.x.x) by creating a policy to block matching source IPs.