This technique abuses Windows Security Support Provider (SSP) and Authentication Packages (AP) that come in the form of DLLs that get injected into LSASS.exe process on system boot or dynamically via AddSecurityPackage API.
Loading SSP with Reboot
In this lab, mimikatz Security Support Provider mimilib.dll will be registered as a Windows Security Package.
Once the Security Package is registered and the system is rebooted, the mimilib.dll will be loaded into lsass.exe process memory and intercept all logon passwords next time someone logs onto the system or otherwise authenticates, say, via runas.exe.
Let's now build the mimilib.dll and copy it to the target machine's system32 folder:
The below shows Security Packages registry value with the mimilib added and the kiwissp.log file with a redacted password that had been logged during the user logon (after the system had been rebooted after the Security Package was registered):
Reboot is required for the new SSP to take effect after it's been added to the Security Packages list.
Loading SSP without Reboot
It's possible to load the SSP DLL without modifying the registry:
Below code loads the malicious SSP spotless.dll:
#defineWIN32_NO_STATUS#defineSECURITY_WIN32#include<windows.h>#include<sspi.h>#include<NTSecAPI.h>#include<ntsecpkg.h>#pragmacomment(lib, "Secur32.lib")intmain(){ SECURITY_PACKAGE_OPTIONS spo = {}; SECURITY_STATUS ss =AddSecurityPackageA((LPSTR)"c:\\temp\\spotless.dll",&spo);return0;}
Below shows how the new Security Package spotless.dll is loaded by lsass and is effective immediately:
Loading the SSP with this approach does not survive a reboot unlike SSPs that are loaded as registered Security Packages via registry.
Detection
It may be worth monitoring Security Packages value inhklm\system\currentcontrolset\control\lsa\ for changes.
Newly added packages should be inspected:
Additionally, mimilib.dll (same applies to custom spotless.dll) can be observed in the list of DLLs loaded by lsass.exe, so as a defender, you may want to make a baseline of loaded known good DLLs of the lsass process and monitor it for any new suspicious DLLs:
Code
Below is the code, originally taken from mimikatz, adapted and refactored to suit this lab, that we can compile as our own Security Support Provider DLL. It intercepts authenticatin details and saves them to a file c:\temp\logged-pw.txt: