Author: Eduardo R. B. Marques, DCC/FCUP
Exercises marked with (C) will be covered in class, and exercises marked with (H) are left as homework.
Aim: experiment with DVWA to understand command injection vulnerabilities, and related input validation for each DVWA security level.
You may login with user name admin and password password.
Access the Command Injection page using the menu on the left. It will let you specify a IP adddress (e.g. 127.0.0.1) such that the DVWA server executes the ping command internally to that IP, and then reports the output of the ping command.
Exploit vulnerabilities by supplying malicious input that leads to ("injects") the execution of command
cat /etc/passwd
Scroll down the page and click on View Source to observe the code that is is executed on the server side. Analyze the code to understand the input validation mechanism (if any). You can also click on View Help for an explanation of the input validation mechanisms and vulnerability exploitation hints.
Change the DVWA Security Level , initially set to Low, and repeat step 4 for the Medium, High and finally the Impossible security levels.
Aim: observe issues detected through static code analysis using SonarCloud for the DVWA command injection example.
Open https://sonarcloud.io/dashboard?id=QSES_DVWA in your browser.
Access the Code tab, then browse the vulnerabilities/exec/ source folder → direct link.
Click on low.php, where 2 security vulnerabilities were detected, each corresponding to a call to shell_exec.
You will notice that command injection vulnerabilities are detected in low.php but not for all the remaning cases. The analysis only signals the cases where external input directly reaches the shell_exec call without any intervening input validation.
Aim: again using DVWA, understand SQL injection vulnerabilities and the related input validation for each DVWA security level.
Consider DVWA's SQL injection and Blind SQL injection pages, and:
Aim: use your PC to run DVWA (and other tools in the future) using Docker.
Run the DVWA Docker image using the following Docker command:
docker run --rm -it -p 9999:80 vulnerables/web-dvwa
The -p 9999:80 option indicates that port 80 on the DVWA container will be redirected to port 9999 on the host. You may use other values in place of 9999.
Open your browser and access http://127.0.0.1:9999.
Conduct a pen-test over DVWA, e.g.
python ./sqlmap.py \
-u "http://127.0.0.1:9999/vulnerabilities/sqli/id=2&Submit=Submit#" \
--cookie="PHPSESSID=. . . . .; security=low” \
-b --current-db --current-user
You must fill in the value of PHPSESSID above.
To find it, access the PHP Info page and
consult the PHP Variables section.
Aim: familiarize yourself with basic aspects of SonarCloud setup in integration with GitHub, again using DVWA as an example.
Aim: experiment with a real-world example of command injection.
See instructions here on how to run a Docker container that is vulnerable to ShellShock and exploit the vulnerability.