A Windows credential harvesting tool that leverages the legitimate Windows API to prompt users for their credentials.
GetWindowsCredentials uses the Windows API function CredUIPromptForWindowsCredentialsW to display a native Windows credential dialog box. When users enter their credentials, the tool validates them against the system and saves successful login attempts to a file.
- Native Windows Dialog - Uses legitimate Windows credential UI
- Credential Validation - Verifies credentials against the domain/local system
- Persistent Prompting - Continues to prompt until valid credentials are entered
- Domain Support - Handles both domain and local accounts
- Silent Logging - Saves credentials to a log file without user notification
- Displays a Windows credential prompt using
CredUIPromptForWindowsCredentialsW - Captures username, password, and domain information
- Validates credentials using
LogonUserWAPI - If validation fails, prompts again until successful
- Saves valid credentials to
C:\Windows\Temp\creds.log
CredUIPromptForWindowsCredentialsW- Display credential dialogCredUnPackAuthenticationBufferW- Extract credentials from bufferCredUIParseUserNameW- Parse username and domainLogonUserW- Validate credentials against the system
Credentials are saved in the following format:
[+]Username: DOMAIN\username , Password: password123
- Visual Studio 2015 or later
- Windows SDK
- C++ compiler with Windows API support
Using Visual Studio:
- Open Developer Command Prompt
- Navigate to the source directory
- Run the following command:
cl /EHsc GetWindowsCredentials.cpp /link Credui.libUsing MinGW:
g++ GetWindowsCredentials.cpp -o GetWindowsCredentials.exe -lCredui -mwindowsGetWindowsCredentials.exeThe program will:
- Display a Windows credential dialog
- Wait for the user to enter credentials
- Validate the credentials
- Save successful logins to
C:\Windows\Temp\creds.log - Repeat if validation fails
You can modify the following constants in the source code:
// Dialog text
WCHAR baseCaption[] = L"Enter current user credentials:";
WCHAR pszCaptionText[] = L"Your screen has been locked for security";
// Output file location
WCHAR saveAs[] = L"C:\\Windows\\Temp\\creds.log";WriteCred Function
- Writes captured credentials to a log file
- Formats output with username and password
WinMain Function
- Main entry point
- Displays credential prompt
- Validates credentials
- Loops until valid credentials are provided
username- Captured username (max 514 characters)password- Captured password (max 256 characters)domain- Captured domain (max 337 characters)bLoginStatus- Validation result flag
The tool validates credentials using LogonUserW to:
- Ensure captured credentials are legitimate
- Avoid logging incorrect passwords
- Simulate real-world attack scenarios
- Demonstrate the full credential harvesting process
The program uses a goto statement to create a loop that continues prompting until valid credentials are provided. This simulates a locked screen scenario where the user must authenticate to proceed.
This project is licensed under the MIT License - see the LICENSE file for details.
