MITRE ATT&CK™ Unsecured Credentials: Credentials In Files - Technique T1552.00
Theory
We may search local file systems and remote file shares for files containing insecurely stored credentials. These can be files created by users to store their own credentials, shared credential stores for a group of individuals, configuration files containing passwords for a system or service, or source code/binary files containing embedded passwords.
Practice
Tools
Noseyparker is a command-line program that finds secrets and sensitive information in textual data and Git history. We can use this tool to recursively search sensitive information in a folder
# Scan filesystem / foldernoseyparkerscan--datastorenp.myDataStore/path/to/folder# Get resultsnoseyparkerreport-dnp.myDataStore
find command can be use to find configuration files by recursively searching files with a specific extension or name.
# Find all .conf filesfind/-typef-name*.conf2>/dev/null# Find all files containing "pass"find/-typef-name*pass*2>/dev/null
Hunting for passwords
Find command can be use to find passwords in files by recursively searching text patterns
# /s: recursive search# /i: Non case-sensitive searchfindstr /si password *.txtfindstr /si password *.xmlfindstr /si password *.ini# /p: Skips files with non-printable characters.# /n: Prints the line number of each line that matches.findstr /spin "password"*.*findstr /spin "password" c:\Users\Administrator\*
We may find passwords in registries using the reg command
# Registry subkey information# query: Returns a list of the next tier of subkeys and entries that are located under a specified subkey in the registry
# HKLM: The keyname of HKEY_LOCAL_MACHINE# /f: Specifies the data or pattern to search for.# /t: Specifies registry types to search.# /s: Specifies to query all subkeys and value names recursively.reg query HKLM /f password /t REG_SZ /s
Alternatively, we may find passwords in emails at the following locations