def parse_program_arguments(arguments): parser = ArgumentParser(prog='ripper', description='collects files from predetermined locations') parser.add_argument('-l', '--list', dest='list', help='list available plugins', action='store_true') parser.add_argument('-p', '--plugins', dest='plugins', help='plugins to run, comma separated') parser.add_argument('-m', '--maxsize', dest='maxsize', default=(256 * 1024), help='max file size to automatically get, in bytes') parser.add_argument('-u', '--users', dest='users', help='users to collect against, comma separated') options = parser.parse_args() if ((options.plugins == None) and (options.list != True)): parser.print_help() print '' example() print '' listplugins() return if (options.list == True): listplugins() return if options.plugins: global __PLUGINS for plugin in options.plugins.split(','): __PLUGINS.append(plugin) if options.maxsize: global __MAXSIZE __MAXSIZE = options.maxsize if options.users: global __COLLECTUSERS for user in options.users.split(','): __COLLECTUSERS.append(user)
def parse_program_arguments(arguments): parser = ArgumentParser( prog='ripper', description='collects files from predetermined locations') parser.add_argument('-l', '--list', dest='list', help='list available plugins', action='store_true') parser.add_argument('-p', '--plugins', dest='plugins', help='plugins to run, comma separated') parser.add_argument('-m', '--maxsize', dest='maxsize', default=(256 * 1024), help='max file size to automatically get, in bytes') parser.add_argument('-u', '--users', dest='users', help='users to collect against, comma separated') options = parser.parse_args() if ((options.plugins == None) and (options.list != True)): parser.print_help() print '' example() print '' listplugins() return if (options.list == True): listplugins() return if options.plugins: global __PLUGINS for plugin in options.plugins.split(','): __PLUGINS.append(plugin) if options.maxsize: global __MAXSIZE __MAXSIZE = options.maxsize if options.users: global __COLLECTUSERS for user in options.users.split(','): __COLLECTUSERS.append(user)
parser.add_argument('--recursive', action='store_true', dest='recursive', default=False, help='If present, dir will be done recursively, otherwise will not be recursive') parser.add_argument('--restart', action='store_true', dest='restart', default=False, help='If present, will not compare with previous results and will start a new baseline') parser.add_argument('--safe', action='store_true', dest='safe', default=False, help="Will run times and then craft a before/after parameter, rather then use dir's age parameter") path_group.add_argument('--sysdrive', action='store_true', dest='sysdrive', default=False, help='Will only run the dir against the system drive') parser.add_argument('--nodiff', action='store_true', dest='nodiff', default=False, help='Do not run a diffhour, only a normal hour') parser.add_argument('--noquiet', action='store_true', dest='noquiet', default=False, help='Display the results of the dir to screen') time_group.add_argument('--fromtime', action='store', dest='fromtime', metavar='"YYYY-MM-DD [hh:mm:ss]"', default=None, help='Date from which to calculate the age. Default is to calculate normally.') time_group.add_argument('--centeredtime', action='store', dest='centeredtime', metavar='"YYYY-MM-DD [hh:mm:ss]"', default=None, help='Date from which to calculate the age in both directions. Default is to calculate normally.') age_group.add_argument('--fromstart', action='store_true', dest='fromstart', default=False, help="Calculate the -after time since the first 'time' command run on this cpaddr") options = parser.parse_args() mask = ('"%s"' % options.mask) path = ('"%s"' % options.path.rstrip('\\')) age = options.age if (not _checkage(options.age)): dsz.ui.Echo('Invalid age', dsz.ERROR) parser.print_help() sys.exit(1) fromtime = None if (options.fromstart and ((options.fromtime is not None) or (options.centeredtime is not None))): dsz.ui.Echo('You cannot use -fromstart with -fromtime or -centeredtime', dsz.ERROR) parser.print_help() sys.exit(1) if (options.fromtime is not None): date_re = '((1[0-9]|2[0-9])\\d\\d)-(0[1-9]|1[0-2])-([0-2][0-9]|3[0-2])' time_re = '(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])' if (re.match(('^%s$' % date_re), options.fromtime.strip('"')) is not None): fromtime = ('%s 00:00:00' % options.fromtime.strip('"')) elif (re.match(('^%s %s$' % (date_re, time_re)), options.fromtime.strip('"')) is not None): fromtime = options.fromtime.strip('"') else: dsz.ui.Echo('Invalid fromtime', dsz.ERROR)