Traditional antivirus was built around a simple assumption: an attack involves a malicious file, and if you can recognise the file you can stop the attack. Attackers noticed. A large share of modern intrusions involve little or no custom malware on disk. Instead they use programs that every Windows or Linux machine already has, signed by the operating system vendor and trusted by default. The security community calls this living off the land, and the tools involved are often called LOLBins, short for living-off-the-land binaries.
Two related ideas
Fileless malware describes code that runs mainly in memory, without writing a traditional executable to disk. A script might be passed directly to an interpreter, or code might be loaded into the memory of a legitimate process. The term is a little misleading, because something usually touches disk or the registry somewhere, for example to survive a reboot. A more precise phrase is “minimal-footprint” or “memory-resident”.
Living off the land describes misusing legitimate, pre-installed tools to do attacker work: downloading files, executing code, moving between machines, collecting data. The community-maintained LOLBAS project documents Windows binaries, scripts and libraries with abusable features; GTFOBins does something similar for Unix-like systems. Both exist mainly so defenders know what to watch.
The two ideas often combine: a legitimate tool is used to load code directly into memory.
Why attackers bother
- Trust. System binaries are signed by Microsoft or the distribution maintainer. Application allowlisting and many security tools trust them.
- Camouflage. Administrators use PowerShell, WMI, remote management and scheduled tasks every day. Malicious use hides among legitimate use.
- Less forensic residue. With no malware file, there is no hash to share and nothing for a file scanner to find after the fact.
- No development cost. The tools are free, documented and already installed.
What it looks like, conceptually
Consider an illustrative intrusion at a software services firm. A user opens a shortcut file from a zipped “offer letter”. The shortcut runs a built-in scripting host, which runs an obfuscated PowerShell command. That command downloads the next stage straight into memory and executes it there; nothing new appears in the user’s folders.
For persistence, the attacker stores a script inside a registry value and creates a scheduled task that reads and runs it at logon. For discovery, they use built-in commands to list domain users, groups and shares. To move to a server, they use Windows’ own remote management features with stolen credentials. A certificate utility that ships with Windows, intended for managing certificates, is misused to decode a file. Every program that runs in this story is legitimate. What is malicious is the sequence and the context.
The Windows tools most often named in this context include PowerShell, WMI, the HTML application host, the scripting hosts, rundll32 and regsvr32, and the certificate utility. Each has real administrative uses, which is exactly the point.
Detecting the undetectable file
Since there may be no malicious file, detection moves to behaviour and context. The important telemetry sources are:
- Process creation with full command lines, from EDR, Sysmon or Windows process auditing with command-line logging enabled. Without command lines, you see that PowerShell ran, which tells you almost nothing.
- Parent-child relationships. PowerShell launched by an administrator’s terminal is normal. PowerShell launched by a word processor, a PDF reader or the HTML application host is a strong signal.
- PowerShell script block logging, which records the script content that actually executed, after the interpreter has decoded obfuscation layers. Windows records these under event ID 4104 in the PowerShell operational log.
- AMSI, the Windows Antimalware Scan Interface, which lets security products inspect script content at the moment it is run, again after decoding.
- Network connections by unusual processes. A certificate utility or a DLL-loading helper making outbound internet connections is rarely legitimate.
- Memory scanning by EDR products for code injected into legitimate processes.
Baselines make these signals usable. In a firm where only the IT team uses PowerShell, any PowerShell from a finance user is worth a look. In a development shop where everyone automates with it, the detection needs to focus on encoded commands, downloads into memory, or unusual parents.
Reducing the attack surface
Prevention is about removing what most users do not need:
- Application control policies that block rarely needed binaries, such as the HTML application host, for ordinary users.
- Microsoft’s attack surface reduction rules, which can, for example, block Office applications from creating child processes.
- PowerShell Constrained Language Mode for users who do not need full scripting capability.
- Removing local administrator rights, which limits what any of these tools can do on the user’s behalf.
Each of these needs testing, because some business applications and IT scripts depend on the same tools. Rolling out in audit mode first, then enforcing, avoids breaking payroll at month-end.
The shift that living off the land forces on defenders is a healthy one. It moves attention from “is this file bad?” to “does this activity make sense for this user, on this machine, at this time?” That second question is harder, but it is also much harder for an attacker to dodge.
Written by the RP Strativa Team. The intrusion described is illustrative.
Leave a Reply