Module 6: Cross-Site Scripting Exploitation and Case Study

Cross-Site Scripting - Exploitation

Accessing The Sandbox

Start your VPN, the VM, and add the VM's IP to your hosts file.

Moving the Payload to an External Resource

Serving xss.js

kali@kali:~$ mkdir xss

kali@kali:~$ cd xss

kali@kali:~/xss$ echo "alert(1)" > xss.js

kali@kali:~/xss$ python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
Script payload on Search Application
Script payload with Alert
Script Payload loaded on victim

HTTP Server Logs

Stealing Session Cookies

Updating xss.js to exfiltrate the user's cookie

Script Payload

Empty data parameter in log

Rendered payload in victim browser

Cookie in HTTP log (Use Non-HttpOnly Cookie selected)

No Cookie in HTTP Log (Use HTTPOnly Cookie selected)

Stealing Local Secrets

Local storage is accessed by using the window.localStorage property, while session storage can be accessed with window.sessionStorage.

Exfiltrating storage

Rendering with data in local storage

Contents of the localStorage

Keylogging

Keylogging payload in xss.js

Key Logging Search Application

Stealing Saved Passwords

Modifyin xss.js to steal passwords

Saved creds on page

Saved credentials exfiltrated

Saved creds on page with opacity

Phishing Users

Search Application Login
Inspecting the Form

Payload to Phish with Login Form

Phishing the victim user

User Credentials in HTTP Logs

Creating xss.js as a login page due to no login page present

Exploiting innerHTML to execute our script

Case Study: Shopizer Reflected XSS

Getting Started

Start VPN, VMs, and add IP to hosts file. Register an account.

Discovering the Vulnerability

Shopizer URL containing an interesting value
Searching the page source for c:2

The loadCategoryProducts() function

Source code containing our canary value
The canary value including the single quote inside the JavaScript code

JavaScript error message due to our single quote

The application responding with an HTTP 404 when expanding our payload
Replacing the semicolons with plus marks

Loading Remote Scripts

Site map tool in Burp Suite
Listing of the JavaScript files loaded by Shopizer

Creating a simple JS file

Using Burp Suite Decoder to Base64-encode our jQuery.getScript() payload

Base64-encoded payload

JavaScript alert window showing an error
JavaScript Console Displaying Request Error
JavaScript Network Tab Displaying Request Error

Updated Base64-encoded payload

JavaScript alert windows showing "It worked!"

Exploiting Reflected XSS

My Account page in Shopizer
Edit Shipping information form

Sample POST request to add or update an address

Updating a shipping address without including a "customerId"

Sample fetch() payload

Serving the JS file

Loading the exploit URL
Using Burp Suite to verify the POST request was sent
Verifying the address change on the My Account Page
Loading payload in XSS Sandbox

HTTP Log Showing xss.js was Loaded

Rendering payload in XSS Sandbox
Viewing the Victim's Address

Last updated