Ejemplo n.º 1
0
def command_profiles(parser, P, cmdParams, auditParams):
    if P.targets:
        parser.error("too many arguments")
    profiles = sorted(get_available_profiles())
    if not profiles:
        print "No available profiles!"
    else:
        print "--------------------"
        print " " + colorize("Available profiles", "yellow")
        print "--------------------"
        print
        for name in profiles:
            try:
                p = RawConfigParser()
                p.read(get_profile(name))
                desc = p.get("golismero", "description")
            except Exception:
                desc = None
            if desc:
                print "+ %s: %s" % (colorize(name, "cyan"), desc)
            else:
                print "+ %s" % colorize(name, "cyan")

    if path.sep == "/":
        print
    exit(0)
Ejemplo n.º 2
0
def command_profiles(parser, P, cmdParams, auditParams):
    if P.targets:
        parser.error("too many arguments")
    profiles = sorted(get_available_profiles())
    if not profiles:
        print "No available profiles!"
    else:
        print "--------------------"
        print " " + colorize("Available profiles", "yellow")
        print "--------------------"
        print
        for name in profiles:
            try:
                p = RawConfigParser()
                p.read(get_profile(name))
                desc = p.get("golismero", "description")
            except Exception:
                desc = None
            if desc:
                print "+ %s: %s" % (colorize(name, "cyan"), desc)
            else:
                print "+ %s" % colorize(name, "cyan")

    if path.sep == "/":
        print
    exit(0)
Ejemplo n.º 3
0
def daemon_main(listen_address, listen_port, server_push):

    # Get the config file name.
    config_file = get_default_config_file()
    if not config_file:
        raise RuntimeError("Could not find config file, aborting!")

    # Load the Orchestrator options.
    orchestrator_config = OrchestratorConfig()
    orchestrator_config.config_file = config_file
    orchestrator_config.from_config_file(orchestrator_config.config_file,
                                         allow_profile = True)
    if orchestrator_config.profile:
        orchestrator_config.profile_file = get_profile(
                                            orchestrator_config.profile)
        if orchestrator_config.profile_file:
            orchestrator_config.from_config_file(
                                            orchestrator_config.profile_file)
        else:
            raise RuntimeError("Could not find profile, aborting!")

    # Get the plugins folder from the parameters.
    # If no plugins folder is given, use the default.
    plugins_folder = orchestrator_config.plugins_folder
    if not plugins_folder:
        plugins_folder = path.abspath(__file__)
        plugins_folder = path.dirname(plugins_folder)
        plugins_folder = path.join(plugins_folder, "plugins")
        if not path.isdir(plugins_folder):
            from golismero import common
            plugins_folder = path.abspath(common.__file__)
            plugins_folder = path.dirname(plugins_folder)
            plugins_folder = path.join(plugins_folder, "plugins")
            if not path.isdir(plugins_folder):
                raise RuntimeError(
                    "Default plugins folder not found, aborting!")
        orchestrator_config.plugins_folder = plugins_folder

    # Load the daemon configuration from command line.
    if listen_address:
        orchestrator_config.listen_address = listen_address
    if listen_port:
        orchestrator_config.listen_port    = listen_port
    if server_push:
        orchestrator_config.server_push    = server_push

    # Force the daemon UI plugin.
    orchestrator_config.ui_mode = "daemon"

    # Force disable colored output.
    orchestrator_config.color = False

    # Force maximum verbosity level.
    orchestrator_config.verbose = Logger.MORE_VERBOSE

    # Launch GoLismero.
    launcher.run(orchestrator_config)
Ejemplo n.º 4
0
def main():

    # Get the config file name.
    config_file = get_default_config_file()
    if not config_file:
        raise RuntimeError("Could not find config file, aborting!")

    # Load the Orchestrator options.
    orchestrator_config = OrchestratorConfig()
    orchestrator_config.ui_mode = "web"
    orchestrator_config.color = False
    orchestrator_config.config_file = config_file
    orchestrator_config.from_config_file(orchestrator_config.config_file,
                                         allow_profile=True)
    if orchestrator_config.profile:
        orchestrator_config.profile_file = get_profile(
            orchestrator_config.profile)
        if orchestrator_config.profile_file:
            orchestrator_config.from_config_file(
                orchestrator_config.profile_file)
        else:
            raise RuntimeError("Could not find profile, aborting!")

    # Get the plugins folder from the parameters.
    # If no plugins folder is given, use the default.
    plugins_folder = orchestrator_config.plugins_folder
    if not plugins_folder:
        plugins_folder = path.abspath(__file__)
        plugins_folder = path.dirname(plugins_folder)
        plugins_folder = path.join(plugins_folder, "plugins")
        if not path.isdir(plugins_folder):
            from golismero import common
            plugins_folder = path.abspath(common.__file__)
            plugins_folder = path.dirname(plugins_folder)
            plugins_folder = path.join(plugins_folder, "plugins")
            if not path.isdir(plugins_folder):
                raise RuntimeError(
                    "Default plugins folder not found, aborting!")
        orchestrator_config.plugins_folder = plugins_folder

    # Check if all options are correct.
    orchestrator_config.check_params()

    # Launch GoLismero.
    launcher.run(orchestrator_config)
Ejemplo n.º 5
0
def main():

    # Get the config file name.
    config_file = get_default_config_file()
    if not config_file:
        raise RuntimeError("Could not find config file, aborting!")

    # Load the Orchestrator options.
    orchestrator_config = OrchestratorConfig()
    orchestrator_config.ui_mode = "web"
    orchestrator_config.colorize = False
    orchestrator_config.config_file = config_file
    orchestrator_config.from_config_file(orchestrator_config.config_file, allow_profile = True)
    if orchestrator_config.profile:
        orchestrator_config.profile_file = get_profile(orchestrator_config.profile)
        if orchestrator_config.profile_file:
            orchestrator_config.from_config_file(orchestrator_config.profile_file)
        else:
            raise RuntimeError("Could not find profile, aborting!")

    # Get the plugins folder from the parameters.
    # If no plugins folder is given, use the default.
    plugins_folder = orchestrator_config.plugins_folder
    if not plugins_folder:
        plugins_folder = path.abspath(__file__)
        plugins_folder = path.dirname(plugins_folder)
        plugins_folder = path.join(plugins_folder, "plugins")
        if not path.isdir(plugins_folder):
            from golismero import common
            plugins_folder = path.abspath(common.__file__)
            plugins_folder = path.dirname(plugins_folder)
            plugins_folder = path.join(plugins_folder, "plugins")
            if not path.isdir(plugins_folder):
                raise RuntimeError("Default plugins folder not found, aborting!")
        orchestrator_config.plugins_folder = plugins_folder

    # Check if all options are correct.
    orchestrator_config.check_params()

    # Launch GoLismero.
    launcher.run(orchestrator_config)
Ejemplo n.º 6
0
def build_config_from_cmdline():

    # Get the command line parser.
    parser = cmdline_parser()

    # Parse the command line options.
    try:
        args = sys.argv[1:]
        envcfg = getenv("GOLISMERO_SETTINGS")
        if envcfg:
            args = parser.convert_arg_line_to_args(envcfg) + args
        P, V = parser.parse_known_args(args)
        if P.targets:
            P.targets += V
        else:
            P.targets = V
        P.plugin_args = {}
        command = P.command.upper()
        if command in COMMANDS:
            P.command = command
            if command == "RESCAN":
                P.command = "SCAN"
                P.redo = True
            else:
                P.redo = False
        else:
            P.targets.insert(0, P.command)
            P.command = "SCAN"

        # Load the Orchestrator options.
        cmdParams = OrchestratorConfig()
        cmdParams.command = P.command
        if P.config:
            cmdParams.config_file = path.abspath(P.config)
            if not path.isfile(cmdParams.config_file):
                raise ValueError("File not found: %s" % cmdParams.config_file)
        if cmdParams.config_file:
            cmdParams.from_config_file(cmdParams.config_file,
                                       allow_profile=True)
        if P.user_config:
            cmdParams.user_config_file = path.abspath(P.user_config)
            if not path.isfile(cmdParams.user_config_file):
                raise ValueError("File not found: %s" %
                                 cmdParams.user_config_file)
        if cmdParams.user_config_file:
            cmdParams.from_config_file(cmdParams.user_config_file,
                                       allow_profile=True)
        if P.profile:
            cmdParams.profile = P.profile
            cmdParams.profile_file = get_profile(cmdParams.profile)
        if cmdParams.profile_file:
            cmdParams.from_config_file(cmdParams.profile_file)
        cmdParams.from_object(P)
        cmdParams.plugin_load_overrides = P.plugin_load_overrides

        # Enable console colors if requested.
        Console.use_colors = cmdParams.color

        # Show the program banner.
        parser.must_show_banner = False
        if cmdParams.verbose:
            show_banner()

        # Load the target audit options.
        auditParams = AuditConfig()
        auditParams.profile = cmdParams.profile
        auditParams.profile_file = cmdParams.profile_file
        auditParams.config_file = cmdParams.config_file
        auditParams.user_config_file = cmdParams.user_config_file
        if auditParams.config_file:
            auditParams.from_config_file(auditParams.config_file)
        if auditParams.user_config_file:
            auditParams.from_config_file(auditParams.user_config_file)
        if auditParams.profile_file:
            auditParams.from_config_file(auditParams.profile_file)
        auditParams.from_object(P)
        auditParams.plugin_load_overrides = P.plugin_load_overrides

        # If importing is turned off, remove the list of imports.
        # FIXME this should be done by argparse in argument order!
        if P.disable_importing:
            auditParams.imports = []

        # If reports are turned off, remove the list of reports.
        # Otherwise, if no reports are specified, default to screen report.
        # FIXME this should be done by argparse in argument order!
        if P.disable_reporting:
            auditParams.reports = []
        elif (not auditParams.reports
              and (P.command != "REPORT" or not auditParams.targets)):
            auditParams.reports = ["-"]
            if auditParams.only_vulns is None:
                auditParams.only_vulns = True

    # Show exceptions as command line parsing errors.
    except Exception, e:
        ##raise    # XXX DEBUG
        parser.error("arguments error: %s" % str(e))
Ejemplo n.º 7
0
def main():

    # Get the command line parser.
    parser = cmdline_parser()

    # Parse the command line options.
    try:
        args = sys.argv[1:]
        envcfg = getenv("GOLISMERO_SETTINGS")
        if envcfg:
            args = parser.convert_arg_line_to_args(envcfg) + args
        P = parser.parse_args(args)
        command = P.command.upper()
        if command in COMMANDS:
            P.command = command
        else:
            P.targets.insert(0, P.command)
            P.command = "SCAN"

        # Load the Orchestrator options.
        cmdParams = OrchestratorConfig()
        cmdParams.command = P.command
        if P.config:
            cmdParams.config_file = path.abspath(P.config)
            if not path.isfile(cmdParams.config_file):
                raise ValueError("File not found: %r" % cmdParams.config_file)
        if cmdParams.config_file:
            cmdParams.from_config_file(cmdParams.config_file, allow_profile = True)
        if P.profile:
            cmdParams.profile = P.profile
            cmdParams.profile_file = get_profile(cmdParams.profile)
        if cmdParams.profile_file:
            cmdParams.from_config_file(cmdParams.profile_file)
        cmdParams.from_object(P)
        cmdParams.plugin_load_overrides = P.plugin_load_overrides

        # Enable console colors if requested.
        Console.use_colors = cmdParams.color

        # Show the program banner.
        parser.must_show_banner = False
        if cmdParams.verbose:
            show_banner()

        # Load the target audit options.
        auditParams = AuditConfig()
        auditParams.profile = cmdParams.profile
        auditParams.profile_file = cmdParams.profile_file
        auditParams.config_file = cmdParams.config_file
        if auditParams.config_file:
            auditParams.from_config_file(auditParams.config_file)
        if auditParams.profile_file:
            auditParams.from_config_file(auditParams.profile_file)
        auditParams.from_object(P)
        auditParams.plugin_load_overrides = P.plugin_load_overrides

        # If importing is turned off, remove the list of imports.
        if P.disable_importing:
            auditParams.imports = []

        # If reports are turned off, remove the list of reports.
        # Otherwise, if no reports are specified, default to screen report.
        if P.disable_reporting:
            auditParams.reports = []
        elif not auditParams.reports and P.command in ("SCAN", "REPORT"):
            auditParams.reports = ["-"]
            if auditParams.only_vulns is None:
                auditParams.only_vulns = True

    # Show exceptions as command line parsing errors.
    except Exception, e:
        ##raise    # XXX DEBUG
        parser.error(str(e))
Ejemplo n.º 8
0
    if P.command == "PROFILES":
        if P.targets:
            parser.error("too many arguments")
        profiles = sorted(get_available_profiles())
        if not profiles:
            print "No available profiles!"
        else:
            print "--------------------"
            print " " + colorize("Available profiles", "yellow")
            print "--------------------"
            print
            for name in profiles:
                try:
                    p = RawConfigParser()
                    p.read(get_profile(name))
                    desc = p.get("golismero", "description")
                except Exception:
                    desc = None
                if desc:
                    print "+ %s: %s" % (colorize(name, "cyan"), desc)
                else:
                    print "+ %s" % colorize(name, "cyan")

        if path.sep == "/":
            print
        exit(0)


    #--------------------------------------------------------------------------
    # Dump the database and quit.
Ejemplo n.º 9
0
def main():

    # Show the program banner.
    show_banner()

    # Get the command line parser.
    parser = cmdline_parser()

    # Parse the command line options.
    try:
        args = sys.argv[1:]
        envcfg = getenv("GOLISMERO_SETTINGS")
        if envcfg:
            args = parser.convert_arg_line_to_args(envcfg) + args
        P = parser.parse_args(args)

        # Load the Orchestrator options.
        cmdParams = OrchestratorConfig()
        if P.config:
            cmdParams.config_file = path.abspath(P.config)
            if not path.isfile(cmdParams.config_file):
                raise ValueError("File not found: %r" % cmdParams.config_file)
        if cmdParams.config_file:
            cmdParams.from_config_file(cmdParams.config_file, allow_profile = True)
        if P.profile:
            cmdParams.profile = P.profile
            cmdParams.profile_file = get_profile(cmdParams.profile)
        if cmdParams.profile_file:
            cmdParams.from_config_file(cmdParams.profile_file)
        cmdParams.from_object(P)
        cmdParams.plugin_load_overrides = P.plugin_load_overrides

        # Load the target audit options.
        auditParams = AuditConfig()
        auditParams.profile = cmdParams.profile
        auditParams.profile_file = cmdParams.profile_file
        auditParams.config_file = cmdParams.config_file
        if auditParams.config_file:
            auditParams.from_config_file(auditParams.config_file)
        if auditParams.profile_file:
            auditParams.from_config_file(auditParams.profile_file)
        auditParams.from_object(P)
        auditParams.plugin_load_overrides = P.plugin_load_overrides

        # If importing is turned off, remove the list of imports.
        if P.disable_importing:
            auditParams.imports = []

        # If reports are turned off, remove the list of reports.
        # Otherwise, if no reports are specified, default to screen report.
        if P.disable_reporting:
            auditParams.reports = []
        elif not auditParams.reports:
            auditParams.reports = ["-"]

        # If there are no targets but there's a database,
        # get the targets (scope) from the database.
        if not auditParams.targets and auditParams.audit_db:
            try:
                cfg = AuditDB.get_config_from_closed_database(
                    auditParams.audit_db, auditParams.audit_name)
                if cfg:
                    auditParams.targets = cfg.targets
                    auditParams.include_subdomains = cfg.include_subdomains
                    if cmdParams.verbose > 1:
                        if auditParams.targets:
                            print "Found the following targets in the database:"
                            for t in auditParams.targets:
                                print "--> " + t
                            print
            except Exception:
                pass
                ##raise    # XXX DEBUG

    # Show exceptions as command line parsing errors.
    except Exception, e:
        ##raise    # XXX DEBUG
        parser.error(str(e))