WdToggle: enable WDigest credential caching
A Proof of Concept Cobalt Strike Beacon Object File which uses direct system calls to enable WDigest credential caching and circumvent Credential Guard (if enabled).
Additional guidance can be found in this blog post.
This PoC code is based on the following excellent blog posts:
Utilizing direct systems calls via inline assembly in BOF code provides a more opsec safe way of interacting with the LSASS process. Using direct system calls avoids AV/EDR software intercepting user-mode API calls.
Visual Studio (C++) does not support inline assembly for x64 processors. So in order to write a single Beacon Object File containing our compiled/assembled code we must use the Mingw-w64 (GCC for Windows) compiler.
What is this repository for?
- Demonstrate the usage of direct systems calls using inline-assembly to provide a more opsec safe way of interacting with the LSASS process.
- Enable WDigest credential caching by toggling the g_fParameter_UseLogonCredential global parameter to 1 within the LSASS process (wdigest.dll module).
- Circumventing Credential Guard (if enabled) by toggling the g_IsCredGuardEnabled variable to 0 within the LSASS process (wdigest.dll module).
- Execute this code within the Beacon process using a Beacon object file.
How do I set this up?
We will not supply compiled binaries. You will have to do this yourself:
- Clone this repository.
- Make sure you have the Mingw-w64 compiler installed. On Mac OSX for example, we can use the ports collection to install Mingw-w64 (sudo port install mingw-w64).
- Run the make command to compile the Beacon object file.
- Within a Cobaltstrike beacon, context run the inline-execute command and provide the path to the object WdToggle.o file.
- Run the Cobaltstrike logonpasswords command (Mimikatz) and notice that clear-text passwords are enabled again for new user logins or users who unlock their desktop session.
To detect credential theft through LSASS memory access, we could use a tool like Sysmon. Sysmon can be configured to log processes opening a handle to the lsass.exe process. With this configuration applied, we can gather telemetry for suspicious processes accessing the LSASS process and help detecting possible credential dumping activity. Of course, there are more options to detect credential theft, for example using an advanced detection platform like Windows Defender ATP. But if you don’t have the budget and luxury of using these platforms, then Sysmon is that free tool that can help to fill up the gap.