def change_state(self, desirate_state):
     if not self.required:
         activated_modules = database.get('activated_modules')
         if desirate_state:
             activated_modules[self.name] = True
             self.enable = True
         else:
             activated_modules[self.name] = False
             self.enable = False
         database.set('activated_modules', activated_modules)
 def install_modules(cls):
     activated_modules = database.get('activated_modules')
     for module_name in cls.modules:
         if module_name not in activated_modules:
             if cls.modules[module_name].required:
                 activated_modules[module_name] = True
             else:
                 activated_modules[module_name] = False
         if hasattr(cls.modules[module_name].obj, 'install_entrypoint'):
             os.chdir(cls.modules[module_name].path)
             cls.modules[module_name].obj.install_entrypoint()
             os.chdir(database.get('base_directory'))
     database.set('activated_modules', activated_modules)
Beispiel #3
0
 def change_settings(cls, post):
     post_data = {}
     for key in post:
         if len(post[key]) > 0:
             post_data[key] = post[key]
     post_data = post
     if 'server' in post:
         database.set('server', post['server'])
     if 'password_1' in post:
         if len(post['password_1']) > 0:
             if post['password_1'] == post['password_2']:
                 password_hash = hashlib.sha512(
                     post['password_1'].encode('utf-8')).hexdigest()
                 database.set('password', password_hash)
             else:
                 return 'Passwords not match', 'red'
     if 'web_interface_port' in post:
         if post['web_interface_port'].isdigit():
             if int(post['web_interface_port']) != database.get(
                     'web_interface_port'):
                 database.set('web_interface_port',
                              int(post['web_interface_port']))
         else:
             return 'Port should contain only digits', 'red'
     if 'TLS' in post and post['TLS'] == 'on':
         database.set('TLS', True)
     else:
         database.set('TLS', False)
     if 'cert_path' in post:
         post['cert_path'] = urllib.parse.unquote(post['cert_path'])
         if post['cert_path'] != database.get('cert_path'):
             if os.path.exists(
                     post['cert_path']) or database.get('TLS') == False:
                 database.set('cert_path', post['cert_path'])
             else:
                 return 'Certificate file not found', 'red'
     if 'key_path' in post:
         post['key_path'] = urllib.parse.unquote(post['key_path'])
         if post['key_path'] != database.get('key_path'):
             if os.path.exists(
                     post['key_path']) or database.get('TLS') == False:
                 database.set('key_path', post['key_path'])
             else:
                 return 'Key file not found', 'red'
     for var_name in post:
         if var_name.find('hidden_activation__') >= 0:
             module_name = var_name.replace('hidden_activation__', '')
             if module_name in modules_manager.modules:
                 desirate_state = False
                 if 'activation__{}'.format(module_name) in post:
                     if post['activation__{}'.format(module_name)] == 'on':
                         desirate_state = True
                 if desirate_state != database.get(
                         'activated_modules')[module_name]:
                     modules_manager.modules[module_name].change_state(
                         desirate_state)
     return 'Settings saved', 'green'
Beispiel #4
0
 def install_entrypoint(cls):
     database.set('ban_score', 100, 'blacklist')
     database.set('period', 1, 'blacklist')  # in hours
     database.set('storage_time', 500, 'blacklist')  # in hours
     database.set('ban_duration', 24, 'blacklist')  # in hours
Beispiel #5
0
 def start(cls):
     analyzers_manager.import_analyzers()
     cls.thread = Thread(target=cls.analyser)
     cls.thread.daemon = True
     cls.thread.start()
     database.set('state', 'on', 'WAF')
Beispiel #6
0
 def stop(cls):
     if cls.thread != None:
         cls.thread = None
     database.set('state', 'off', 'WAF')
Beispiel #7
0
 def install_entrypoint(cls):
     database.set('state', 'off', 'WAF')
Beispiel #8
0
def start_server():
    database.set('sessions', {})
    server = Thread(target=run_on)
    server.daemon = True
    server.start()
    signal.pause()
Beispiel #9
0
	def stop(cls):
		if cls.thread != None:
			cls.thread = None
		database.set('state', 'off', 'DNS_shield')
Beispiel #10
0
	def start(cls):
		cls.thread = Thread(target = cls.analyser)
		cls.thread.daemon = True
		cls.thread.start()
		database.set('state', 'on', 'DNS_shield')
Beispiel #11
0
	def install_entrypoint(cls):
		database.set('state', 'off', 'DNS_shield')