1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
#! /usr/bin/env python
#
# Python script to print the file entries in Expert Witness Compression format file(s) using pyewf
#
# Author: Joachim Metz
# Creation date: October 16, 2011
# Modification date: January 26, 2013
#
__author__ = "Joachim Metz"
__version__ = "20130126"
__date__ = "Jan 26, 2013"
__copyright__ = "Copyright (c) 2006-2013, Joachim Metz <joachim.metz@gmail.com>"
__license__ = "GNU LGPL version 3"
import datetime
import sys
import pyewf
# ----------------------------------------------------------------------------
# Functions
# ----------------------------------------------------------------------------
def print_file_entry( file_entry ):
print "File entry:"
try:
name = file_entry.get_name()
except:
print "Unable to retrieve name\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
if name:
print "Name\t\t\t: " + name.encode( "utf8" )
try:
creation_time = file_entry.get_creation_time()
except:
print "Unable to retrieve creation time\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
if creation_time:
print "Creation time\t\t: " + creation_time.strftime("%Y-%m-%d %H:%M:%S")
try:
modification_time = file_entry.get_modification_time()
except:
print "Unable to retrieve modification time\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
if modification_time:
print "Modification time\t: " + modification_time.strftime("%Y-%m-%d %H:%M:%S")
try:
access_time = file_entry.get_access_time()
except:
print "Unable to retrieve access time\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
if access_time:
print "Access time\t\t: " + access_time.strftime("%Y-%m-%d %H:%M:%S")
try:
entry_modification_time = file_entry.get_entry_modification_time()
except:
print "Unable to retrieve entry modification time\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
if entry_modification_time:
print "Entry modification time\t: " + entry_modification_time.strftime("%Y-%m-%d %H:%M:%S")
try:
md5_hash = file_entry.get_hash_value_md5()
except:
print "Unable to retrieve MD5 hash\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
if md5_hash:
print "MD5 hash\t\t: " + md5_hash
print ""
try:
number_of_sub_file_entries = file_entry.get_number_of_sub_file_entries()
except:
print "Unable to retrieve number of file entries\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
for sub_file_entry_index in range( 0, number_of_sub_file_entries ):
try:
sub_file_entry = file_entry.get_sub_file_entry( sub_file_entry_index )
except:
print "Unable to retrieve number of file entry: " + sub_file_entry_index + "\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
print_file_entry( sub_file_entry )
# ----------------------------------------------------------------------------
# Main
# ----------------------------------------------------------------------------
print "file_entries.py " + __version__ + " (libewf " + pyewf.get_version() + ")\n"
argc = len( sys.argv )
if argc < 2:
print "Usage: file_entries.py filename(s)\n"
sys.exit( 1 )
if argc == 2:
try:
filenames = pyewf.glob(
sys.argv[ 1 ] )
except:
print "Unable to glob filename(s)\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
else:
filenames = sys.argv[ 1: ]
handle = pyewf.handle();
if handle == None:
print "Missing handle object\n"
sys.exit( 1 )
try:
# Open requires a list of filenames
handle.open(
filenames )
except:
print "Unable to open file(s)\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
try:
root_file_entry = handle.get_root_file_entry()
except:
print "Unable to retrieve root file entry\n"
print sys.exc_info()[ 1 ]
sys.exit( 1 )
print "Single files:"
print_file_entry( root_file_entry )
sys.exit( 0 )
|