Intercepting Logon Credentials via Custom Security Support Provider and Authentication Packages
Credential Access, Persistence
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:
PS C:\> copy mimilib.dll %systemroot%\system32Get a list existing LSA Security Packages:
PS C:\> reg query hklm\system\currentcontrolset\control\lsa\ /v "Security Packages"
HKEY_LOCAL_MACHINE\system\currentcontrolset\control\lsa
Security Packages REG_MULTI_SZ kerberos\0msv1_0\0schannel\0wdigest\0tspkg\0pku2uAdd mimilib.dll to the Security Support Provider list (Security Packages):
PS C:\> reg add "hklm\system\currentcontrolset\control\lsa\" /v "Security Packages" /d "kerberos\0msv1_0\0schannel\0wdigest\0tspkg\0pku2u\0mimilib" /t REG_MULTI_SZ /fThe 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):

Loading SSP without Reboot
It's possible to load the SSP DLL without modifying the registry:

Below code loads the malicious SSP spotless.dll:
Below shows how the new Security Package spotless.dll is loaded by lsass and is effective immediately:

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:
References
Last updated
Was this helpful?