🎭Living off The Land File Transfers

Introduction

The phrase "Living off the land" was coined by Christopher Campbell (@obscuresec) & Matt Graeber (@mattifestation) at DerbyCon 3.

The term LOLBins (Living off the Land binaries) came from a Twitter discussion on what to call binaries that an attacker can use to perform actions beyond their original purpose. These are legitimate system binaries that can be abused for malicious purposes.

Key Resources:

  • LOLBAS Project - For Windows Binaries (https://lolbas-project.github.io/)

  • GTFOBins - For Linux Binaries (https://gtfobins.github.io/)

Living off the Land binaries can be used to perform functions such as:

  • Download - Retrieve files from remote sources

  • Upload - Send files to remote destinations

  • Command Execution - Execute arbitrary commands

  • File Read - Read sensitive files

  • File Write - Write files to disk

  • Bypasses - Bypass security controls

This section focuses on using LOLBAS and GTFOBins projects and provides examples for download and upload functions on Windows & Linux systems.

Windows Living off The Land Binaries (LOLBAS)

CertReq.exe

Description: Certificate Request utility that can be used to upload files via HTTP POST.

Upload Files:

Expected Output:

Netcat Session Output:

⚠️ Note: If you get an error when running certreq.exe, the version you are using may not contain the -Post parameter.

Bitsadmin

Description: Background Intelligent Transfer Service (BITS) can download files from HTTP sites and SMB shares.

Download File:

PowerShell BITS Transfer:

Advanced BITS Usage:

Certutil

Description: Certificate utility that can download arbitrary files. Found by Casey Smith (@subTee).

Download File:

Base64 Decode:

URL Cache Download:

⚠️ Note: The Antimalware Scan Interface (AMSI) currently detects this as malicious Certutil usage.

Expand.exe

Description: Built-in utility for extracting compressed files.

Download and Extract:

Esentutl.exe

Description: Extensible Storage Engine (ESE) database utility.

Download File:

Findstr.exe

Description: String search utility that can read files.

Read Remote Files:

Replace.exe

Description: File replacement utility.

Download File:

Makecab.exe

Description: Cabinet file creation utility.

Upload File (via UNC):

Print.exe

Description: Print command that can download files.

Download File:

Reg.exe

Description: Registry editor that can save/export files.

Export Registry to Remote:

Xcopy.exe

Description: Extended copy utility.

Download File:

Linux Living off The Land Binaries (GTFOBins)

OpenSSL

Description: Cryptographic toolkit that can create SSL connections for file transfer.

Setup SSL Server (Attack Host):

Download File (Target Host):

Upload File via SSL:

Wget

Description: Web file downloader (if available).

Download File:

Upload via POST:

Curl

Description: Command-line HTTP client.

Download File:

Upload File:

Nc (Netcat)

Description: Network utility for reading/writing network connections.

Download File:

Upload File:

Socat

Description: Extended netcat with additional features.

Download File:

SSH/SCP

Description: Secure Shell utilities.

Download File:

Upload File:

Base64

Description: Base64 encoding/decoding utility.

Encode and Transfer:

Xxd

Description: Hex dump utility.

Transfer via Hex:

Tar

Description: Archive utility.

Transfer Archive:

DD

Description: Data duplicator/converter.

Transfer Raw Data:

Advanced Living off The Land Techniques

Windows Registry as Storage

Store Data in Registry:

Alternate Data Streams (ADS)

Hide Files in ADS:

WMI for File Transfer

Download via WMI:

MSBuild for Execution

Download and Execute via MSBuild:

Linux Systemd for Persistence

Create Service for File Transfer:

Steganography with LOLBins

Hide Data in Images

Windows - Using forfiles:

Linux - Using steghide:

Detection Evasion Techniques

Rename Binaries

Windows:

Linux:

Use Legitimate File Extensions

Disguise Executables:

Time-based Transfers

Schedule Transfers:

Defensive Considerations

Monitoring LOLBins Usage

Windows Event Logs:

  • Monitor Process Creation Events (Event ID 4688)

  • Monitor PowerShell Script Block Logging (Event ID 4104)

  • Monitor Network Connections (Event ID 3 - Sysmon)

Linux Monitoring:

  • Monitor syscalls with auditd

  • Use process monitoring tools (ps, top, htop)

  • Monitor network connections (netstat, ss)

Common Detection Signatures

Suspicious Command Lines:

Mitigation Strategies

  1. Application Whitelisting - Prevent unauthorized binary execution

  2. Network Monitoring - Monitor outbound connections

  3. Behavioral Analysis - Detect unusual binary usage patterns

  4. Endpoint Detection - Use EDR solutions to detect LOLBin abuse

  5. User Education - Train users to recognize suspicious activities

Best Practices for Penetration Testers

Reconnaissance Phase

  1. Enumerate available binaries on target systems

  2. Check binary versions and capabilities

  3. Identify network restrictions that may affect transfers

  4. Research alternative methods for detected/blocked binaries

Execution Phase

  1. Start with least suspicious methods first

  2. Use legitimate-looking file names and extensions

  3. Time transfers appropriately to avoid detection

  4. Clean up artifacts after successful transfers

  5. Document successful techniques for future use

Testing Methodology

Troubleshooting Common Issues

Certificate Errors

Bypass SSL Certificate Validation:

Network Restrictions

Test Connectivity:

Binary Not Found

Alternative Binary Search:

Key Takeaways

  1. LOLBins are powerful - Legitimate binaries can perform file transfers

  2. Stealth advantage - Using system binaries is less suspicious

  3. Multiple options available - Always have backup methods ready

  4. Environment awareness - Different systems have different binaries

  5. Detection evasion - Rename binaries and use legitimate-looking names

  6. Clean up artifacts - Remove evidence after successful transfers

  7. Document techniques - Keep notes on successful methods

  8. Stay updated - New LOLBins are discovered regularly

References

Last updated