Created
June 27, 2025 04:46
-
-
Save enderphan94/f1f46d5076bfa03f448cb72f886489d5 to your computer and use it in GitHub Desktop.
findCred.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ./findCred.sh /path/to/your/directory | |
# Check if directory is provided | |
if [ -z "$1" ]; then | |
echo "Usage: $0 /path/to/directory" | |
exit 1 | |
fi | |
TARGET_DIR=$1 | |
# Check if trufflehog is installed | |
if ! command -v trufflehog &> /dev/null | |
then | |
echo "trufflehog is not installed. Please install it: https://github.com/trufflesecurity/trufflehog" | |
exit 1 | |
fi | |
# Check if gitleaks is installed | |
if ! command -v gitleaks &> /dev/null | |
then | |
echo "gitleaks is not installed. Please install it: https://github.com/gitleaks/gitleaks" | |
exit 1 | |
fi | |
echo "Starting combined scanning on directory: $TARGET_DIR" | |
echo "Results will be saved in trufflehog_results.txt and gitleaks_results.txt" | |
# Run trufflehog | |
echo "Running trufflehog scan..." | |
trufflehog filesystem "$TARGET_DIR" > trufflehog_results.txt | |
echo "trufflehog scan completed." | |
# Run gitleaks | |
echo "Running gitleaks scan..." | |
gitleaks detect --source "$TARGET_DIR" --report-path=gitleaks_results.json | |
echo "gitleaks scan completed." | |
# Run ripgrep for additional keyword search | |
if ! command -v rg &> /dev/null | |
then | |
echo "ripgrep (rg) is not installed. Skipping additional keyword search." | |
else | |
echo "Running ripgrep keyword search..." | |
rg -i 'AKIA[0-9A-Z]{16}|secret|password|apikey|token|Authorization' "$TARGET_DIR" > ripgrep_results.txt | |
echo "ripgrep keyword search completed." | |
fi | |
echo "Scanning completed." | |
echo "Review the following files for potential secrets:" | |
echo "- trufflehog_results.txt" | |
echo "- gitleaks_results.json" | |
if [ -f ripgrep_results.txt ]; then | |
echo "- ripgrep_results.txt" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment