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

# Source Code Disclosure via Backup Files

Source Code Disclosure via Backup Files notes for PortSwigger Web Security Academy labs, including exploitation workflow, payload testing, Burp Suite validation, and remediation context.

### Source Code Disclosure via Backup Files

**Description of lab**

This lab exposes the source code of the application through **backup files** stored in a hidden directory. / The objective is to identify and submit the **password of the database**, which is hardcoded in the disclosed source code.

**Operation stages**

**Discovery of content**/ Using **Burp Suite** (function Discover Content ), we analyze the accessible paths of the application.

<figure><img src="https://131707722-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>

**Identification of a sensitive directory**/ Analysis reveals the existence of a hidden directory named **backup**.

<figure><img src="https://131707722-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://131707722-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>

**Access to backup files**/ In this directory, a backup file with an extension `.bk` is accessible. / It contains \*\* Java code\*\* explained.

<figure><img src="https://131707722-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>

**Disclosed code analysis**/ The file reveals login information to a **PostgreSQL** database, with hardcoded credentials.

<figure><img src="https://131707722-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/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.
