Modifying password entered by the user when logging into Windows account

634 views Asked by At

I'm writing a credential provider that would correct user's password when the user is logging into Windows account and accidentally types password using wrong keyboard language settings (Ukrainian rather than latin for example). The same keys but different letters. Now I need a way to intercept the user-entered password and if it is entered wrongly to correct it. As a starting point I'm using the credentials provider from the Windows SDK. It works fine in a standard mode (like the default CP). But I cannot find where to obtain and correct the password entered by the user. I thought that HRESULT CSampleCredential::GetStringValue( DWORD dwFieldID, PWSTR* ppwz)

method is the right place to do it. To replace

hr = SHStrDupW(_rgFieldStrings[dwFieldID], ppwz);

string with

hr = SHStrDupW(ppwstrCorrected, ppwz);

Where ppwstrCorrected contains either the original password or the corrected one. But this does nothing. Credentials Provider continues to work as it did. I even tried to "break" my provider by making GetStringValue return some gibberish any time it is called. But the sample provider still works as a standard one. And yes, I've tried to log in via the sample provider and not the standard since they are easy to distinguish by bitmaps on their tiles. So where can I intercept the entered password that goes into Windows for checking?

2

There are 2 answers

1
Alexander On

I think it will be better to re-set corrected password back using ICredentialProviderCredentialEvents::SetFieldString()

ICredentialProviderCredential::GetStringValue() called by LogonUI to retrieve values of static text fields.

0
ambeid On

Answering my own question. There were two problems with my provider. First, provider's code was simply unused and standard provider's code was used instead. I don't know why it is so but I solved this by filtering out the standard providers, like it is described in Windows Credential Provider, Filter, and Unlock Workstation Scenario question. Now, as far as SDK example is concerned, the unmodified user-entered password may be accessed in the CSampleCredential::GetSerialization() method. It is stored in _rgFieldString[SFI_PASSWORD] string. The password may be passed to the encryption function from this method, so it should be modified before it is encrypted.