Cross Site Scripting Library and Unrestricted File Upload
Contents
Background Information
- Damn Vulnerable Web App(DVWA) is a PHP/MySQL web application that is damn vulnerable. Its main goals are 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 aid teachers/students to teach/learn web application security in a class room environment.
- Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected into the otherwise benign and trusted web sites. Cross-site scripting (XSS) attacks occur when an attacker uses a web application to send malicious code, generally in the form of a browser side script, to a different end user. Flaws that allow these attacks to succeed are quite widespread and occur anywhere a web application uses input from a user in the output it generates without validating or encoding it. An attacker can use XSS to send a malicious script to an unsuspecting user. The end user's browser has no way to know that the script should not be trusted, and will execute the script. Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by your browser and used with that site. These scripts can even rewrite the content of the HTML page.
- Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected into the otherwise benign and trusted web sites. Cross-site scripting (XSS) attacks occur when an attacker uses a web application to send malicious code, generally in the form of a browser side script, to a different end user. Flaws that allow these attacks to succeed are quite widespread and occur anywhere a web application uses input from a user in the output it generates without validating or encoding it. An attacker can use XSS to send a malicious script to an unsuspecting user. The end user's browser has no way to know that the script should not be trusted, and will execute the script. Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by your browser and used with that site. These scripts can even rewrite the content of the HTML page. The XSS payload is stored in the database. The XSS is permanent until the database is reset or the payload is manually deleted.
- Uploaded files represent a significant risk to applications. The first step in many attacks is to get some code to the system to be attacked. Then the attack only needs to find a way to get the code executed. Using a file upload helps the attacker accomplish the first step. The consequences of unrestricted file upload can vary, including complete system takeover, an overloaded file system, forwarding attacks to backend systems, and simple defacement.
Login and Set Security Setup
- Login to Damn Vulnerable Web App:
- Start up FireFox
- Place http://127.0.0.1/dvwa/login.php in the address bar
- Input Username: admin and Password: password
- Set DVWA Security Level:
- Click on DVWA Security, in the left hand menu.
- Select “low” and click Submit
XSS Stored Basic Exploit Test
- Instructions:
- Select “XSS Stored” from the left navigation menu.
- Name: Test 1
- Message: <script>alert(“This is a XSS Exploit Test”)</script>
- Click Sign Guestbookt
- Notes:
- Notice that the JavaScript alert we just created is now displayed.
- Every Time a user comes to this forum, this XSS exploit will be displayed.
- This exploit can be easily modified to capture cookie/session information for future Man-in-Middle attacks.
XSS Stored IFRAME Exploit Test
- The First Step is to reset the DataBase
- Instructions:
- Select “Setup” from the left menu navigation.
- Click on the Create / Reset Database Button.
- Select “XSS Stored” from the left navigation menu.
- Input Name: Test 2
- Input Message: <iframe src=“http://www.cnn.com”></iframe>
- Click Sign Guestbook
- Notes:
- We need to reset the database otherwise the each XSS exploit will appear for each example.
- Notice that CNN is displayed under “Test 2's” Message. This is a powerful exploit because a user could use SET to create Malicious cloned website and place in here.
XSS Stored COOKIE Exploit Test
* The First Step is to reset the DataBase
- Instructions:
- Select “Setup” from the left menu navigation.
- Click on the Create / Reset Database Button.
- Select “XSS Stored” from the left navigation menu.
- Input Name: Test 3
- Input Message: <script>alert(document.cookie)</script>
- Click Sign Guestbook
- Click OK
- Notes:
- We need to reset the database otherwise the each XSS exploit will appear for each example.
- An attacker could easily modify this XSS script to send the cookie to a remote location instead of displaying it.
Unrestricted File Upload
- Instructions:
- Select “Upload” from the left navigation menu.
- Click Browse
- Choose a PHP file from root
- Click Upload button
- Reset the Database
- Set security level to high
- click Browse and choose The same PHP file
- click on view source bottom of the page, on the write
- compare the source codes
References
Panel title
Percipit Mnesarchum
Molestie Phaedrum Luptatum
constituam Habeo adipisci Inani
zril Forensibus sea Habeo
adipisci Minimum corrumpit Regione
suscipit Has et partem Percipit
Mnesarchum Molestie Phaedrum
Luptatum constituam Habeo
adipisci Inani zril Vel
nisl albucius Habeo adipisci Minimum
corrumpit Regione suscipit Percipit
maiestatis Regione suscipit Percipit
maiestatis
Subtitle