> For the complete documentation index, see [llms.txt](https://riteshs4hu.gitbook.io/infosec-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://riteshs4hu.gitbook.io/infosec-notes/internal-and-external-network-sec/privilege-escalation/file-transfer-method/ftp-server.md).

# FTP Server

### FTP Server (Python - pyftpdlib)

```python
# ftp_server.py

from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

def create_ftp_server(host, port, username, password, root_dir):
    authorizer = DummyAuthorizer()
    authorizer.add_user(username, password, root_dir, perm="elradfmw")

    handler = FTPHandler
    handler.authorizer = authorizer
    handler.banner = "Welcome to My FTP Server"

    server = FTPServer((host, port), handler)
    return server

if __name__ == "__main__":
    host = "{host-ip}"
    port = 21
    username = "anonymous"
    password = "anonymous"
    root_dir = "."

    server = create_ftp_server(host, port, username, password, root_dir)
    print(f"FTP server started on {host}:{port} - Press Ctrl+C to stop.")
    server.serve_forever()
```

#### ✅ Start Server

```bash
sudo python3 ftp_server.py
```
