13

I need to resize a pdf file to crop its surrounding white border. I can crop it using PDF-Shuffler on Ubuntu. But cant save the change, because of owner password protection. When i try to open that file using PDF-Editor, it asked for that password.

Since I dont know that owner password, so cant use regular recovery system. There are lots of online system too, but thats very slow process even most of those cant remove owner password. Now looking for a script/software specially for Ubuntu to remove that owner password.

Sadat
  • 243

2 Answers2

17

On Ubuntu you can use the following commands to decrypt PDFs with forgotten Owner Passwords trivially:

  1. Install package qpdf:

    sudo apt-get install qpdf
    
  2. Decrypt PDF:

    qpdf --decrypt encrypted_document.pdf decrypted_document.pdf
    

Notes:

  1. The above instructions assume that you are trying to decrypt a PDF with a forgotten Owner Password (i.e. you can open the PDF and view its content but are restricted from making changes, prints, etc. without the password). These types of encrypted PDFs are trivial to decrypt and don't require tools like pdfcrack or hashcat (dictionary/brute force password crackers)

  2. On the other hand a PDF with a forgotten User Password (i.e. you cannot view the content of the PDF without supplying the password) will require PDF dictionary/brute force password crackers and you are not always guaranteed to find the password. If however you do have the User Password and simply want to save a decrypted version of the PDF you can do this to with qpdf as follows:

    qpdf --password=ENTER_PASSWORD --decrypt encrypted_document.pdf decrypted_document.pdf
    
  3. Windows binaries of qpdf can also be downloaded from http://qpdf.sourceforge.net/

moo
  • 1,620
3

Ubuntu repositories have a tool called pdfcrack that can be installed using the package manager. This can attempt to brute-force (guess) the password for you.

Important note: in many countries the penalties for circumventing encryption are very severe. Be sure you have the legal right to crack the password before continuing.

Open a terminal and do something like this:

sudo apt-get install pdfcrack
pdfcrack -f MYFILE.PDF
dwurf
  • 406
  • In the USA you could be performing illegal activities if PDF cracking falls under the DMCA. While I don't think they're going to knock down your doors, it's important to know. Since I'm in Canada, I appreciate now knowing about pdfcrack, for those one-off's. – BloodyIron May 01 '12 at 16:43
  • @dwurf, thanks a lot. I will try it and remember your warning. – Sadat May 01 '12 at 17:23
  • @dwurf,pdfcrack cant detect OWNER PASSWORD PROTECTION. – Sadat May 01 '12 at 17:25
  • @Sadat from the website: - Supports cracking both owner and userpasswords – dwurf May 01 '12 at 21:24
  • 1
    On ubuntu 18.04: "pdfcrack -f file.pdf" - got an error, "The specific version is not supported (standard - 6)" – Harry May 15 '21 at 13:51