Unprotecting Microsoft Word .docx document

Let’s say that you get a form, for example from the government, in Microsoft Word format. You need to fill in the fields which are supposed to be nicely laid out for you. However there are problems filling in those fields because of document formatting, Microsoft Word version incompatibility, etc. argh reasons. This wouldn’t happen in the beatiful word of Office productivity suite, would it?

You could easily fill in the form if you could simply just edit the document and put the text there. But this is prevented using Microsoft Word form password protection mechanism. You need to know the password to enable the editing of the document.

The documention “protection” is not actually very big protection at all. You simply have a flag in the .docx file telling “oh please dear user do not change my beautiful document and just try to have your text in the predefined fields”. The authors of the document are probably right and an average Joe will destroy the document formatting in Word. On the other hand if you know what you are doing you just can get your paperwork done. The password, saved inside the document, is not very much protection, as you can manually gut the document and flip the flag inside.

.docx is actually zip archive containing XML files and you can manipulate its contents with a text editor and ZIP program. Unzip:

mkdir temp
cd temp
unzip ../"KEHITTÄMISTUEN MAKSATUSHAKEMUS.docx"

Edit the unzipped file word/settings.xml using your favorite plain-text editor.

Remove attributes in the following element:

<w:documentProtection w:edit="forms" w:enforcement="1" 
  w:cryptProviderType="rsaFull" 
  w:cryptAlgorithmClass="hash" 
  w:cryptAlgorithmType="typeAny" 
  w:cryptAlgorithmSid="4" 
  w:cryptSpinCount="50000" 
  w:hash="iMNelgcwaqcjZrxjRjtl0SRWLpY=" 
  w:salt="ik/s9VEtUXAkIehywGuyqQ=="/>

Now it looks like:

<w:documentProtection />

Re-zip:

zip -ur ../KEHITTÄMISTUEN\ MAKSATUSHAKEMUS.docx *

Re-open in Microsoft Word.

Poof. The form protection is gone. Sip coffee and continue with your inspirating paper work.

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+