Credential Harvesting from Web Configs
Web application configuration files contain the most reliable credentials on a target — database passwords, API keys, SMTP credentials, and cloud access tokens that must exist for the application to function. These rarely change and are often reused across services. Collect them immediately after gaining shell access, before attempting privilege escalation.
Find Configuration Files
Locate common config file locations across all web applications on the server:
/var/www/html/.env /var/www/html/config/database.yml /opt/app/settings.py
Extract Credentials from Common Config Formats
APP_KEY=base64:abc123== DB_HOST=127.0.0.1 DB_DATABASE=webapp DB_USERNAME=webapp_user DB_PASSWORD=SuperSecret123! MAIL_PASSWORD=smtp_password AWS_ACCESS_KEY_ID=AKIA... AWS_SECRET_ACCESS_KEY=wJalr...
$db_host = 'localhost'; $db_user = 'root'; $db_pass = 'r00tpassword!'; $api_key = 'sk-prod-abc123xyz';
define('DB_NAME', 'wordpress');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'wp_password123');
define('DB_HOST', 'localhost');
SECRET_KEY = 'django-insecure-abc123'
DATABASES = {'default': {'PASSWORD': 'db_password_here'}}
Bulk Credential Search
Search all web application files recursively for credential patterns. This catches credentials embedded in source files outside of dedicated config files:
/var/www/html/includes/db.php:3:$password = 'admin123!'; /var/www/html/.env:8:DB_PASSWORD=SuperSecret123!
Database Credential Reuse Testing
Use extracted database credentials to connect directly and dump further data:
Environment Variables
Running processes may have credentials injected through environment variables not visible in config files. Check the web server process environment:
SSH Keys and Cloud Credentials
Check home directories reachable from the web server user for SSH keys and cloud credentials:
/var/www/.ssh/id_rsa /home/developer/.ssh/id_rsa
A readable SSH private key allows direct SSH login as the key owner. Test immediately against the target itself and any other hosts discovered through network enumeration. Cloud credentials enable lateral movement into the cloud environment from your Kali machine.
References
-
Automated secret scanning across filesystems and git history
Was this helpful?
Your feedback helps improve this page.