Cracking Microsoft Office (97-03, 2007, 2010, 2013) password hashes with Hashcat

For anyone that is not familiar with it, Hashcat is one of the most well known password cracking tools at the moment, primarily due to it’s lightning fast speed. There are several versions of the tool, allowing it to take advantage of different platforms, including ocl-hashcat and cuda-hashcat.

On the latest update of the tool (October, 2014) there was a significant addition that did not get the buzz that it should have created. That is the ability to crack Microsoft Office password hashes across all different versions (97-2003, 2007, 2010, 2013). This addition appears to have been added only to the GPU enabled versions of hashcat (ocl-hashcat, cuda-hashcat) at the moment.

There are 6 different flag codes implemented for the 97-03 hashes (depicting different implementations of the hash) and one implementation for each of the other versions of Office, as shown below.

This guide will take you through how to use hashcat (we will use cuda-hashcat as an example) to crack Microsoft Office passwords. Important note: This is not a guide on how to install and use hashcat in general. There are a lot of other guides available on this topic, an example would be this one.

First of all, you will need a password protected document to extract a hash that needs to be cracked. For illustration purposes, I have created a Word 2007 document (example.docx) and protected it with the password “password12345“.

Our first move would be to acquire the hash from the actual document. This can be done through a python script called office2john.py (hint: you can use the hashes extracted through this script also with john the ripper).

To run office2john.py:

On our example the results would look like this:

We can see that in the beginning of the hash we can identify the version Office used by this hash ($office$*2007*) Now that we have retrieved our hash, its time to start the cracking! For hashcat to be able to recognise the hash as an office document, we have to use one of the following two options:

  • Remove the name of the document from the hash (up till the “:” symbol)
  • Add the – -username switch during the call of the hashcat, so that the name of the document will be treated as a username

Personally, I prefer the second option, as we don’t have to mess with the hash (which can be quite cumbersome if you need to do it for several documents).

To start the cracking procedure, we can call CudaHashcat on Windows with the following switches (all in one line):

Where the switches correspond to:

  • -a 0: Straight dictionary attack against the hash
  • -m <<Office_Flag>>: The corresponding flag for the version of Office in use (see above table)
  • –username: Ignore the username flag (needs to be added for Hashcat to recognise the hash correctly)
  • –status: Provides an update of the status of the process without giving a prompt
  • -o <<Output_File>>: The location where the cracked hashes will be saved. The results will also be saved on the .pot file, unless otherwise specified
  • <<Hash>>: The saved password hash.
  • <<Dictionary>>: The list of words that will be used to try and crack the password. You can find some good wordlists here

To crack our example document, we can run the following command:

The results should look similar to this:

Depending on your machine, you will be amazed by the speed of the tool. On my machine, which is not built for password hashing, the average speed of cracking during bruteforcing was 3000 Hashes per second (H/s).If the password is successfully cracked, you will find it in the output file specified and in the cudaHashcat.pot file in the format Hash:Password.

4 thoughts on “Cracking Microsoft Office (97-03, 2007, 2010, 2013) password hashes with Hashcat

  1. Thanks for the well presented and to the point procedure. Extremely helpful and Still relevant today. ON PERFORMANCE: In terms of performance for my Office2007 excel file, getting around 80K H/s on a Nvidia 980 Overclocked.

Leave a Reply

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

Captcha: * Time limit is exhausted. Please reload the CAPTCHA.