This cheatsheet provides grep alternatives for Windows CMD and PowerShell to search for usernames, passwords, hashes, API keys, and database connection strings.
CMD does not have grep, but you can use findstr instead.
findstr /R /I "username[:=].* password[:=].*" /S C:\path\to\folder\*.*β Matches:
username=admin
password:SuperSecret123
findstr /R /I "[a-f0-9]\{32,64\}" /S C:\path\to\folder\*.*β Matches:
5f4dcc3b5aa765d61d8327deb882cf99 # MD5
d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2 # SHA1
findstr /R /I "mysql:\/\/.*:.*@.*" /S C:\path\to\folder\*.*β Matches:
mysql://root:BackDropJ2024DS2024@127.0.0.1/backdrop
postgresql://admin:SuperSecure123@localhost:5432/mydb
findstr /R /I "api[_\-]?key[=:].*" /S C:\path\to\folder\*.*β Matches:
api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
apiKey='AKIAIOSFODNN7EXAMPLE'
PowerShell provides more powerful filtering with Select-String.
Get-ChildItem -Path "C:\path\to\folder" -Recurse | Select-String -Pattern "username[:=].* password[:=].*" -CaseSensitiveβ Matches:
username=admin
password=SuperSecret123
Get-ChildItem -Path "C:\path\to\folder" -Recurse | Select-String -Pattern "[a-f0-9]{32,64}" -CaseSensitiveβ Matches:
5f4dcc3b5aa765d61d8327deb882cf99 # MD5
d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2 # SHA1
Get-ChildItem -Path "C:\path\to\folder" -Recurse | Select-String -Pattern "([a-zA-Z_]*\s*=\s*[\"']?[a-z]+:\/\/[a-zA-Z0-9._%-]+:[a-zA-Z0-9%^&*()_+=-]+@[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+)" -CaseSensitiveβ Matches:
mysql://root:BackDropJ2024DS2024@127.0.0.1/backdrop
postgresql://admin:SuperSecure123@localhost:5432/mydb
Get-ChildItem -Path "C:\path\to\folder" -Recurse | Select-String -Pattern "(api[_\-]?key[=:].*|aws[_\-]?secret[_\-]?access[_\-]?key[=:].*)" -CaseSensitiveβ Matches:
api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
aws_secret_access_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
reg query HKLM /f "password" /t REG_SZ /s
reg query HKCU /f "password" /t REG_SZ /sβ Finds stored passwords in registry keys.
| Feature | CMD (findstr) |
PowerShell (Select-String) |
|---|---|---|
| Search for "username:password" | β | β |
| Search for Hashes | β | β |
| Search for Database Connections | β | β |
| Search for API Keys | β | β |
| Search in Windows Registry | β | β |
βοΈ Find hardcoded passwords, API keys, and hashes in config files, logs, and scripts.
βοΈ Useful for pentesting, security audits, and incident response.