Exemplo n.º 1
0
    def __init__(self, config="glastopf.cfg", work_dir=os.getcwd()):
        """
        :param work_dir: directory used for data storage and various data files, must be writeable by glastopf.
            Default: os.getcwd()
        :param config: path to the glastopf configuration file.
            Default: glastopf.cfg
        """
        logger.info(
            'Initializing Glastopf {0} using "{1}" as work directory.'.format(
                __version__, work_dir))
        self.work_dir = work_dir
        self.data_dir = os.path.join(self.work_dir, 'data')
        self.loggers = logging_handler.get_aux_loggers(self.data_dir,
                                                       self.work_dir)
        self.config_path = os.path.join(self.work_dir, config)

        conf_parser = ConfigParser()
        conf_parser.read(self.config_path)
        self.options = {
            "uid":
            conf_parser.get("webserver", "uid").encode('latin1'),
            "gid":
            conf_parser.get("webserver", "gid").encode('latin1'),
            "proxy_enabled":
            conf_parser.get("webserver", "proxy_enabled").encode('latin1'),
            "banner":
            conf_parser.get("misc", "banner").encode('latin1'),
            "sensorid":
            conf_parser.get("sensor", "sensorid").encode('latin1'),
        }

        if self.options['sensorid'] == "None":
            self.options['sensorid'] = str(uuid.uuid4())
            conf_parser.set('sensor', 'sensorid', self.options['sensorid'])
            with open((self.config_path), 'wb') as configfile:
                conf_parser.write(configfile)

        (self.maindb, self.dorkdb) = self.setup_main_database(conf_parser)

        self.dork_generator = self.setup_dork_generator(conf_parser)

        if len(self.dork_generator.get_current_pages()) == 0:
            logger.info(
                "Generating initial dork pages - this can take a while.")
            self.dork_generator.regular_generate_dork(0)

        #profiler disabled until issue #26 is fixed
        self.profiler_available = False
        #if self.profiler_available:
        #    self.profiler = profiler.Profiler(self.maindb)

        #self.HTTP_parser = util.HTTPParser()
        self.MethodHandlers = method_handler.HTTPMethods(self.data_dir)

        #used for post processing (logging and analysis) of attack events
        self.post_queue = Queue.Queue()
        self.workers_enabled = False
Exemplo n.º 2
0
    def __init__(self, config="glastopf.cfg", work_dir=os.getcwd()):
        """
        :param work_dir: directory used for data storage and various data files, must be writeable by glastopf. Default: os.getcwd()
        :param config: path to the glastopf configuration file. Default: glastopf.cfg
        """
        logger.info('Initializing Glastopf using "{0}" as work directory.'.format(work_dir))
        self.work_dir = work_dir
        self.data_dir = os.path.join(self.work_dir, 'data')

        conf_parser = ConfigParser()
        conf_parser.read(config)
        self.options = {
            "uid": conf_parser.get("webserver", "uid").encode('latin1'),
            "gid": conf_parser.get("webserver", "gid").encode('latin1'),
            "proxy_enabled": conf_parser.get("webserver", "proxy_enabled").encode('latin1'),
        }

        (self.maindb, self.dorkdb) = self.setup_main_database(conf_parser)

        self.dork_generator = self.setup_dork_generator(conf_parser, self.work_dir)

        if len(self.dork_generator.get_current_pages()) == 0:
            logger.info("Generating initial dork pages - this can take a while.")
            self.dork_generator.regular_generate_dork(0)

        #hmm?
        self.profiler_available = False
        if self.profiler_available:
            self.profiler = profiler.Profiler(self.maindb)

        self.HTTP_parser = util.HTTPParser()
        self.MethodHandlers = method_handler.HTTPMethods(self.data_dir)

        #used for post processing (logging and analysis) of attack events
        self.post_queue = Queue.Queue()
        self.workers_enabled = False