Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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
@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
up vote 3 down vote accepted

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


echo "Decrypting PDF file"

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

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

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


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

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .