Practice library / Penetration testing, first steps
Lab · Easy · 45 minutes
File Transfers
Move files between machines using HTTP, FTP, SCP, SMB, and base64 encoding.
On this page 9 sections
Post-exploitation needs a way to move tooling onto a target and results back off, often through the one port a defender still allows. A missing wget, a blocked outbound port or a hardened Windows host each force a different method. Here you serve files over HTTP, copy over SSH with scp and rsync, share through SMB and encode a payload with base64 when only text passes.
What You'll Learn
- Serve a file over HTTP and download it with
curlandwget - Copy files over SSH with
scp,sftpandrsync - Move a file between Linux and Windows with an SMB share
- Send a small file through a text-only channel with
base64 - Prove each transfer with a SHA-256 hash
- Find the log lines that each method leaves on the server
Every system administrator moves files between machines: a patch to a server, a log file to an analyst, a config backup to a vault. Servers often have no GUI and few tools, so you must know more than one way. This lab teaches four methods and the check that works for all of them: a hash. In the last step you read the logs, so you also learn what a defender sees.
Prerequisites
Finish the Reverse Shells lab first. You must be comfortable with two machines and a network address between them. For a raw TCP transfer with nc, continue with Netcat Fundamentals.
Build the target
KaliRange hosts no targets, no virtual machines and no lab files. Run this lab on your own machines; the names and 10.0.0.x addresses below are the example addresses of this lab. Replace them with your own.
| Name | Role | Address |
|---|---|---|
kali | Admin workstation, the source of the files | 10.0.0.5 |
target | Linux server with SSH on port 22 | 10.0.0.20 |
win10 | Optional Windows machine of the lab | 10.0.0.30 |
Tools on kali: python3, curl, wget, scp, sftp, rsync, smbclient, impacket-smbserver and base64. The win10 machine is only for the Windows commands. You can do every step with target alone.
Build these from free, legal parts: a Kali Linux virtual machine as kali, a plain Debian or Ubuntu virtual machine with sshd enabled as target, and, if you want the Windows commands too, an evaluation copy of Windows from the Microsoft Evaluation Center (180 days) as win10. Run all three on your own computer, on an isolated virtual network. Take a snapshot of each virtual machine before Step 1.
Use only machines you own or have written permission to test. On a real network you need written permission for each transfer, and you must not move data you do not own. Do not use these methods to take data out of a system you do not manage.
Make a test file on kali. All steps use it.
mkdir -p ~/transfer && cd ~/transfer
printf 'KaliRange transfer test\nline 2\nline 3\n' > report.txt
head -c 20000 /dev/urandom > backup.bin
sha256sum report.txt backup.bin | tee SHA256SUMSExample output:
8b1f0d6e5c3a2f4e9a77b0c1d2e3f40516273849a0b1c2d3e4f5061728394a5 report.txt
c41d9a7e2b6f08153d4e7a9b0c2f5e681a3d7b9c4e0f2a6b8d1c3e5f7092a4b6 backup.binThe values on your machine are different. backup.bin is random, so its hash changes each time. Keep the file SHA256SUMS.
Step 1: Serve a file over HTTP
Download a file with curl and wget
HTTP is the most common way to fetch a file. The sender starts a web server in one directory. The receiver downloads from it. Almost every host has curl or wget.
On kali, start a web server in the directory.
cd ~/transfer
python3 -m http.server 8000 --bind 10.0.0.5Example output:
Serving HTTP on 10.0.0.5 port 8000 (http://10.0.0.5:8000/) ...This server shows every file in the directory to every host that can reach the port. Run it in a directory that holds only the files you want to send. Stop it with Ctrl+C when you finish.
Open a second terminal on kali. Log in to target with ssh user@10.0.0.20, then download the files.
mkdir -p ~/incoming && cd ~/incoming
curl -O http://10.0.0.5:8000/report.txt
wget http://10.0.0.5:8000/backup.binExample output:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 37 100 37 0 0 18500 0 --:--:-- --:--:-- --:--:-- 18500
--2026-11-19 10:14:07-- http://10.0.0.5:8000/backup.bin
Connecting to 10.0.0.5:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20000 (20K) [application/octet-stream]
Saving to: 'backup.bin'
backup.bin 100%[===================>] 19.53K --.-KB/s in 0s
2026-11-19 10:14:07 (214 MB/s) - 'backup.bin' saved [20000/20000]Check that the files are the same. Copy SHA256SUMS in the same way, then compare.
curl -O http://10.0.0.5:8000/SHA256SUMS
sha256sum -c SHA256SUMSExample output:
report.txt: OK
backup.bin: OKOK on both lines means no byte changed. A line FAILED means the copy is damaged: download it again.
Look at the web server window on kali. It wrote one line for each request.
10.0.0.20 - - [19/Nov/2026 10:14:06] "GET /report.txt HTTP/1.1" 200 -
10.0.0.20 - - [19/Nov/2026 10:14:07] "GET /backup.bin HTTP/1.1" 200 -On the Windows machine win10, use PowerShell. Windows 10 and later also include curl.exe.
Invoke-WebRequest -Uri http://10.0.0.5:8000/report.txt -OutFile report.txt
curl.exe -O http://10.0.0.5:8000/backup.bin
Get-FileHash report.txt -Algorithm SHA256Stop the web server with Ctrl+C.
Step 2: Copy files over SSH
Use scp, sftp and rsync
SSH encrypts the transfer and checks the identity of the server. If sshd runs on the target, you need no other service. This is the preferred method for administration.
Upload a file from kali to target with scp. Port 22 is the default; -P sets another port.
cd ~/transfer
scp report.txt user@10.0.0.20:/tmp/report.txtExample output:
user@10.0.0.20's password:
report.txt 100% 37 52.1KB/s 00:00Download a file the other way. The source is the remote path.
scp user@10.0.0.20:/etc/hostname ./hostname.target
cat hostname.targetExample output:
hostname.target 100% 7 9.8KB/s 00:00
targetUse sftp when you want to list directories and pick files by hand.
sftp user@10.0.0.20sftp> ls /tmp
sftp> put backup.bin /tmp/backup.bin
sftp> get /etc/hostname
sftp> byeUse rsync for large folders or for a transfer that can stop. It sends only the changed parts and can continue after an error.
rsync -avz --progress ~/transfer/ user@10.0.0.20:/tmp/transfer/Example output:
sending incremental file list
./
SHA256SUMS
backup.bin
20,000 100% 9.54MB/s 0:00:00 (xfr#2, to-chk=0/4)
report.txt
sent 20,451 bytes received 96 bytes 13,698.00 bytes/sec
total size is 20,168 speedup is 0.98Check the hash on target.
ssh user@10.0.0.20 'cd /tmp/transfer && sha256sum -c SHA256SUMS'Example output:
report.txt: OK
backup.bin: OKStep 3: Share files over SMB
Move files between Linux and Windows
SMB is the file-sharing protocol of Windows. Windows machines open an SMB path as a normal folder, so you need no extra tool on them. On Linux, smbclient is the client.
Start a temporary share on kali. The tool impacket-smbserver is part of the Impacket package in Kali. The option -smb2support turns on SMB 2, which current Windows requires.
cd ~/transfer
sudo impacket-smbserver labshare . -smb2support -username labuser -password 'Lab-Pass-123'Example output:
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies
[*] Config file parsed
[*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0
[*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0
[*] Config file parsedThe user name and password are lab values. Always set a password; do not offer an open share. The share name is labshare and it points to the current directory.
From a Linux client, such as target, list the share and get a file with smbclient.
cd ~/incoming
smbclient //10.0.0.5/labshare -U labuser%'Lab-Pass-123' -c 'ls; get report.txt'Example output:
. D 0 Thu Nov 19 10:22:41 2026
report.txt A 37 Thu Nov 19 10:09:12 2026
backup.bin A 20000 Thu Nov 19 10:09:12 2026
SHA256SUMS A 132 Thu Nov 19 10:09:13 2026
20000 blocks of size 1024. 20000 blocks available
getting file \\report.txt of size 37 as report.txt (36.1 KiloBytes/sec) (average 36.1 KiloBytes/sec)From win10, map the share and copy a file with the commands of cmd.exe.
net use Z: \\10.0.0.5\labshare /user:labuser Lab-Pass-123
copy Z:\backup.bin C:\Temp\backup.bin
net use Z: /deleteExample output:
The command completed successfully.
1 file(s) copied.
Z: was deleted successfully.To upload from Windows to kali, copy in the other direction: copy C:\Temp\notes.txt Z:\. Stop impacket-smbserver with Ctrl+C. On kali, the server prints each login and file open, which Step 5 uses.
Step 4: Send a file as text with base64
Move a small file through a text-only channel
Sometimes you have only a terminal: a serial console, a web console of a cloud server, or a chat window. You cannot send binary data there, but you can send text. base64 changes any file into plain letters and digits, and back. The text is 33 percent longer than the file, so use this only for small files.
On kali, encode the file into one line. The option -w0 turns off line wrapping.
base64 -w0 report.txt; echoExample output:
S2FsaVJhbmdlIHRyYW5zZmVyIHRlc3QKbGluZSAyCmxpbmUgMwo=Copy the line. On target, paste it into the decoder and write the file.
echo 'S2FsaVJhbmdlIHRyYW5zZmVyIHRlc3QKbGluZSAyCmxpbmUgMwo=' | base64 -d > ~/incoming/report.b64.txt
cat ~/incoming/report.b64.txt
sha256sum ~/incoming/report.b64.txtExample output:
KaliRange transfer test
line 2
line 3
8b1f0d6e5c3a2f4e9a77b0c1d2e3f40516273849a0b1c2d3e4f5061728394a5 /home/user/incoming/report.b64.txtCompare the hash with the first line of SHA256SUMS on kali. The two must be equal. For a longer text, send the hash too: the text can break when a terminal changes a character.
Windows has the same function in two tools. Use PowerShell or the certutil program.
[Convert]::ToBase64String([IO.File]::ReadAllBytes("C:\Temp\notes.txt"))
[IO.File]::WriteAllBytes("C:\Temp\copy.txt", [Convert]::FromBase64String("S2FsaVJhbmdlIHRyYW5zZmVyIHRlc3QK"))
certutil -encode C:\Temp\notes.txt C:\Temp\notes.b64
certutil -decode C:\Temp\notes.b64 C:\Temp\notes.outExample output of the last command:
Input Length = 112
Output Length = 76
CertUtil: -decode command completed successfully.base64 is an encoding, not encryption. Anyone who reads the text can decode it. Never use it to protect a secret.
Step 5: Read the traces as a defender
Find each transfer in the logs
Every method above leaves a record. A defender uses these records to find a file that was moved without permission. An administrator uses them to prove that a transfer happened.
Check the SSH log on target. scp, sftp and rsync all start with an SSH login.
sudo grep 'sshd' /var/log/auth.log | grep -E 'Accepted|session opened' | tail -4Example output:
Nov 19 10:16:31 target sshd[3120]: Accepted password for user from 10.0.0.5 port 51822 ssh2
Nov 19 10:16:31 target sshd[3120]: pam_unix(sshd:session): session opened for user user(uid=1000) by (uid=0)The log shows who connected and from where. It does not show file names. To log file names of sftp, an administrator sets Subsystem sftp internal-sftp -l INFO in /etc/ssh/sshd_config.
List network connections on kali while a transfer runs. A web server or SMB server listens on a port that you can see.
ss -tlnp | grep -E ':8000|:445'Example output:
LISTEN 0 5 10.0.0.5:8000 0.0.0.0:* users:(("python3",pid=2841,fd=3))
LISTEN 0 32 0.0.0.0:445 0.0.0.0:* users:(("python3",pid=2905,fd=5))Use this list in your own work. On a server that never serves files, an unknown process on port 8000 or 445 is a finding.
Write down what a defender can do for each method.
| Method | Trace | Control |
|---|---|---|
| HTTP | Web server log, proxy log, curl in shell history | Egress filter; allow only known hosts |
| SSH | auth.log, last, flow data on port 22 | Key-only login; restrict users with AllowUsers |
| SMB | Windows event 5140 (share access), smbd log | Block port 445 between workstations |
| base64 | Large text in shell history or terminal log | Session recording; length alert on commands |
Data sent through base64 or a custom port looks normal to a simple filter. Defenders look at the size and the time of a connection, not only at the port.
Check Your Work
Write a short note with these facts from your own lab. For each fact, give the command and the output line that proves it.
- The output of
sha256sum -c SHA256SUMSontargetafter the HTTP transfer. - The same check after the
rsynctransfer. - The
smbclientlinegetting file \\report.txt of size 37. - The hash of the file that you decoded from
base64, equal to the hash of the original. - The
GETline in the web server log that matches yourcurlcommand. - One log line in
auth.logthat shows yourscplogin.
Clean-up
- Stop the web server and
impacket-smbserverwith Ctrl+C. Runss -tlnp | grep -E ':8000|:445'; it prints nothing. - On
target, remove the test files:rm -rf ~/incoming /tmp/transfer /tmp/report.txt /tmp/backup.bin. - On
win10, runnet use * /deleteand delete the files inC:\Temp. - On
kali, remove~/transferwhen you finish your note. - Roll back each virtual machine to the snapshot you took before Step 1 (or rebuild it).
Lab complete. You can now move a file with HTTP, SSH, SMB and base64, prove it with a hash, and find the trace on the server. Next: Netcat Fundamentals shows a raw TCP transfer with no protocol on top.
Sign in to track progress and send feedback.