Example #1
0
    def __init__(self, config, HandlerClass, *args, **kwargs):
        """
		:param config: Configuration to retrieve settings from.
		:type config: :py:class:`smoke_zephyr.configuration.Configuration`
		"""
        # additional mime types to be treated as html because they're probably cloned pages
        HandlerClass.extensions_map.update({
            '': 'text/html',
            '.asp': 'text/html',
            '.aspx': 'text/html',
            '.cfm': 'text/html',
            '.cgi': 'text/html',
            '.do': 'text/html',
            '.jsp': 'text/html',
            '.nsf': 'text/html',
            '.php': 'text/html',
            '.srf': 'text/html'
        })
        super(KingPhisherServer, self).__init__(HandlerClass, *args, **kwargs)
        self.logger = logging.getLogger('KingPhisher.Server')
        self.config = config
        """A :py:class:`~smoke_zephyr.configuration.Configuration` instance used as the main King Phisher server configuration."""
        self.serve_files = True
        self.serve_files_root = config.get('server.web_root')
        self.serve_files_list_directories = False
        self.serve_robots_txt = True
        self.database_engine = db_manager.init_database(
            config.get('server.database'))

        self.http_server.config = config
        self.http_server.throttle_semaphore = threading.Semaphore()
        self.http_server.session_manager = aaa.AuthenticatedSessionManager(
            timeout=config.get_if_exists('server.authentication.cache_timeout',
                                         '30m'))
        self.http_server.forked_authenticator = aaa.ForkedAuthenticator(
            cache_timeout=config.get_if_exists(
                'server.authentication.cache_timeout', '10m'),
            required_group=config.get_if_exists('server.authentication.group'),
            pam_service=config.get_if_exists(
                'server.authentication.pam_service', 'sshd'))
        self.job_manager = job.JobManager()
        """A :py:class:`~smoke_zephyr.job.JobManager` instance for scheduling tasks."""
        self.job_manager.start()
        self.http_server.job_manager = self.job_manager
        loader = jinja2.FileSystemLoader(config.get('server.web_root'))
        global_vars = {}
        if config.has_section('server.page_variables'):
            global_vars = config.get('server.page_variables')
        global_vars['embed_youtube_video'] = pages.embed_youtube_video
        global_vars['make_csrf_page'] = pages.make_csrf_page
        global_vars['make_redirect_page'] = pages.make_redirect_page
        self.http_server.template_env = templates.TemplateEnvironmentBase(
            loader=loader, global_vars=global_vars)
        self.__geoip_db = geoip.init_database(
            config.get('server.geoip.database'))

        self.__is_shutdown = threading.Event()
        self.__is_shutdown.clear()
Example #2
0
	def setUp(self):
		self.assertGreater(ROUTINE_SLEEP_TIME, 1)
		self.jm = job.JobManager()
		self.jm.start()