> For the complete documentation index, see [llms.txt](https://sarpers-organization.gitbook.io/ctftricks/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sarpers-organization.gitbook.io/ctftricks/_chapter-intro-10/file-transfer/python-http-server/trick-0300.md).

# Transfer Files via Python HTTP Server

***

In the directory on the source machine where the file(s) you want to transfer are located, start the Python HTTP server:

```bash
python3 -m http.server 8000
```

This will serve the contents of the current directory over HTTP on port 8000 (or any other specified port). You can also specify a different directory to serve using the `--directory` option:

```bash
python3 -m http.server 8000 --directory /path/to/share
```

This command serves files from `/path/to/share` instead of the current directory.

On the target machine, you can then download the file using a command-line tool like `wget` or `curl`, or simply access `http://<source_ip>:8000/` in a web browser.

```bash
wget http://<source_ip>:8000/filename
# Or with curl
curl http://<source_ip>:8000/filename -o filename
```

**Important Security Note:** This module is not suitable for production use. It only implements basic security checks. It serves all files in the directory it's run from (and subdirectories). Anyone who can reach the server can download *any* file in that directory or its subdirectories, which is a common vulnerability known as Directory Traversal. Therefore, use this server only on trusted networks and for temporary purposes.
