Linux File Transfer Without Common Tools
Not every Linux host has wget, curl, nc, or scp available. Restricted environments, minimal containers, and hardened installs strip these out. This page covers transfer methods built from what is almost always present: bash, Python, Perl, and the filesystem itself.
This works in both directions — getting files onto a target and getting files off it.
Serving Files from Your Attacker Machine
Before covering transfer methods, the simplest way to serve files is Python's built-in HTTP server. Run this on your attacker machine in the directory containing your files:
Then fetch from the target using any available method below.
Bash /dev/tcp
No tools at all — just bash. Works for both uploading and downloading over TCP.
Download a file from your attacker machine:
Upload a file to a netcat listener on your attacker machine:
/dev/tcp is a bash built-in — it does not spawn any process and leaves no binary in the filesystem.
Python HTTP Download
If Python is present, this is the most reliable single-line download:
Python HTTP Upload
Serve a file from the target back to your machine using Python's HTTP server in a writable directory, then fetch it:
Then on your attacker machine:
Alternatively, use Python to POST the file directly:
Receive with a simple netcat listener or a Python HTTP server with upload support.
Download
If LWP is not available, fall back to raw sockets:
Common on web servers where PHP is the only available interpreter:
Base64 Over the Terminal
When there is no network path at all — only a command injection that returns output, or a session where you can only read stdout — encode the file and copy-paste it out.
On the target:
Copy the output from your terminal, then decode on your attacker machine:
For large files, split first to keep chunks manageable:
This is slow but works with zero network tooling required.
SCP and SFTP When SSH Is Available
If SSH credentials or keys are available and the target can reach your attacker machine:
Both are covered in more depth under the SSH service data exfiltration page.
Checking What Is Available
Before picking a method, run a quick check:
Work from the top of the list downward. bash with /dev/tcp and python3 cover the vast majority of cases on modern Linux systems.
References
-
Linux man page Reference for /dev/tcp and /dev/udp pseudo-device support in bash.
-
Python 3 urllib.requestdocs.python.org/3/library/urllib.request.html (opens in new tab)
Python documentation Reference for urlretrieve and Request usage in Python 3 one-liners.
Was this helpful?
Your feedback helps improve this page.