Transfering Files
Netcat File Transfer
Step 1
Create a file on the target box in the /tmp directory
Set up the listener and direct STDOUT into the new file
-Send the file
Method Two
On attacker run:
On target run:
NC Transfer with gzip data
Web Servers:
Python HTTP Server File Transfer
Start the Python Server in the directory where the file is located that you want to transfer
Use the ip address assigned to your box, if there is a vpn involved use the vpn address
Above is for python3
Above is for python
You can optionally specify a port that you want the server to run on (it defaults to 8000)
Wget the file from the target box
Change permissions
Run the transfered file
PHP Web Server
Metasploit Web Server
SMB File Transfer
On kali box:
On Windows (update the IP address with your Kali IP):
SMB2 Support
If you recieve this error when attempting to transfer files:
Restart your smbserver.py with this option at the end:
Wget
Curl
PHP Download
Secure Copy Protocol
SCP a file from your attack box to a target box
This command copies the file linpeas.sh to user on the target box and places it in the /tmp directory.
SCP a file from your attack box while on the command line of a target box and place it in your present working directory.
SCP More Example Usage
Upload a file using SCP
Download a file using SCP
Windows Specific Downloads
CertUtil.exe
Windows has a built-in command line program called CertUtil.exe which is installed as part of Certificate Services and can be used to manage certificates in Windows.
CertUtil is also known as living off land LOL binary which is a trusted preinstalled system tool.
It can even bypass security features by base64 encoding the malware.
-urlcache
Displays or deletes URL cache entries-f
Forces fetching a specific URL and updating the cache-split
Split embedded ASN.1 elements, and saves files on diskUsing the encoding may help bypass security controls in certutil.
Using the
-decode
option we can download a Base-64 encoded malicious executable such as a text file and decode the executable to disk.This can bypass antivirus, edge devices and filtering.
First we need to base64 encode the netcat executable.
To verify that the nc.txt file contains text, we can run the following command to print the first 10 lines to the terminal:
Now we have to transfer the text file to the target and decode it back to an executable.
And the following command decodes the base64
Powershell downloads:System.Net.WebClient
First example uses .NET class System.Net.WebClient.
The following commands create a Powershell script on the remote Windows machine that can be used to download the file from the attack box:
Note that you have to insert the download link and filename in the command on the last line and replace all the bold with the URL and the filename.
Once verified that the PS script is created we can execute with:
Alternatively we can also execute the command from a regular command line in Windows powershell to download files without creating a script
The -c option executes the command provided within the double quotes with Powershell.
The default execution policy is ‘Restricted’ which means the system will not run Powershell scripts.
With the following powershell command we can get the current execution policy:
We can now set the policy to ‘Unrestricted’:
Loading Script into Memory with powershell
The script can be loaded into memory with powershell
Powershell Downloads: Start-BitsTransfer
Another way to download files with Powershell is by using the Background Intelligent Transfer Service (BITS).
The Start-BitsTransfer cmdlet creates a BITS transfer job to transfer one or more files between a client computer and a server.
BITS has to be enabled on the target machine in order for it to work.
The following command will download nc.exe from a remote web server to the C drive:
Powershell Downloads: Invoke-WebRequest
The Invoke-WebRequest cmdlet is simple and easy to use and is available in Powershell version 3.0 and higher.
Downloading large files with this method may cause memory issues.
Recommended to use the System.Net.Web.Client method for transferring large files.
For this cmdlet to work the target host needs to have at least Powershell 3.0
You can check the version of Powershell by using the following command
Proxy Aware Powershell Downloader
Description: 'Most large orgs are using web proxies these days. The standard PowerShell download cradle is not proxy aware. Use this one.'
Upload Windows data through HTTP Post request
make /var/www/upload.php on kali
Upload file in Windows client
VBS download files for Windows XP
Create vbs script
Run VBS script to download file
I am Stuck
If u ever happen to have a shell of a UNIX system, and cannot find a way to upload anything, this is a lifesaver trick you can try:
On local system:
Double click on output to copy
On Target System:
Last updated
Was this helpful?