Created
January 4, 2025 18:15
-
-
Save mickmon/77045203a0fbe89016f7a4a11cc52511 to your computer and use it in GitHub Desktop.
A 2nd script attempting to use a list of passwords against a gpg key (but I'm not sure if really guessing the gpg key password)
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 | |
# File containing passwords to test | |
PASSWORD_FILE="password_combinationsZ2.txt" | |
# The key ID you want to test against | |
KEY_ID="1AB1E7A23BB73E4D" # Replace with your key ID (e.g., FA60B8E6A5A8D435) | |
if [ ! -f "$PASSWORD_FILE" ]; then | |
echo "Password file not found: $PASSWORD_FILE" | |
exit 1 | |
fi | |
# Function to flush the GPG agent cache | |
flush_gpg_agent() { | |
gpgconf --kill all | |
} | |
while IFS= read -r passphrase; do | |
echo "Trying password: $passphrase" | |
# Flush the GPG agent cache | |
flush_gpg_agent | |
# Test the passphrase with --passwd and --dry-run | |
echo "$passphrase" | gpg --batch --pinentry-mode=loopback --passphrase-fd=0 --dry-run --passwd "$KEY_ID" --status-fd=1 2>/dev/null | grep -q "GOOD_PASSPHRASE" | |
# Check if "GOOD_PASSPHRASE" was found in the output | |
if [ $? -eq 0 ]; then | |
echo "Success! Correct password is: $passphrase" | |
exit 0 | |
fi | |
done < "$PASSWORD_FILE" | |
echo "No valid password found." | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment