#!/bin/bash
echo "===== 1: all DB credential definitions in PHP configs (dedup)"
grep -rhoiE "(define\s*\(\s*['\"](DB_USER|DB_PASSWORD|DB_NAME|DB_HOST|DB_PASS)['\"]\s*,\s*['\"][^'\"]*['\"]|\\\$(db_?user|db_?pass(word)?|db_?name|db_?host)\s*=\s*['\"][^'\"]*['\"]|'(user|password|username|dbname)'\s*=>\s*'[^']*')" \
  --include=*.php /home/ara/public_html /home/ara/common /home/ara/websites 2>/dev/null | sed "s/'/'/g" | sort | uniq -c | sort -rn | head -40
echo "===== 2: config files list"
find /home/ara -maxdepth 4 \( -name 'wp-config.php' -o -name 'configuration.php' -o -name '*config*.inc' -o -name '*config*.inc.php' -o -name '.env' \) -type f 2>/dev/null | head -40
echo "===== 3: SMTP / mail creds"
grep -rhoiE "(smtp_(user|pass|username|password|host)[\"']?\s*[:=>]+\s*[\"'][^\"']+[\"']|MAIL_(USERNAME|PASSWORD|HOST)[\"']?,?\s*[\"'][^\"']+[\"'])" --include=*.php --include=*.inc /home/ara/public_html /home/ara/common 2>/dev/null | sort -u | head -25
echo "===== 4: mysql sockets accessible as root"
mysql -uroot -N -e "SELECT VERSION(), @@datadir, @@hostname" 2>&1
