Credentials In Files
Adversaries may search local file systems and remote file shares for files containing insecurely stored credentials. These include user-created credential files, shared credential stores, configuration files with embedded passwords, and source code containing hardcoded credentials. Threat actors and malware including Emotet, APT33, LaZagne, Pupy, PoshC2, and Smoke Loader actively search for credential files. Commonly targeted files include web.config, applicationHost.config, .htaccess, unattend.xml (Group Policy Preferences), cloud credential files (~/.aws/credentials, ~/.azure/accessTokens.json), and any plaintext files with 'password' in the content.
// Detect credential file search and access
let CredentialFilePaths = dynamic([
".aws/credentials", ".azure", "accessTokens.json", "credentials.json",
"unattend.xml", "sysprep.xml", "web.config", "applicationHost.config",
"passwd", "shadow", ".htpasswd", "id_rsa", "id_ecdsa", "id_ed25519",
"ConsoleHost_history.txt", ".bash_history", ".zsh_history",
"KeePass", "1Password", "passwords.txt", "creds.txt", "logins.json"
]);
let SearchToolPatterns = dynamic([
"findstr", "Select-String", "grep", "dir /s", "Get-ChildItem",
"type ", "cat ", "LaZagne", "mimikatz"
]);
DeviceProcessEvents
| where Timestamp > ago(24h)
// Credential file access via search tools
| where ProcessCommandLine has_any (CredentialFilePaths)
and ProcessCommandLine has_any (SearchToolPatterns)
| extend SearchTool = case(
ProcessCommandLine has "findstr", "findstr",
ProcessCommandLine has "Select-String", "Select-String",
ProcessCommandLine has "Get-ChildItem", "Get-ChildItem",
ProcessCommandLine has "LaZagne", "LaZagne",
"Other"
)
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, SearchTool
| union (
// Detect direct file access to known credential file locations
DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType == "FileRead" or ActionType == "FileAccessed"
| where FolderPath has_any (".ssh", ".aws", ".azure", "PSReadline",
"Unattend", "SYSVOL", "sysprep")
and (FileName has_any ("credentials", "password", "id_rsa", "history",
"unattend", "sysprep", "accessTokens") or
FileName endswith ".pem" or FileName endswith ".ppk" or
FileName endswith ".p12" or FileName endswith ".pfx")
| where InitiatingProcessFileName !in~ ("explorer.exe", "OneDrive.exe", "backup.exe")
| project Timestamp, DeviceName, InitiatingProcessAccountName, FolderPath, FileName,
InitiatingProcessFileName, InitiatingProcessCommandLine
)
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- Backup agents legitimately reading configuration files and credential stores as part of system backup operations
- Security scanning tools (Tenable, Qualys) that enumerate credential files during vulnerability assessments
- Configuration management tools (Ansible, Chef, Puppet) reading configuration files including those containing credentials
- Password managers and single sign-on agents that legitimately access credential file locations
- IT auditing scripts that scan for hardcoded credentials as a security best practice enforcement measure
References (7)
- https://attack.mitre.org/techniques/T1552/001/
- https://github.com/AlessandroZ/LaZagne
- https://obscuresecurity.blogspot.com/2012/05/gpp-passwords-in-group-policy.html
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1552.001/T1552.001.md
- https://specterops.io/blog/cloud-credential-storage/
- https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html
- https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-scenarios
Unlock Pro Content
Get the full detection package for T1552.001 including response playbook, investigation guide, and atomic red team tests.