# XSS DOM-Based

## XSS - DOM-Based

Go to login page form <https://127.0.0.1/index.php?page=login.php>

and log in using login bypass or inserting password.

Go to a page vulnerable to XSS stored like as: <https://127.0.0.1/index.php?page=add-to-your-blog.php>

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F1bIfm4aKQNx6k1yClffJ%2Fimage.png?alt=media&#x26;token=2f98aaa5-b323-46a6-8673-8f784981025a" alt=""><figcaption></figcaption></figure>

in this two field will inject our payload:

```javascript
element.innerHTML='... <img src=1 onerror=alert(document.cookie)> ...'
```

the image 1 does not exist, so the alert will be triggered, the command will be injected into DOM and execute on the page:&#x20;

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F0dDS2to5fGYGybIQ0SZM%2Fimage.png?alt=media&#x26;token=0e1c784f-589d-49a6-8bba-b1567983f7d9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2Fs6bC3v9Ji9czRpSccJpi%2Fimage.png?alt=media&#x26;token=72c43d0d-ebd5-484d-b99f-984df510d2fc" alt=""><figcaption></figcaption></figure>

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FtTcr3qZTjY66RH62hNkU%2Fimage.png?alt=media&#x26;token=7568e05a-4053-4e3f-999e-56bf26ff3aeb" alt=""><figcaption></figcaption></figure>
