• Stars
    star
    141
  • Rank 259,971 (Top 6 %)
  • Language
    C
  • Created almost 4 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Run Processes as PPL with ELAM

PPLRunner

This project is to enable running 'arbitrary*' process as an Anti Malware Protected-Process-Light (PPL), for research purposes. (* See the Restrictions section for more details)

See this blog I wrote for more details and the reasoning behind this project.

Overview

System protected process is a security model in Windows designed to protect system and anti-virus processes from tampering or introspection, even by Administrators/SYSTEM.

Processes started as an Anti Malware 'Protected Process-Light' (PPL) are restricted in what they can do, can only load signed code, but cannot be debugged, inspected, or stopped by non-Protected Processes. Additionally, they can get access to special data, such as the Microsoft-Windows-Threat-Intelligence ETW Provider.

This project creates an Early-Launch Anti Malware (ELAM) driver and usermode service. The service will launch a configurable child process when it starts which will also be marked as PPL.

The child binary must be signed with the same certificate as the service, along with some other restrictions, but can otherwise be any binary and commandline arguments you chose.

Honestly I'm not doing a good job of explaining what ELAM and PPL are, instead I recommend starting here:

Pre-Built/Easy mode

You can grab a pre-built and signed version of the PPLRunner service and kernel module from Releases. The release also has the autogenerated certificate and private key in a .pfx file, which is password-protected with the password password. I did say this is for research-purposes only right?

Manual

To generate and build your own project:

Setup

Make sure you have Windows SDKs installed.

Open generate_cert.ps1 and sign_file.ps1, and change the $password variable to something else (they must match each other).

Run generate_cert.ps1. This will generate a ppl_runner.pfx with a new private and public certificate. This will be used to sign all binaries used by PPLRunner.

Build

Build ppl_runner.sln. This will produce 3 binaries:

elam_driver.sys

The ELAM Kernel Driver that has the certificate information in it. The driver doesn't actually do anything, and won't actually be loaded, it is just used as a vessel for the signing certificate.

ppl_runner.exe

The Service installer and binary. As a PPL service, when started it will launch a child process, also as PPL, then stop and exit.

child_example.exe

An example executable that will be signed with the correct certificate by Visual Studio at build time. PPLRunner can run almost any binary, this is just an example that will be automatically signed.

Install

NOTE Only install on a testing machine, not production/your home PC.

  1. Once built, copy elam_driver.sys and ppl_runner.exe to a folder on the target machine.

  2. Enable test signing by running this from an elevated prompt, then reboot:

bcdedit /set testsigning on
  1. From an elevated command prompt, browse to the folder containing the copied executables and run:
ppl_runner.exe install

This should install a service named ppl_runner.

Configure

To sign a binary to run, sign it with the ppl_runner.pfx cert, using either the sign_file.ps1 script, or just running signtool.exe yourself. If you don't have signtool.exe, it is in the Windows SDKs.

Create the registry key HKLM\SOFTWARE\PPL_RUNNER. Set the default/empty key to be a REG_SZ, containing the full path to the binary to execute, and any commandline argument. e.g. from the commandline:

REG.exe ADD HKLM\SOFTWARE\PPL_RUNNER /ve /t REG_SZ /d "C:\path\to\binay --argument 1"

Run

To make the service launch the executable, just run from an elevated prompt:

net start ppl_runner

As a PPL service, when started ppl_runner will read the registry key, launch the child process, also as PPL, then stop and exit. A successful launch will still say the service failed to run, but if you check the return code with sc query ppl_runner, it should be 0, i.e. ERROR_SUCCESS.

The Child process will not be visible, however if you can use Debug Outputs and DBGView.exe to get some form of output (see the child_example code).

Cleanup/Removal

As the service is also Anti Malware PPL, it can only be stopped and deleted by a similarly high-level process. However, we can use PPLRunner to remove itself, simply set the command in the registry key to be:

C:\path\to\ppl_runner.exe remove

And run the Service. i.e. run:

REG.exe ADD HKLM\SOFTWARE\PPL_RUNNER /ve /t REG_SZ /d "C:\path\to\ppl_runner.exe remove"
net start ppl_runner

Restrictions

  • This project only works in testsigning mode.
  • ppl_runner.exe install must be re-run after every reboot
  • The child binary must be signed with the same certificate as the service
  • Any DLLs the binary loads must also be signed

Debugging

Run Sysinternal's DBGView and log Win32 Global, filtering on *[PPL_RUNNER]*. This will show all logs from the service and installer.

Example uses

TBD - Sealighter blog

Similar Projects

James Forshaw created an awesome project to inject code into existing PPL processes.

Futher Reading and Thanks

Following Alex Ionescu is probably the best way to learn more about ELAM and PPL. Possibly start with this: https://www.crowdstrike.com/blog/protected-processes-part-3-windows-pki-internals-signing-levels-scenarios-signers-root-keys/

Following Matt Graeber and James Forshaw is another great way.

Massive thanks to Matt for the powershell script to get the 'To-Be-Signed' hash from a certificate.

James has written a lot about PPL and its flaws.

More Repositories

1

bad-bpf

A collection of eBPF programs demonstrating bad behavior, presented at DEF CON 29
C
530
star
2

Sealighter

Sysmon-Like research tool for ETW
C++
328
star
3

SealighterTI

Combining Sealighter with unpatched exploits to run the Threat-Intelligence ETW Provider
C
159
star
4

bpf-hookdetect

Dectect syscall hooking using eBPF
C
139
star
5

siemcraft

Security Information and Event Management in Minecraft
Go
115
star
6

commandline_cloaking

A collection of projects demonstrating various commandline cloaking techniques on Linux
Go
53
star
7

bpf-pipesnoop

Example program using eBPF to log data being based in using shell pipes
C
40
star
8

toucli

Use TouchID and the Secure Enclave to encrypt data from the commandline.
Swift
15
star
9

SimpleAmsiProvider

A simple provider to analyse what gets passed into Microsoft's Anti-Malware Scan Interface
C++
13
star
10

tf_wireguard

Simple Terraform Scripts to setup a WireGuard server on various cloud providers.
HCL
11
star
11

https.server

Python SimpleHTTPServer wrapped in TLS
Python
8
star
12

bpf-uprobedbg

C
7
star
13

ctlwatcher

Monitor Certificate Transparency logs for domains matching regexes.
Rust
6
star
14

ld_preload_go

Simple example of creating an `LD_PRELOAD` library in Go that hooks LibC's main function.
Go
5
star
15

ebpf-pinned-fentry

Example how to run eBPF probes without a usermode process using fentry
C
3
star
16

Presentations

A Repo to hold slides from presentations, etc.
3
star
17

cookiecache

Simplify getting and using cookies from the browser to use in Python.
Python
3
star
18

dockenv

Dockenv - Run python in docker the easy way
Python
2
star
19

etwRunner

Basic KrabsETW runner template
C++
2
star
20

terraform-provider-bitlaunch

BitLaunch Terraform Provider
Go
2
star
21

pyauditlogger

Auto-Add Python 3.8 audit hooks to all python scripts
Python
1
star
22

hijack-watcher

Rust version of HijackWatcher
Rust
1
star
23

etw_watcher

Using GitHub Actions to create commit diffs
PowerShell
1
star
24

PowerInject

Inject Interactive PowerShell into an arbitrary process
C
1
star
25

sigstore-watcher

Watches SigStore Code Signing Logs
Rust
1
star
26

sgproxy

Basic HTTP/S proxy. Created to add HTTP Auth to a request from a client that doesn't support supplying auth in URL, for example VScode's Juypyter Notebook Server browser.
Go
1
star
27

Puppeteer-Stealth-Docker

This is a simple example of how do stealthy headless chrome webscraping from a Docker container.
Dockerfile
1
star