Skip to content

Commit 44cf601

Browse files
author
Tim Walsh
committed
Add file export options to analysis
1 parent 5369b8d commit 44cf601

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

diskimageanalyzer.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ def write_to_spreadsheet(disk_result, spreadsheet_path):
250250

251251
# parse arguments
252252
parser = argparse.ArgumentParser()
253+
parser.add_argument("-e", "--exportall", help="Export all (not only allocated) with tsk_recover", action="store_true")
253254
parser.add_argument("-k", "--keepfiles", help="Retain exported logical files from each disk", action="store_true")
255+
parser.add_argument("-r", "--resforks", help="Export AppleDouble resource forks from HFS-formatted disks", action="store_true")
254256
parser.add_argument("source", help="Path to folder containing disk images")
255257
parser.add_argument("destination", help="Output destination")
256258
args = parser.parse_args()
@@ -341,10 +343,17 @@ def write_to_spreadsheet(disk_result, spreadsheet_path):
341343
disk_files_dir = os.path.join(files_dir, file)
342344
if not os.path.exists(disk_files_dir):
343345
os.makedirs(disk_files_dir)
344-
try:
345-
subprocess.check_output(['tsk_recover', '-a', diskimage, disk_files_dir])
346-
except subprocess.CalledProcessError as e:
347-
print('ERROR: tsk_recover could not carve allocated files from disk. STDERR: %s' % (e.output))
346+
# carve allocated or all files depending on option selected
347+
if args.exportall == True:
348+
try:
349+
subprocess.check_output(['tsk_recover', '-e', diskimage, disk_files_dir])
350+
except subprocess.CalledProcessError as e:
351+
print('ERROR: tsk_recover could not carve all files from disk. STDERR: %s' % (e.output))
352+
else:
353+
try:
354+
subprocess.check_output(['tsk_recover', '-a', diskimage, disk_files_dir])
355+
except subprocess.CalledProcessError as e:
356+
print('ERROR: tsk_recover could not carve allocated files from disk. STDERR: %s' % (e.output))
348357

349358
# rewrite last modified dates of carved files based on values in DFXML
350359
for (event, obj) in Objects.iterparse(fiwalk_file):
@@ -419,10 +428,17 @@ def write_to_spreadsheet(disk_result, spreadsheet_path):
419428
disk_files_dir = os.path.join(files_dir, file)
420429
if not os.path.exists(disk_files_dir):
421430
os.makedirs(disk_files_dir)
422-
try:
423-
subprocess.check_output(['bash', '/usr/share/hfsexplorer/bin/unhfs', '-v', '-o', disk_files_dir, diskimage])
424-
except subprocess.CalledProcessError as e:
425-
print('ERROR: HFS Explorer could not carve the following files from image: %s' % (e.output))
431+
# carve with or without resource forks depending on option selected
432+
if args.resforks == True:
433+
try:
434+
subprocess.check_output(['bash', '/usr/share/hfsexplorer/bin/unhfs', '-v', '-resforks', 'APPLEDOUBLE', '-o', disk_files_dir, diskimage])
435+
except subprocess.CalledProcessError as e:
436+
print('ERROR: HFS Explorer could not carve the following files from image: %s' % (e.output))
437+
else:
438+
try:
439+
subprocess.check_output(['bash', '/usr/share/hfsexplorer/bin/unhfs', '-v', '-o', disk_files_dir, diskimage])
440+
except subprocess.CalledProcessError as e:
441+
print('ERROR: HFS Explorer could not carve the following files from image: %s' % (e.output))
426442

427443

428444
elif 'udf' in disk_fs.lower():

0 commit comments

Comments
 (0)