Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I received a pdf file few days back, the pdf file was password protected with a 5 digit number varying from 20000 to 25999. Unfortunately I forgot the password but still I remember that it falls within the mentioned set of numbers. Manually its really difficult for me to try each and every alternative one after another.

Kindly let me know if I want a brute force mechanism (or some other better option) then how to achieve this.

share|improve this question

migrated from stackoverflow.com Jun 8 '13 at 15:12

This question came from our site for professional and enthusiast programmers.

    
Don't know how to do it in java, but should be easy with AutoIt. –  mwerschy Jun 8 '13 at 12:51
    
Okular with ignore author rights option? –  yttrium Jun 8 '13 at 12:52
    
Do you really need a Java solution? –  Qantas 94 Heavy Jun 8 '13 at 12:52
    
No need of java. Just need to recover it anyhow and thats it. I thought if nothing is available then will try in Java as the last option. –  user182944 Jun 8 '13 at 12:52
1  
@Hennes: Which PDF apps are you talking about? It's been years since I've used Adobe's useless offering, and as far as I remember neither Foxit nor Sumatra nor the others ignored the user password. Older versions might have ignored the owner password (that restricts printing, copying etc.), but not the user password that prevented opening the file. –  Karan Jun 8 '13 at 15:59
show 10 more comments

1 Answer

On Linux/Unix/Cygwin you could automate the decryption by using qpdf and a loop that goes through all possible combinations:

#!/bin/bash

echo "Decrypting PDF file"

for i in $(eval echo "{20000..25999}"); do

echo "try nr. $i"
qpdf --password=$i --decrypt input.pdf output.pdf

RET=$?
if [[ $RET == 0 ]]; then
  echo "File succesfully decrypted."
  exit
fi

done

Others might be able to help you with getting this to work on Windows.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.