T1552.001

Credentials In Files

Sub-technique of T1552 Unsecured Credentials ↗

Finding passwords in config files, backups, shell histories or git repositories.

How it shows up on Hack The Box

Once in, check the web app's config (.env, wp-config.php, appsettings.json), SQLite databases, backups and git history: the database password is often a user's password.

Techniques in our catalog that match this one (the number is their machines):

Machines to practice it

Sorted from easiest to hardest. The ▶ link takes you to the minute of the IppSec video where it is used.

Showing 48 of 121. Open each catalog technique above to see them all.

Guides

Commands

Taken from our cheatsheets and tool pages. Type your details and they are filled into every command.

Web enumeration › Common findings

Review the history
cd repo && git log --oneline && git show HEAD~1
Search secrets in every commit
git log -p | grep -iE 'pass|secret|token|key'

Linux privilege escalation › Checks

Passwords in config files
grep -rniE '(pass(word)?|pwd|secret|token)\s*[=:]' /var/www /opt /etc /home 2>/dev/null | grep -v '^Binary'
Usual config files
find / \( -name '*.conf' -o -name '*.config' -o -name '.env' -o -name 'wp-config.php' -o -name '*.kdbx' \) -readable 2>/dev/null | grep -vE '^/(proc|sys|usr/share)'
History files
cat ~/.*history 2>/dev/null; ls -la /home/*/

Linux privilege escalation › Exploitation

adm (read logs)
grep -riE 'pass|login' /var/log 2>/dev/null

Windows and Active Directory privilege escalation › Windows

PowerShell history
type $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
Search passwords in files
findstr /si /m "password" C:\inetpub\*.config C:\Users\*.txt C:\Users\*.xml C:\Users\*.ini
PSCredential in XML
$c = Import-Clixml -Path cred.xml; $c.GetNetworkCredential().Password

git-dumper › From .git to the secret

Search secrets across the whole history
git log -p --all | grep -iE 'pass|secret|token|key'

Tools