Friday, 23 July 2010


As regular readers will know here in the Sausage Factory our primary forensics tool is Encase. From time to time however we need to try out other tools to validate our results. Recently I wanted to utilise two python scripts widely discussed elsewhere and as a result had to figure out the mechanics of getting these scripts to run on a forensic workstation running Windows 7. I thought I'd share the process with you. Now some of you are highly geeky programmer types who write and run scripts for breakfast - if thats you turn away now. This blog post is in no way definitive and is intended for python newbies wishing to run python scripts in their forensicating but who until now didn't know how.

First off we need to install and configure Python

  • Download Python - I downloaded Python 2.7 Window X86-64 installer for my Windows 7 64 bit box
  • Run the installer
  • Right click on the Computer icon, select properties, select Advanced system settings and click on the Environment Variables button.
  • In the System Variables pane you will have a variable entitled Path, select it and click on edit
  • Add to the entries already there ;C:\Python27 (assuming you installed Python 2.7 to the default location)

The two scripts I wanted to run were David Kovar's analyzeMFT and the $USNJRNL parser written by Seth Nazzaro. They are designed to parse MFTs and USN Change Journals respectively which can be copied out of an image or made available via VFS or PDE. More about analyzeMFT can be found at the author's blog. Detailing how I ran these scripts will give a clear indication of how to run these, and many other python scripts, and utilise their output.

Download script by visiting and right clicking on the Downloaded Here link in the Downloads section (for the source code) and saving the download as a text file. Once downloaded change the file extension to .py.

Save it somewhere and then run IDLE (installed with Python) and open the script. Locate the words noGUI = False and edit to read noGUI = True and save.

To run

  • open command prompt
  • at prompt type Python C:\Path_to_the_script\ -f U:\Path_to_your_extracted_or_mounted_MFT\$MFT -o $MFT_parsed
  • The above command runs the script against your extracted or mounted $MFT and outputs the results to a file $MFT_parsed
  • Open $MFT_parsed using the text import wizard in Excel selecting the text format for each column.

Thanks to David Kovar for making this script available.

$USNJRNL•$J Parser
This script can be downloaded at

To run

  • open command prompt
  • at prompt type Python C:\Path_to_the_script\ -f U:\Path_to_your_extracted_or_mounted_USNJRNL•$J\USNJRNL•$ -o Output_file -c
  • The above command runs the script against your extracted or mounted $USNJRNL•$J and outputs the results to Output_file.csv

Typing at the command prompt Python wil give some help about a scripts options. For example Python results in the output

Usage: [options]
-h, --help show this help message and exit
input file name
output file name (no extension)
-c, --csv create Comma-Separated Values Output File
-t, --tsv create Tab-Separated Values Output File
-s, --std write to stdout

I have installed Python 2.7. There are other (and later) versions available including some that are not completely open source. It is also possible to install Python modules to provide a GUI. I have not installed these - takes the fun out of running scripts!


Markus said...


i'm very interested in parsing the UsnJrnl file aswell but unfortunately I receive the following error message after following your steps, when I arrive at the "script execute" path:

('Unexpected error:', )
Traceback (most recent call last):
File "C:\TEMP\", line 279, in
File "C:\TEMP\", line 79, in main
parsefile_small(it, options)
File "C:\TEMP\", line 189, in parsefile_small
sys.stderr.write ("\nLength of data is %s \n", len(data))
TypeError: function takes exactly 1 argument (2 given)

I'm running Python 2.7 on Windows 7 (latest Patches etc) and I'm trying to analyze an Windows XP Service Pack 3 UsnJrnl File.

Am I doing something wrong? I hope you can help me :)

sincerely yours


DC1743 said...

Hi Markus,

I am not a python expert but I will try and help. What command did you enter at the command prompt?

Regards Richard

Markus said...


before I start with further information I would like to thank you in advance for your help!

I'm actually writing my master thesis and actually I'm trying a few things out around the UsnJrnl file.

Since I'm not a python expert too, I've decided to post a reply here and on the script developers page first, before I spend more hours in understanding and fixing the code. (maybe I'm just doing a few things wrong or maybe I forgot something? I don't know actually)


First of all I installed Python 2.7 from the official Python project page and after this I've downloaded the .py script which was mentioned in your blog article.

I've uploaded a copy for verification purposes here:

This script was executed on the following file:

Its an extracted UsnJrnl file out of a Windows XP (SP3) installation out of an VirtualBox environment. The Source image was snapped by the use of the dd tool under helix, and the file was extracted later with the help of the TSK & Autopsy tools.

The script execution command was simply : -f UsnJrnl-J -o UsnJrnlOutput -c

unfortunately the posted error message occurs.

I appreciate any kind of help :-)



DC1743 said...


First off, the enscript I referred to in the post wont parse your change journal either.

I suspect the file is corrupted in some way and is not in the form the scripts expect. This is possibly due to tools used to extract it.

With a hex editor delete the first 58 bytes of your file, then run the script using the output option -o output -s

This parses most of the file out to the console, you could pipe the output into a file.


Markus said...


thank you very much for your answer and help.

I've solved the parsing issue almost. The error was caused by a bad input file. It seems that the USNJRNL File was damaged in its structure during the extraction.

After re-extracting the USNJRNL file with an different tool, I was able to parse the file, but the script is still crashing during the parsing process.

At least I have a csv File now and with it a point to continue and gain new motivation :)



Gogo said...

Markus, I had a similar issue while parsing my USNJRNL file. What tool di you use to successfully extract it?

I tried with FTK Imager but it won't see the file, then I tried with Pro Discover Basic and it succeeded but then the script did not like the input (which is clearly corrupted in the first bytes).