A production-ready tool for identifying pre-Windows 2000 compatible computer accounts in Active Directory environments. These accounts are often created with weak or default passwords, representing a significant security risk.
Spray-2k includes two implementations for maximum flexibility:
- PowerShell Script (
Invoke-Pre2k.ps1) - No external modules required - C# Binary (
Pre2k.exe) - Cobalt Strike execute-assembly compatible
Both implementations query Active Directory for computer accounts with the pre-Windows 2000 compatible flag (userAccountControl:1.2.840.113556.1.4.803:=4128) and test for two common weak authentication scenarios:
- Empty passwords
- Passwords matching the lowercase machine name (first 14 characters)
- No external dependencies (PowerShell version uses only built-in ADSI/DirectoryServices)
- Runs in current user context by default
- Optional custom credentials support
- Configurable authentication timeouts (default: 10 seconds)
- Progress tracking for large domains
- Clean, concise output showing only vulnerable accounts
- Production-ready error handling
- Verbose logging for debugging (PowerShell)
- Cobalt Strike compatible (C# version)
git clone https://github.com/hackandbackpack/spray-2k.git
cd spray-2kNo additional installation required. The PowerShell script runs directly, and the C# binary is pre-compiled.
.\Invoke-Pre2k.ps1.\Invoke-Pre2k.ps1 -EmptyPasswordOnly.\Invoke-Pre2k.ps1 -MachineNameOnly.\Invoke-Pre2k.ps1 -Domain "contoso.com"$password = Read-Host -AsSecureString -Prompt "Enter password"
.\Invoke-Pre2k.ps1 -Username "DOMAIN\user" -Password $password.\Invoke-Pre2k.ps1 -TimeoutSeconds 15.\Invoke-Pre2k.ps1 -Verbose.\Pre2k.exe.\Pre2k.exe /emptyonly.\Pre2k.exe /nameonly.\Pre2k.exe /domain:contoso.com.\Pre2k.exe /username:DOMAIN\user /password:Password123.\Pre2k.exe /timeout:15.\Pre2k.exe /helpexecute-assembly C:\path\to\Pre2k.exe
execute-assembly C:\path\to\Pre2k.exe /emptyonly
execute-assembly C:\path\to\Pre2k.exe /domain:contoso.com
[*] Querying domain for computer accounts...
[+] Found 1523 computer accounts
[*] Testing authentication...
[*] Progress: 50/1523
[*] Progress: 100/1523
[!] SUCCESS: DC01$ - Empty password
[*] Progress: 150/1523
[!] SUCCESS: LEGACY-SRV$ - Password matches machine name
[*] Progress: 200/1523
...
[+] Scan complete. 2 vulnerable accounts found.
| Parameter | Type | Required | Description |
|---|---|---|---|
-EmptyPasswordOnly |
Switch | No | Only test empty passwords |
-MachineNameOnly |
Switch | No | Only test machine name passwords |
-Username |
String | No | Custom username (must be paired with Password) |
-Password |
SecureString | No | Custom password (must be paired with Username) |
-Domain |
String | No | Target domain (default: current domain) |
-TimeoutSeconds |
Int | No | Authentication timeout in seconds (default: 10) |
-Verbose |
Switch | No | Enable verbose logging |
| Parameter | Type | Required | Description |
|---|---|---|---|
/emptyonly |
Flag | No | Only test empty passwords |
/nameonly |
Flag | No | Only test machine name passwords |
/username:<user> |
String | No | Custom username (must be paired with password) |
/password:<pass> |
String | No | Custom password (must be paired with username) |
/domain:<domain> |
String | No | Target domain (default: current domain) |
/timeout:<seconds> |
Int | No | Authentication timeout in seconds (default: 10) |
/help or /? |
Flag | No | Show help message |
- PowerShell 3.0 or later
- Network access to Active Directory
- Sufficient permissions to query computer objects (typically Domain Users)
- Domain-joined machine or network connectivity to domain controllers
- .NET Framework 4.0 or later
- Network access to Active Directory
- Sufficient permissions to query computer objects (typically Domain Users)
- Can run from non-domain-joined machines with proper credentials
Pre-Windows 2000 compatible computer accounts are created when the "Assign this computer account as a pre-Windows 2000 computer" option is selected during computer creation or when older deployment methods are used. These accounts have:
userAccountControlattribute value of 4128 (PASSWD_NOTREQD=32 + WORKSTATION_TRUST_ACCOUNT=4096)- Default password set to the lowercase machine name (without
$suffix, limited to first 14 characters) - Example:
WORKSTATION01$has default passwordworkstation01
Accounts that were pre-created but never joined to the domain retain this weak password indefinitely, allowing unauthorized authentication.
Both implementations use this LDAP filter:
(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=4128))
This uses the bitwise AND matching rule (1.2.840.113556.1.4.803) to efficiently find accounts with the pre-Windows 2000 flag.
Both implementations test authentication using LDAP Simple Bind via DirectoryEntry with:
- Format:
DOMAIN\COMPUTERNAME$ - Passwords: Empty string (
"") and lowercase machine name - Timeout: Configurable (default 10 seconds) to prevent hanging
- Error Handling: Silently handles expected authentication failures, only reports successes
- Uses paged searches (
PageSize = 1000) for efficient queries in large domains - Only retrieves necessary attributes (
sAMAccountName,dNSHostName,userAccountControl) - Progress updates every 50 computers to minimize output noise
- Timeout prevents hanging on unreachable domain controllers
To recompile the C# version:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /target:exe /out:Pre2k.exe Pre2k.csOr using PowerShell:
Add-Type -Path .\Pre2k.cs -OutputAssembly .\Pre2k.exe -OutputType ConsoleApplicationThis tool is designed for:
- Security assessments by authorized personnel
- Penetration testing with proper authorization
- Red team operations with appropriate scope
- Security audits to identify weak configurations
Defenders can use this tool to:
- Identify pre-Windows 2000 compatible accounts in their environment
- Remediate by resetting passwords or disabling accounts
- Monitor for creation of new vulnerable accounts
- Validate remediation efforts
To fix identified vulnerabilities:
# Reset computer account password
Reset-ComputerMachinePassword -Server DC01
# Or disable unused accounts
Disable-ADAccount -Identity "COMPUTERNAME$"
# Or remove pre-Windows 2000 flag
Set-ADComputer -Identity "COMPUTERNAME$" -Replace @{userAccountControl=4096}Defenders should monitor for:
- Multiple LDAP queries with the bitwise filter for
userAccountControl:1.2.840.113556.1.4.803:=4128 - Repeated authentication attempts against multiple computer accounts
- Authentication from unusual sources using computer account credentials
- Failed authentication attempts against computer accounts (may indicate scanning)
- Verify network connectivity to domain controller
- Ensure current user has permissions to query AD
- Check domain name is correct (if specified)
- Try running with
-Verboseflag to see detailed errors
- Verify username format (should be
DOMAIN\username) - Ensure password is correct
- Check user has permissions to access AD
- Verify domain name is correct
- Increase
-TimeoutSecondsfor slow networks - Ensure domain controllers are responsive
- Check network bandwidth and latency
- Consider targeting specific OUs (requires code modification)
- This is good! It means no pre-Windows 2000 accounts have weak passwords
- Verify the query is finding accounts with
-Verboseflag - Check that accounts haven't been remediated
This tool is inspired by and builds upon the excellent work of the original pre2k tool by @unsigned_sh0rt (Garrett Foster) and @Tw1sm.
The original pre2k tool demonstrated the methodology for identifying and exploiting pre-Windows 2000 computer account vulnerabilities in Active Directory environments. Their Python-based implementation provided the foundation and inspiration for this PowerShell and C# reimplementation.
Original Repository: https://github.com/garrettfoster13/pre2k
We're grateful for their research, development, and contribution to the security community. Their tool has been invaluable for penetration testers and red teamers conducting Active Directory assessments.
Additional research and methodology based on work from:
- TrustedSec - Pre-created computer account research
- Optiv - Active Directory security assessments
- Various security researchers in the Active Directory security community
This tool is provided for authorized security testing and assessment purposes only. Users are responsible for ensuring they have proper authorization before running this tool against any systems.
This tool is provided "as is" without warranty of any kind. The authors are not responsible for any misuse or damage caused by this tool. Always obtain proper authorization before performing security assessments.