# Cross-Site Scripting
A web application is vulnerable to XSS if it uses unsanitized user input. XSS is possible in Javascript, VBScript, Flash and CSS.
## Stored XSS
This is where a malicious string originates from the websites database. Such as (stored in a db)
* User profiles
* Chats and comments
* Part of link
* Blind xss is stored inside the app but effects are only visible by proxy, [xsshunter](https://xsshunter.com/).
### Examples
* Sanity test by changing DOM content
```
```
* Cookie stealing
```javascript
```
* Navigte to `/logs` and take sid
* Open nc port and collect cookies
```javascript
```
## Reflected XSS
In a reflected cross-site scripting attack, the malicious payload is part of the victims request to the website. The website includes this payload in response back to the user. To summarise, an attacker needs to trick a victim into clicking a URL to execute their malicious payload.
* URL parameters inside GET queries
* File paths
### Usage
As script inside parameter
```sh
http://example.com/search?keyword=
```
* Show server IP
```
http://example.com/reflected?keyword=
```
* Session stealing, base64 encoded
```javascript
```
* open netcat binder to catch the http queries
## DOM based XSS
With DOM-Based xss, an attackers payload will only be executed when the vulnerable Javascript code is either loaded or interacted with. It goes through a Javascript function like so:
```javascript
var keyword = document.querySelector('#search')
keyword.innerHTML =
```
### Usage
* Find the sub-object inside the document
```javascript
test" onmouseover="alert('YO!')"
```
* Show cookie
```
test" onmouseover="alert(document.cookie)"
```
## Bypass Filters
* `script>alert("1");</script>
```
* `alert()` sanitizing
```javascript
0\"autofocus/onfocus=alert(1)-->"-confirm(3)-"
```
or
```javascript
0\"autofocus/onfocus=alert(1)-->