Credentials Collection via CredUIPromptForCredentials
Purpose
The purpose of this lab is to twofold:
write some code that invokes Windows credential prompt, that would allow malware or an attacker to collect targeted user's credentials once they are on the compromised machine
write some ETW code that detects processes invoking credential prompts
Stealing User Credentials
It is possible to collect user credentials with the below code:
Although in this lab I am using CredUIPromptForCredentials
for invoking credentials prompt, you should be using CredUIPromptForWindowsCredentials
If we compile and run the above code, we get a credential prompt, that captures user's credentials in plain text, which we could then save to a file or send out over the internet:
The above credential prompt can also be invoked with PowerShell cmdlet Get-Credential
.
Detecting Credential Prompts
As a defender, one may want to know what processes are popping these credential prompts, so that malicious ones could be detected - i.e if you are notified that suddenly some unusual process showed a prompt, it may mean that the process is infected and the machine is compromised.
Detection of programs showing credential prompts is possible with Event Tracing for Windows (EWT) - Microsoft-Windows-CredUI provider to the rescue:
Looking at the provider Microsoft-Windows-CredUI in ETWExplorer, we can see that it can provide consumers with events for both CredUIPromptForCredentials
and CredUIPromptForWindowsCredentials
invokations:
We can create an ETW tracing session and subscribe to events from Microsoft-Windows-CredUI provider with C# like so:
Demo
Below shows RogueCredentialsPrompt.exe and Powershell.exe invoking Windows credential prompts and our simple consumer program detecting that activity:
References
Last updated