Understanding Reflected XSS
In this step, we will introduce the concept of Reflected XSS and demonstrate its implementation using the DVWA (Damn Vulnerable Web Application) platform.
Reflected XSS, also known as Non-Persistent XSS, is a type of XSS vulnerability where the malicious script is executed by the victim's web browser due to a vulnerability in the web application's handling of user input. Unlike Stored XSS, where the malicious script is stored on the server, Reflected XSS relies on the attacker delivering a malicious script through a crafted URL or web page request.
The DVWA platform is a intentionally vulnerable web application designed for security testing and learning purposes. It provides a safe environment to practice various web vulnerabilities, including XSS.
To begin, follow these steps:
-
Launch the DVWA virtual machine by executing the following command in your terminal:
sudo virsh start Metasploitable2
-
Open a web browser and navigate to http://192.168.122.102
to access the DVWA login page.
-
Log in with the default credentials (username: admin
, password: password
).
-
In the DVWA main menu, set the security level to "Low" by navigating to the "DVWA Security" section.
-
Go to the "XSS (Reflected)" module under the "Vulnerability" section.
-
In the input field, enter the following JavaScript code:
<script>
alert("Hello, Reflected XSS!");
</script>
-
Click the "Submit" button.
You will notice that the script is executed, and an alert box pops up with the message "Hello, Reflected XSS!". This is because the application does not sanitize the user input before reflecting it back to the browser.
To understand the underlying mechanism, you can view the source code of the page by clicking the "View Source" button. You will notice that the application echoes the user input directly without any validation or sanitization.