> 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/information-disclosure/source-code-disclosure-via-backup-files.md).

# 通过备份文件泄露源代码

通过备份文件泄露源代码，PortSwigger Web Security Academy 实验笔记，包括利用流程、载荷测试、Burp Suite 验证以及修复上下文。

### 通过备份文件泄露源代码

**实验描述**

该实验通过 **备份文件** 存储在一个隐藏目录中。/ 目标是识别并提交 **数据库密码**，它被硬编码在泄露的源代码中。

**操作阶段**

**内容发现**/ 使用 **Burp Suite** （功能“发现内容”），我们分析应用程序可访问的路径。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-39457c6536adb000caa7c922d609813a1604ded0%2Fimage%20(199).png?alt=media" alt=""><figcaption></figcaption></figure>

**敏感目录识别**/ 分析显示存在一个名为 **backup**.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2a1349c3cac4bf1a37533deb0bcc51374342d288%2Fimage%20(201).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cea45e8c3ed42ec6f3d6540af4503efed2569949%2Fimage%20(200).png?alt=media" alt=""><figcaption></figcaption></figure>

**访问备份文件**/ 在该目录中，一个扩展名为 `.bk` 的备份文件可访问。/ 它包含\*\*Java 代码\*\*的说明。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0ac705718ecabad6c255880bb91fa0d069dcaa93%2Fimage%20(202).png?alt=media" alt=""><figcaption></figcaption></figure>

**泄露代码分析**/ 该文件透露了一个 **PostgreSQL** 数据库的登录信息，凭据被硬编码。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1daa99c92705dcf3e95aa7050bbe51916d9da32f%2Fimage%20(203).png?alt=media" alt=""><figcaption></figcaption></figure>

```java
        ConnectionBuilder connectionBuilder = ConnectionBuilder.from(
                "org.postgresql.Driver",
                "postgresql",
                "localhost",
                5432,
                "postgres",
                "postgres",
                "eq77s9j4j4sa5a3m9iymzi9e2m8e68sj"
        ).withAutoCommit();
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/zh/web/information-disclosure/source-code-disclosure-via-backup-files.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
