19.Credential-hunting
Credential Hunting Commands
Search for "password" in common configuration file types
findstr /SIM /C:"password" *.txt *.ini *.cfg *.config *.xmlSearch for "password" in Chrome's Custom Dictionary
gc 'C:\Users\<user>\AppData\Local\Google\Chrome\User Data\Default\Custom Dictionary.txt' | Select-String passwordGet PowerShell history file path
(Get-PSReadLineOption).HistorySavePathRead PowerShell command history
gc (Get-PSReadLineOption).HistorySavePathExtract PowerShell history from all user profiles
foreach($user in (Get-ChildItem C:\users).FullName){
Get-Content "$user\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt" -ErrorAction SilentlyContinue
}Credential Extraction from XML
Import credentials from an XML file
Extract username from the credential object
Extract password from the credential object
Key Concepts:
Credential Discovery:
Locating stored passwords and other sensitive information.
Can lead to local or domain privilege escalation.
Application Configuration Files:
Plaintext or weakly encrypted credentials in configuration files.
Dictionary Files:
User-added words in application dictionaries (e.g., Chrome).
Unattended Installation Files:
unattend.xmlfiles with auto-logon or account creation credentials.
PowerShell History:
Command history containing credentials.
PowerShell Credentials:
Encrypted credentials using DPAPI.
Approach, Commands, Tools, and Techniques:
Application Configuration Files:
findstr /SIM /C:"password" *.txt *.ini *.cfg *.config *.xml(Search for keywords).Manual inspection of
web.configfiles.
Dictionary Files:
gc 'C:\Users\<user>\AppData\Local\Google\Chrome\User Data\Default\Custom Dictionary.txt' | Select-String password(Read Chrome dictionary).
Unattended Installation Files:
Manual inspection of
unattend.xmlfiles.
PowerShell History:
(Get-PSReadLineOption).HistorySavePath(Get history file path).gc (Get-PSReadLineOption).HistorySavePath(Read history file).foreach($user in ((ls C:\users).fullname)){cat "$user\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt" -ErrorAction SilentlyContinue}(Read all accessible history files).
PowerShell Credentials:
Import-Clixml -Path 'C:\scripts\pass.xml'(Import credential object).$credential.GetNetworkCredential().username(Get username).$credential.GetNetworkCredential().password(Get password).
Commands:
findstrgc(Get-Content)(Get-PSReadLineOption).HistorySavePathImport-Clixml
Tools:
PowerShell.
Techniques:
File searching.
PowerShell scripting.
DPAPI abuse (if applicable).
Last updated