LEFT | RIGHT |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """The psteal CLI tool.""" | 2 """The psteal CLI tool.""" |
3 | 3 |
4 from __future__ import unicode_literals | 4 from __future__ import unicode_literals |
5 | 5 |
6 import argparse | 6 import argparse |
7 import collections | 7 import collections |
8 import datetime | 8 import datetime |
9 import logging | 9 import logging |
10 import os | 10 import os |
11 import sys | 11 import sys |
12 import textwrap | 12 import textwrap |
13 | 13 |
14 from dfvfs.lib import definitions as dfvfs_definitions | 14 from dfvfs.lib import definitions as dfvfs_definitions |
15 | 15 |
16 # The following import makes sure the output modules are registered. | 16 # The following import makes sure the output modules are registered. |
17 from plaso import output # pylint: disable=unused-import | 17 from plaso import output # pylint: disable=unused-import |
18 | 18 |
19 from plaso.cli import extraction_tool | 19 from plaso.cli import extraction_tool |
20 from plaso.cli import status_view | 20 from plaso.cli import status_view |
21 from plaso.cli import tool_options | 21 from plaso.cli import tool_options |
22 from plaso.cli import views | 22 from plaso.cli import views |
23 from plaso.cli.helpers import manager as helpers_manager | 23 from plaso.cli.helpers import manager as helpers_manager |
24 from plaso.engine import configurations | 24 from plaso.engine import configurations |
25 from plaso.engine import engine | 25 from plaso.engine import engine |
26 from plaso.engine import filter_file | 26 from plaso.engine import filter_file |
27 from plaso.engine import knowledge_base | 27 from plaso.engine import knowledge_base |
28 from plaso.engine import single_process as single_process_engine | 28 from plaso.engine import single_process as single_process_engine |
29 from plaso.lib import errors | 29 from plaso.lib import errors |
| 30 from plaso.lib import loggers |
30 from plaso.multi_processing import psort | 31 from plaso.multi_processing import psort |
31 from plaso.multi_processing import task_engine as multi_process_engine | 32 from plaso.multi_processing import task_engine as multi_process_engine |
32 from plaso.parsers import manager as parsers_manager | 33 from plaso.parsers import manager as parsers_manager |
33 from plaso.storage import zip_file as storage_zip_file | 34 from plaso.storage import zip_file as storage_zip_file |
34 | 35 |
35 | 36 |
36 class PstealTool( | 37 class PstealTool( |
37 extraction_tool.ExtractionTool, | 38 extraction_tool.ExtractionTool, |
38 tool_options.HashersOptions, | 39 tool_options.HashersOptions, |
39 tool_options.OutputModuleOptions, | 40 tool_options.OutputModuleOptions, |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 status_update_callback=status_update_callback) | 389 status_update_callback=status_update_callback) |
389 | 390 |
390 self._status_view.PrintExtractionSummary(processing_status) | 391 self._status_view.PrintExtractionSummary(processing_status) |
391 | 392 |
392 def ParseArguments(self): | 393 def ParseArguments(self): |
393 """Parses the command line arguments. | 394 """Parses the command line arguments. |
394 | 395 |
395 Returns: | 396 Returns: |
396 bool: True if the arguments were successfully parsed. | 397 bool: True if the arguments were successfully parsed. |
397 """ | 398 """ |
398 self._ConfigureLogging() | 399 loggers.ConfigureLogging() |
399 | 400 |
400 argument_parser = argparse.ArgumentParser( | 401 argument_parser = argparse.ArgumentParser( |
401 description=self.DESCRIPTION, epilog=self.EPILOG, add_help=False, | 402 description=self.DESCRIPTION, epilog=self.EPILOG, add_help=False, |
402 formatter_class=argparse.RawDescriptionHelpFormatter) | 403 formatter_class=argparse.RawDescriptionHelpFormatter) |
403 | 404 |
404 self.AddBasicOptions(argument_parser) | 405 self.AddBasicOptions(argument_parser) |
405 | 406 |
406 extraction_group = argument_parser.add_argument_group( | 407 extraction_group = argument_parser.add_argument_group( |
407 'extraction arguments') | 408 'extraction arguments') |
408 | 409 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 return False | 461 return False |
461 | 462 |
462 try: | 463 try: |
463 self.ParseOptions(options) | 464 self.ParseOptions(options) |
464 except errors.BadConfigOption as exception: | 465 except errors.BadConfigOption as exception: |
465 self._output_writer.Write('ERROR: {0!s}\n'.format(exception)) | 466 self._output_writer.Write('ERROR: {0!s}\n'.format(exception)) |
466 self._output_writer.Write('\n') | 467 self._output_writer.Write('\n') |
467 self._output_writer.Write(argument_parser.format_usage()) | 468 self._output_writer.Write(argument_parser.format_usage()) |
468 return False | 469 return False |
469 | 470 |
470 self._ConfigureLogging(filename=self._log_file) | 471 loggers.ConfigureLogging( |
| 472 debug_output=self._debug_mode, filename=self._log_file, |
| 473 quiet_mode=self._quiet_mode) |
471 | 474 |
472 return True | 475 return True |
473 | 476 |
474 def ParseOptions(self, options): | 477 def ParseOptions(self, options): |
475 """Parses tool specific options. | 478 """Parses tool specific options. |
476 | 479 |
477 Args: | 480 Args: |
478 options (argparse.Namespace): command line arguments. | 481 options (argparse.Namespace): command line arguments. |
479 | 482 |
480 Raises: | 483 Raises: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 if not self._output_filename: | 537 if not self._output_filename: |
535 raise errors.BadConfigOption(( | 538 raise errors.BadConfigOption(( |
536 'Output format: {0:s} requires an output file ' | 539 'Output format: {0:s} requires an output file ' |
537 '(-w OUTPUT_FILE)').format(self._output_format)) | 540 '(-w OUTPUT_FILE)').format(self._output_format)) |
538 | 541 |
539 if os.path.exists(self._output_filename): | 542 if os.path.exists(self._output_filename): |
540 raise errors.BadConfigOption( | 543 raise errors.BadConfigOption( |
541 'Output file already exists: {0:s}.'.format(self._output_filename)) | 544 'Output file already exists: {0:s}.'.format(self._output_filename)) |
542 | 545 |
543 self._output_module = self._CreateOutputModule(options) | 546 self._output_module = self._CreateOutputModule(options) |
LEFT | RIGHT |