SKF write-ups
Search…
Python - XSS-DOM

Running the app Python3

First, make sure python3 and pip are installed on your host machine. After installation, we go to the folder of the lab we want to practise "i.e /skf-labs/XSS/, /skf-labs/jwt-secret/ " and run the following commands:
1
$ pip3 install -r requirements.txt
Copied!
1
$ python3 <labname>
Copied!
Now that the app is running let's go hacking!

Reconnaissance

Step 1

The application shows an input field box were we can try our injections. Lets first inject a normal test string and see how our input is used in the application.
As you can see below the input is reflected in the DOM.
Inspecting the source code of the application we can see that this application will take the user input and use it in the application where id="dom".
1
function submit() {
2
value = $("#input").val();
3
console.log(value);
4
$("#dom").html(value);
5
}
Copied!

Exploitation

Step 1

Now we have seen where the user input is being reflected in the application we will have to look what dangerous HTML characters are not properly escaped so we can build our XSS payload. So for our first check we use the following string as an input:
1
foobar"></
Copied!
As you can see the application did not encode or blacklisted any of the dangerous HTML characters. Now lets try the XSS payload to see if this also is reflected back withouth any escaping or blacklist filtering.
1
foobar<script>alert(1337)</script>
Copied!
In Firefox we can see the XSS alert pop-up and we have successfully performed the XSS attack.

Additional sources

Please refer to the OWASP testing guide for a full complete description about cross site scripting!
https://owasp.org/www-community/attacks/XSS-DOM/
owasp.org