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
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Psort (Plaso Síar Og Raðar Þessu) - Makes output from Plaso Storage files.
Sample Usage:
psort.py /tmp/mystorage.dump "date > '01-06-2012'"
See additional details here:
https://plaso.readthedocs.io/en/latest/sources/user/Using-psort.html
"""
from __future__ import unicode_literals
import multiprocessing
import logging
import os
import sys
from plaso import dependencies
from plaso.cli import tools as cli_tools
from plaso.cli import psort_tool
from plaso.lib import errors
def Main():
"""The main function."""
input_reader = cli_tools.StdinInputReader()
tool = psort_tool.PsortTool(input_reader=input_reader)
if not tool.ParseArguments(sys.argv[1:]):
return False
if tool.show_troubleshooting:
print('Using Python version {0!s}'.format(sys.version))
print()
print('Path: {0:s}'.format(os.path.abspath(__file__)))
print()
print(tool.GetVersionInformation())
print()
dependencies.CheckDependencies(verbose_output=True)
print('Also see: https://plaso.readthedocs.io/en/latest/sources/user/'
'Troubleshooting.html')
return True
try:
tool.CheckOutDated()
except KeyboardInterrupt:
return False
have_list_option = False
if tool.list_analysis_plugins:
tool.ListAnalysisPlugins()
have_list_option = True
if tool.list_language_identifiers:
tool.ListLanguageIdentifiers()
have_list_option = True
if tool.list_output_modules:
tool.ListOutputModules()
have_list_option = True
if tool.list_profilers:
tool.ListProfilers()
have_list_option = True
if tool.list_time_zones:
tool.ListTimeZones()
have_list_option = True
if have_list_option:
return True
try:
tool.ProcessStorage()
# Writing to stdout and stderr will raise BrokenPipeError if it
# receives a SIGPIPE.
except BrokenPipeError:
pass
except (KeyboardInterrupt, errors.UserAbort):
logging.warning('Aborted by user.')
return False
except errors.BadConfigOption as exception:
logging.warning(exception)
return False
return True
if __name__ == '__main__':
# For PyInstaller sake we need to define this directly after "__main__".
# https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Multiprocessing
multiprocessing.freeze_support()
if not Main():
sys.exit(1)
else:
sys.exit(0)
|