githubEdit

Testing for XSS

XSS Types

Type
Description

Stored (Persistent)

Input stored in DB, displayed to all users (most critical)

Reflected (Non-Persistent)

Input reflected in response (e.g., search, error messages)

DOM-based

Processed client-side via JavaScript, never reaches server


Test Payloads

Basic Test

<script>alert(window.origin)</script>

Alternatives (if alert blocked)

<plaintext>
<script>print()</script>
<img src=x onerror=alert(1)>

DOM XSS (when script tags blocked)

<img src="" onerror=alert(window.origin)>

XSS Discovery Tools


Reflected XSS Exploitation

  1. Find reflected parameter (check Network tab for GET/POST)

  2. Inject payload in URL parameter

  3. Send malicious URL to victim:


DOM XSS - Source & Sink

Common Sources (user input)

Dangerous Sinks (vulnerable functions)


Stored XSS

Key Logger

Chat Room XSS

  • Start a netcat listener on your attack box

  • Take this XSS payload and paste it in the chat room and submit:

  • Note: Send the payload and then open the listener

Stored XSS Payloads

  • Stored XSS pop up to display your cookies, good for a POC

  • Adding HTML to a website

  • Deface website title. You will need inspect element and find the name of the element you want to change. thm-title is the element name in this example.

DOM-Based XSS

Internal Network Scanner


Website Defacing

Change Background

Change Title

Replace Page Content

Remove Element


XSS Phishing

Inject Login Form

Comment Out Remaining HTML


Start Listener


Blind XSS Detection

Remote Script Loading (per field)

Blind XSS Payloads


Common Injection Contexts

Context
Payload

Inside <script>

';alert(1)// or ";alert(1)//

HTML attribute

" onmouseover=alert(1)

HTML tag

<img src=x onerror=alert(1)>

URL parameter

javascript:alert(1)

Event handler

'-alert(1)-'


Bypass Techniques

Case Variation

Encoding

No Parentheses

No Quotes


Filter Bypass Payloads

Last updated