A comprehensive Bash script to detect and report secret leakage across your system, including environment variables, API keys, SSH keys, AWS credentials, and other sensitive information.
Shell can run natively out of the box without any hussle or configurations. :)
SlWatch scans your system for exposed secrets and sensitive credentials that could compromise security. It uses intelligent pattern matching and entropy analysis to identify potential secrets, then generates a detailed JSON report of findings.
- 🔍 Environment Variable Scanning: Detects secrets in environment variables
- 📁 File System Scanning: Searches for
.env,.pem,.keyfiles and SSH keys - ☁️ AWS Credentials Detection: Scans AWS config and credentials files
- 🔑 SSH Key Detection: Identifies private SSH keys in
~/.ssh - 🎯 Smart Detection: Uses keyword matching and entropy analysis
- 🔒 Security Controls: Multiple masking options for sensitive output
- 📊 JSON Reports: Generates detailed
secret_report.jsonfor further analysis - 🎨 Color-Coded Output: Easy-to-read terminal output with color highlighting
- Clone or download the repository
- Make the script executable:
chmod +x slwatch.sh
./slwatch.shPerforms a full system scan including environment variables, system files, AWS credentials, and SSH keys.
| Option | Description |
|---|---|
--env |
Scan only environment variables |
--keys |
Scan only key files (.pem, .key, SSH) |
--aws |
Scan only AWS credentials/config files |
--no-system |
Skip full system scan ($HOME traversal) |
--show-secrets |
Display full secret values ( |
--partial |
Partially mask secrets (show first 4 and last 4 characters) |
--help |
Display help information |
# Scan only environment variables
./slwatch.sh --env
# Scan AWS credentials only
./slwatch.sh --aws
# Scan only SSH and certificate keys
./slwatch.sh --keys
# Perform full scan with partial masking of secrets
./slwatch.sh --partial
# Show full secret values (dangerous - use carefully)
./slwatch.sh --show-secrets
# Scan without traversing the full $HOME directory
./slwatch.sh --no-system --env --awsSlWatch looks for these secret-related keywords (case-insensitive):
PASSWORD,PASSSECRET,API_KEY,APIKEYTOKENAWS_SECRETPRIVATE_KEYACCESS_KEYDB_PASSWORD
The script calculates Shannon entropy of values to identify potential secrets:
- Requires minimum length of 8 characters
- Must contain both letters and numbers
- Entropy threshold of > 3.5 bits
- Color-coded scan progress (cyan for scanning, green for findings)
- List of files containing secrets
- Scan summary with statistics
Example:
📊 Scan Summary
---------------------------
Total secrets: 15
Files scanned: 1,234
Generates secret_report.json with detailed findings:
[
{
"source": "environment",
"file": "system",
"variable": "API_KEY",
"value": "****"
},
{
"source": ".env file",
"file": "/path/to/.env",
"variable": "DATABASE_PASSWORD",
"value": "****"
}
]- Bash 4.0+
- Standard Unix tools:
find,grep,awk jq(for JSON report generation)
SlWatch scans the following sources:
- Environment Variables: All current shell environment variables
- System Files:
.envand key files (*.pem,*.key) in$HOME - AWS Credentials:
~/.aws/credentialsand~/.aws/config - SSH Keys: All files in
~/.sshdirectory
SlWatch/
├── slwatch.sh # Main script
├── secret_report.json # Generated report (auto-created)
└── README.md # This file
See LICENSE file for details..
Here is a blog post for that tool. Enjoy! :)
Finally, here is a demonstration of the program in action!
Developed by Marios Daskalas





