MCPcopy
hub / github.com/USArmyResearchLab/Dshell / main_command_line

Function main_command_line

dshell/decode.py:538–762  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

536# TODO: Separate some of this logic outside of this function so we can call
537# dshell as a library.
538def main_command_line():
539 # Since plugin_chain contains the actual plugin instances we have to make sure
540 # we reset the global plugin_chain so multiple runs don't affect each other.
541 # (This was necessary to call this function through a python script.)
542 # TODO: Should plugin_chain be a list of plugin classes instead of instances?
543 global plugin_chain
544 plugin_chain = []
545
546 # dictionary of all available plugins: {name: module path}
547 plugin_map = get_plugins()
548 # dictionary of plugins that the user wants to use: {name: object}
549 active_plugins = OrderedDict()
550
551 # The main argument parser. It will have every command line option
552 # available and should be used when actually parsing
553 parser = DshellArgumentParser(
554 usage="%(prog)s [options] [plugin options] file1 file2 ... fileN",
555 add_help=False)
556 parser.add_argument('-c', '--count', type=int, default=0,
557 help='Number of packets to process')
558 parser.add_argument('--debug', action="store_true",
559 help="Show debug messages")
560 parser.add_argument('-v', '--verbose', action="store_true",
561 help="Show informational messages")
562 parser.add_argument('--acc', '--allcc', action="store_true",
563 help="Show all 3 GeoIP2 country code types (represented_country/registered_country/country)")
564 parser.add_argument('-d', '-p', '--plugin', dest='plugin', type=str,
565 action='append', metavar="PLUGIN",
566 help="Use a specific plugin module. Can be chained with '+'.")
567 parser.add_argument('--defragment', dest='defrag', action='store_true',
568 help='Reconnect fragmented IP packets')
569 parser.add_argument('-h', '-?', '--help', dest='help',
570 help="Print common command-line flags and exit", action='store_true',
571 default=False)
572 parser.add_argument('-i', '--interface', default=None, type=str,
573 help="Listen live on INTERFACE instead of reading pcap")
574 parser.add_argument('-l', '--ls', '--list', action="store_true",
575 help='List all available plugins', dest='list')
576 parser.add_argument('-r', '--recursive', dest='recursive', action='store_true',
577 help='Recursively process all PCAP files under input directory')
578 parser.add_argument('--unzipdir', type=str, metavar="DIRECTORY",
579 default=tempfile.gettempdir(),
580 help='Directory to use when decompressing input files (.gz, .bz2, and .zip only)')
581 parser.add_argument('--conn-timeout', dest="conntimeout", type=int,
582 metavar="SECONDS", default=3600,
583 help="Number of seconds to wait after last packet in a connection before closing it (default: 3600)")
584 parser.add_argument('--conn-max-open', dest='connmax', type=int,
585 metavar="NUMBER", default=1000,
586 help="Number of connections to hold in an open state before Dshell begins closing the oldest (default: 1000)")
587
588 multiprocess_group = parser.add_argument_group("multiprocessing arguments")
589 multiprocess_group.add_argument('-P', '--parallel', dest='multiprocessing', action='store_true',
590 help='Handle each file in separate parallel processes')
591 multiprocess_group.add_argument('-n', '--nprocs', type=int, default=4,
592 metavar='NUMPROCS', dest='process_max',
593 help='Define max number of parallel processes (default: 4)')
594
595 filter_group = parser.add_argument_group("filter arguments")

Callers 1

decode.pyFile · 0.85

Calls 11

add_plugin_argumentsMethod · 0.95
get_plugin_argumentsMethod · 0.95
get_pluginsFunction · 0.90
get_plugin_informationFunction · 0.90
get_output_modulesFunction · 0.90
get_output_pathFunction · 0.90
print_pluginsFunction · 0.85
mainFunction · 0.85
errorMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected