AppLocker Bypass

Enable AppLocker

In Group Policy Editor (gpedit) navigate to Local Computer Policy -> Computer Configuration -> Windows Settings -> Security Settings -> Application Control Policies and select the AppLocker

In the Properties menu, enable AppLocker rules for Executables, Windows Installer files, scripts, and packaged apps. DLL's can be enabled as well in Advanced Tab.

For each category, select Configured and Apply.

Now open one of the categories and right-click. Select "Create Default Rules".

Take the time to inspect each ruleset. When you're done run gpupdate /force from an admin command prompt or powershell session. Below will be a few defense evasion techniques.

View Blocked Execution

EventViewer -> Applications and Services Logs -> Microsoft -> Windows -> AppLocker

Enumeration

Get-ChildItem -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\SrpV2\Exe

Sysinternal Tools

Script to find trusted folders and output the permissions

$tools = "C:\SysinternalsSuite"

C:\SysinternalsSuite\accesschk.exe "<USERNAME>" C:\Windows -wus -accepteula | out-file -FilePath C:/users/<USER>/Desktop/permissions.txt

foreach($line in Get-Content  C:/users/<USER>/Desktop/permissions.txt) {
    if($line.StartsWith("RW") -or $line.StartsWith("W"))
    {
    $line.Substring(3) | out-file -FilePath  C:/users/<USER>/Desktop/files.txt -Append
    }
}

foreach($file_path in Get-Content C:/users/<USER>/Desktop/files.txt){
if(Test-Path -Path $file_path -PathType Container)
    {
        cd $tools
        icacls.exe $file_path | out-file -FilePath C:/users/<USER>/Desktop/folder-permissions.txt -Append
    }
}

Found interesting folder path. Used in Trusted Folders example below.

Trusted Folders

Creating a javascript POC to see if code execution is allowed in a folder. Saved as test.js in folder path mentioned above.

Execute script

The same concept applied to DLLs as well

Generate msfvenom dll

copy to whitelisted folder and run

Bypass MSI

Generate payload

On Victim

Alternate Data Stream

Create alternate data stream to readable and writeable file

Opening the file will execute primary stream. Using the following command will execute the ADS

Getting a Shell with ADS

generate raw payload

Create jscript payload with SuperSharpShooter

create alternate data stream to readable and writeable file (TeamViewer Log)

Opening file will execute primary stream. using the following command will execute the ADS

UninstallUtil

A combination of AppLocker and CLM bypass

Note: you must add a reference before compiling.

Using Uninstalls to bypass Applocker and bitsadmin to transfer file

Microsoft.Workflow.Compiler.exe

Payload is C# code as txt file

Commands to run

MSBUILD

Using XML Template from here

https://www.ired.team/offensive-security/code-execution/using-msbuild-to-execute-shellcode-in-c

Execute Payload

MSHTA

Test.hta file on Web Server will open cmd.exe

The MSHTA.exe filepath used is a x64 exe

Generate payload

SuperSharpShooter

Copy Jscript payload created into test.hta template

WMIC

On Target

XSL Template

Last updated

Was this helpful?