Unlock a PDF with pdfcrack, the best option for Linux

unlock a pdf

How to Live Aligned with we promised a few days ago, today we bring you a tutorial with which we can unlock a PDF password locked. Logically, what is explained in this article will be to recover a password that we have lost or forgotten, which could mean the loss of data from a PDF due to our bad memory. The article we wrote a few days ago was for convenience, while this is to be able to access a file that we cannot access.

The tool that we are going to talk about today is called pdf crack. You have to bear in mind that these types of tools do not work miracles and that, depending on the strength of a password, it may never be recovered. The system used to decrypt the password is brute force and the process is long, not so much because of what we have to do but because of the time it could take to finish the job. We detail the process below:

How to unlock a PDF with pdfcrack

As the process will be long, we go directly to explain the steps:

  1. pdfcrack is available in most of the official repositories of the different Linux distributions. In Ubuntu and derivatives it can be installed with the command "sudo apt install pdfcrack" without the quotes.
  2. Once installed, we will run the tool with the command:
pdfcrack -f nombre_del_archivo.pdf

NOTE: : for the clueless, when we put the name of a file we refer to the complete path. This means that either we go into its directory in the terminal before executing the process with only the name of the file or we drag it to the terminal and in distributions like Ubuntu we remove the quotes.

The process can be very long, and more considering that pdfcrack just use a processor. Of course, you can use 100% of it. To speed up the process, we can add characters to test it, for which we will use the -c option. This will give you a starting point and can be helpful if we always use a pattern. For example, the following command would be if I used passwords with the word "car" and numbers.

pdfcrack -f nombre_del_archivo.pdf -c coche1234

If, for whatever reason, we want stop the process we can do it with Ctrl + C. At the moment we press it, pdfcrack will try to save the state of the process, which means that we can follow it later. The process file is usually saved with the name "savedstat.sav" in our personal folder and to follow it we will use the -1 option. The command would look like this:

pdfcrack -f nombre_del_archivo.pdf -1 savedstate.sav

Another option that we can configure is the minimum number of characters. Taking into account that we know each other, we can know what we usually put in the passwords. For example, I usually use the generators on my devices or the DuckDuckGo! Bang designed to generate random passwords. In the second case, I usually put 12. The option is -n = length, where "length" is the number of characters. The command would look like this:

pdfcrack -f nombre_del_archivo.pdf -n=12

If instead of "-n" we put "-m", we will be telling you how many characters it will have at most. The following example indicates that you must have a maximum of 20:

pdfcrack -f nombre_del_archivo.pdf -m=20

Combining pdfcrack options

Like many terminal tools, pdfcrack allows us to combine options to facilitate the process of unlocking a pdf. To do this, you just have to leave a space between option and option. An example would be the following:

pdfcrack -f nombre_del_archivo.pdf -m=20 -n=12 -c 100690

With the previous command we will have told you that:

  • The password has a minimum of 12 characters.
  • The maximum that you must combine is 20 characters.
  • The password has at some point the characters "100690". They do not need to be ordered.

As we have explained, this can be worth if we usually use a system to generate our passwords. Until a few years ago when it was news that Yahoo! had been hacked, I used a system in which I added my date of birth. If I had been born on June 10, 1990 and used those numbers, adding them would make the process much easier.

Other available options are:

  • -w: to open a text file where we configure several words. This is what is known as a dictionary. Many tools that use brute force to crack passwords have a dictionary or option to add it to them.
  • -o: to work with the password of an owner.
  • -p: provides a user's password to facilitate obtaining an owner's password.
  • -s: permutation is limited to changing the first word to upper case.
  • -b: it will show us some benchmarks to see the performance of pdfcrack during the process.

Pdfcrack options

All this appears if we execute the command «pdfcrack» without adding any option or file to it. It is the same as in other programs if we add "help", "?" or something similar.

Unlock a pdf faster

The problem with pdfcrack is that it only uses one processor. The good? That we can launch up to three processes with three different cores, all in the same terminal window. To do this, as in other terminal commands, we will add the letter "&" between commands. For instance:

pdfcrack -f prueba.pdf & pdfcrack -f prueba.pdf -c ccoeh & pdfcrack -f prueba.pdf -c 100690 -n=5

With the above, one of the options will search in general, the second will search with the letters «ccoeh» and the third with the numbers «100690».

PDF password

In the example that I bring you, I have protected the file «test.pdf« with the password «car» (hence the letters above). As you can see, he has achieved it thanks to the second option that I have indicated. In a case where we put the letters it should have, the result is instantaneous, it does not last a second on a not very powerful computer.

Once we have finished, if we want to make sure that pdfcrack stops running, we will write the command:

killall pdfcrack

In the event that it is something very important, the best we can do is save the sessions and continue them at another time. This allows us to turn off the computer whenever we want, so, no time limit, there should be no password to resist us.

Do you already know how to unlock a PDF with this powerful tool?


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.