From 211c936fc9fb58869899e98ff6b7181755fdec8f Mon Sep 17 00:00:00 2001 From: Marco <17599847+melone2@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:48:58 +0100 Subject: [PATCH] Change show attempt number instead of password while trying passwords --- bin/decrypt-pdf | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/decrypt-pdf b/bin/decrypt-pdf index f9a5053..6ea4d4c 100644 --- a/bin/decrypt-pdf +++ b/bin/decrypt-pdf @@ -12,21 +12,23 @@ fi passwords=($(cat "$password_file")) - encryption_info=$(qpdf --show-encryption "$input_file" 2>&1) +declare -i counter=0 + if [[ $encryption_info == *"Incorrect password supplied"* ]]; then echo "PDF is encrypted. Trying passwords..." for password in "${passwords[@]}"; do + let counter+=1 # increment qpdf --warning-exit-0 --password="$password" --decrypt "$input_file" "$output_file" >/dev/null 2>&1 if [ $? -eq 0 ]; then - echo "PDF decrypted successfully with password: $password" + echo "PDF decrypted successfully with password on attempt $counter" echo "Output saved to $output_file" exit 0 else - echo "Failed to decrypt the PDF with password: $password" + echo "Attempt $counter: Failed to decrypt the PDF" fi done