The Sanctum EDR is an 🚧 experimental and in development 🚧 proof of concept for an EDR (Endpoint Detection and Response) tool, fully written in Rust! No C required in this project baby!
I'm documenting this project on my blog!
Up until recently, the readme was in need of some tlc; given how fast the project has grown the readme was out of date and as time went on some fairly specific configuration requirements have arose. See the Deployment Instructions section for clear details on how to install the project to a VM. Do not deploy this on your host machine, as we are tampering with the kernel (Windows 11), you may encounter system instability.
I am not accepting PR's as a rule; unless your contribution is something small / utility based. This project is primarily for my own learning - and hopefully for me to teach the concepts to people interested in low level Windows system security / malware devs / defensive engineering / analysts.
That said; as there is more attention on the project, please feel free to raise issues or use the discussions page as you wish. If you want some integrations, let me know and I will look at building those in!
I'd also recommend opening the driver crate at its crate level from the Developer Command Prompt (e.g. for VSCode: code driver
) as I have noticed some issues with
Rust-Analyzer
if not opened in this way.
🚧 Please note: This project is not currently designed for mass consumption; you may encounter teething issues in the deploy process - you can raise an issue for me to fix; but I provide no guarantee it will work without issue on your deployment. This is a POC project first and foremost. There may be some bugs, or incomplete features on the main branch as I develop it. For bugs, please raise an issue. Incomplete features will be in progress, so please do not raise issues for those.
Crate | Description |
---|---|
driver | Contains the code for the Sanctum driver which is required for kernel monitoring |
um_engine | The usermode engine of the Sanctum application which communicates with the driver, running processes, and the GUI |
injected_dll | A DLL injected into all processes for EDR hooking (note that this is currently phased out, having being replaced with kernel-side hooking after I researched Alt Syscalls for Windows 11). I will leave this in the project for legacy / blog post reasons, I have spent a lot of time hooking functions and writing about it on my blog, so good to keep in |
gui | A GUI for the Sanctum EDR, using Tauri for rendering |
etw_installer | The installer program for creating the ELAM PPL service (installs sanctum_ppl_runner ) |
sanctum_ppl_runner | A ELAM signed Protected Process Light which monitors Events Tracing for Windows Threat Intelligence provider |
shared_* | Shared crates for the project, both in std and no_std environments |
server | Todo, this is to be the telemetry server which will receive signals from endpoints |
etw_consumer | Deprecated; sanctum_ppl_runner implements all required features this was intended to solve. Leaving in for learning reasons / linked to my blog post |
You can check my YouTube channel for some POC videos :)
As a summary of features:
- Alt Syscalls for kernel-side interception of syscalls
- Events Tracing for Windows: Threat Intelligence telemetry subscription
- Uses Ghost Hunting to detect signs of malicious activity
- Detects tampering of NTDLL (thwarts common malware TTPs)
- Detects rootkit tampering in the kernel
- DLL injection of EDR (currently deprecated in favour of Alt Syscalls)
- Cargo (obviously..).
- Nightly.
- Windows Driver Kit & Developer Console (as admin for building the driver).
- Cargo make and LLVM tools, see Microsoft's build instructions for installing these.
- Tauri build tools, see the documentation for official instructions.
The installation instructions are split between your host and guest. If you are having problems deploying this, please use the discussions page or raise and issue and I will do my best to help / fix any bugs from the process.
They are split into instructions for a host machine and a guest VM, this is because I advise against developing & building on your deployment VM (if the driver bricks your VM and it cant boot, then you will lose any development / environment specific setup [assuming no snapshots] that went into you being able to build this project).
If you wish to build and deploy on the same machine (VM only to save your host), then I recommend 2 VM's; one to build, one to deploy, in which case, treat the host section below as your 2nd VM.
As an overview, the driver must be built via cargo make
, which is a pipeline provided by Microsoft in the Windows Drivers project. The remaining crates for this
project are built via cargo build
.
- Install a clean Windows 11 VM; do so first with a Gen2 processor, Secure Boot and TPM so you can properly install windows. I would recommend installing W11 Pro when prompted. You can use either a type 1 or type 2 hypervisor.
- Update Windows etc.
- Disable Secure Boot and TPM.
- Boot the VM
- Copy over the
installer_clean_vm.ps1
script from this repo root. - Open PowerShell as admin, and cd into where you dropped the script.
- Enable running of scripts on your VM via powershell
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
- Run
./installer_clean_vm.ps1
- this will initialise the folder structure required, pull down the static files, and enable debug mode and configure your VM for kernel debugging in WinDbg.
Now do the host instructions; we will return to the guest shortly.
This is a little involved due to the signing process. But follow along and you should be good.
- Ensure you have Visual Studio build tools installed
- Ensure you have this repo cloned
- Open Developer Command Prompt as Administrator (I'd recommend running
powershell
from this cmd prompt to upgrade to powershell) - CD into the driver crate of this repo
- Run
.\cert.ps1
which will generate a ELAM compatible code signing certificate calledsanctum.pfx
. The cert will be located in thedriver
crate root. - Run
cargo make
- this will build the driver. - Run
.\sign.bat
- this will sign the driver. - Run
certmgr.exe -v target\debug\sanctum_package\sanctum.sys
which will output the certificate information of the driver:- Look for the line (just on top of the half way point of the output) which has the heading:
Content Hash (To-Be-Signed Hash)::
. - Note the hash that is output beneath (will be 2 lines of bytes).
- You want to concatenate these bytes into 1 long string. To see an example explanation, check my comment here.
- Open
driver/build.rs
in your favourite code editor, and change the hash from what is there in your cloned copy to the hash you concatenated in the step above, again, see the above link if that doesn't make sense.
- Look for the line (just on top of the half way point of the output) which has the heading:
- Run
cargo clean
. - Run
cargo make
. - Run
.\sign.bat
.
Must be build in release mode to match the signing script - if you wanna build in debug mode make sure to edit sign_ppl_runner.bat
.
- Continuing on from above, go up one dir with
cd ../
. - Run:
cargo build --release -p sanctum_ppl_runner
- this will build the PPL service binary in/target/release/
. - Sign the service binary via running
.\sign_ppl_runner.bat
.
(Feel free to build these in debug mode if you wish)
cargo build --release -p elam_installer
cargo build --release -p injected_dll
cargo build --release -p um_engine
cargo tauri build --debug
Now to finish off, we want to move the binaries into the guest VM and run things!
- Move
um_engine.exe
,elam_installer
,app
(gui) into ~Desktop\sanctum - Move
sanctum.sys
,sanctum_ppl_runner.exe
,sanctum.dll
into %AppData%\Sanctum - In an admin powershell terminal:
- cd ~Desktop\sanctum
.\elam_installer.exe
- this should work and now prompt you to reboot.
- Reboot
- In an admin powershell terminal:
- cd ~Desktop\sanctum
.\elam_installer.exe
- this time no prompt to rebootsc.exe start sanctum_ppl_runner
- This should run your PPL service. If you have issues, check Event Viewer, or go to Services -> sanctum_ppl_runner and start it from there (may give more verbose error messages)
- Run um_engine as admin
- Run the GUI
app.exe
as admin - Now you should be good to start the driver from the GUI if all went well!
If you have problems with the deployment process, please feel free to submit an issue or discussion and I will try help!