2018-05-04 13:53:29 +02:00
|
|
|
#!/usr/bin/env python3
|
2016-12-09 08:46:37 +01:00
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
'''
|
|
|
|
Flask global variables shared accross modules
|
|
|
|
'''
|
2021-04-28 15:24:33 +02:00
|
|
|
##################################
|
|
|
|
# Import External packages
|
|
|
|
##################################
|
2016-12-09 08:46:37 +01:00
|
|
|
import os
|
2019-06-20 10:56:31 +02:00
|
|
|
import re
|
2018-06-14 16:51:06 +02:00
|
|
|
import sys
|
2016-12-09 08:46:37 +01:00
|
|
|
|
2021-04-28 15:24:33 +02:00
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
2022-11-28 15:01:40 +01:00
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
|
|
|
from lib import ConfigLoader
|
2021-04-28 15:24:33 +02:00
|
|
|
from pubsublogger import publisher
|
2019-10-28 13:48:43 +01:00
|
|
|
|
2016-12-09 08:46:37 +01:00
|
|
|
# FLASK #
|
|
|
|
app = None
|
|
|
|
|
|
|
|
# CONFIG #
|
2019-10-28 13:48:43 +01:00
|
|
|
config_loader = ConfigLoader.ConfigLoader()
|
2016-12-09 08:46:37 +01:00
|
|
|
|
|
|
|
# REDIS #
|
2019-10-28 13:48:43 +01:00
|
|
|
r_serv = config_loader.get_redis_conn("Redis_Queues")
|
|
|
|
r_cache = config_loader.get_redis_conn("Redis_Cache")
|
|
|
|
r_serv_log = config_loader.get_redis_conn("Redis_Log")
|
|
|
|
r_serv_log_submit = config_loader.get_redis_conn("Redis_Log_submit")
|
2022-11-22 10:47:15 +01:00
|
|
|
|
2023-01-18 16:28:08 +01:00
|
|
|
r_serv_charts = config_loader.get_redis_conn("ARDB_Trending") # -> TODO MIGRATE Stats Graphs
|
|
|
|
r_serv_metadata = config_loader.get_redis_conn("ARDB_Metadata") # -> TODO MIGRATE /correlation/ subtypes objects
|
|
|
|
r_serv_onion = config_loader.get_redis_conn("ARDB_Onion") # -> TODO MIGRATE AUTO CRAWLER
|
2018-08-16 17:24:39 +02:00
|
|
|
|
2022-09-01 14:04:00 +02:00
|
|
|
# # # # # # #
|
|
|
|
r_serv_db = config_loader.get_db_conn("Kvrocks_DB")
|
|
|
|
r_serv_tags = config_loader.get_db_conn("Kvrocks_Tags")
|
2021-04-28 15:24:33 +02:00
|
|
|
|
|
|
|
# Logger (Redis)
|
|
|
|
redis_logger = publisher
|
|
|
|
# Port of the redis instance used by pubsublogger
|
|
|
|
redis_logger.port = 6380
|
|
|
|
# Channel name to publish logs
|
2021-05-28 17:37:46 +02:00
|
|
|
redis_logger.channel = 'Flask'
|
2021-04-28 15:24:33 +02:00
|
|
|
|
2018-06-14 16:51:06 +02:00
|
|
|
sys.path.append('../../configs/keys')
|
2018-06-19 11:31:30 +02:00
|
|
|
|
2019-07-25 17:26:32 +02:00
|
|
|
#### VARIABLES ####
|
2019-10-28 13:48:43 +01:00
|
|
|
baseUrl = config_loader.get_config_str("Flask", "baseurl")
|
2018-09-20 10:38:19 +02:00
|
|
|
baseUrl = baseUrl.replace('/', '')
|
|
|
|
if baseUrl != '':
|
2023-01-18 16:28:08 +01:00
|
|
|
baseUrl = '/' + baseUrl
|
2018-09-20 10:38:19 +02:00
|
|
|
|
2023-01-18 16:28:08 +01:00
|
|
|
max_preview_char = int(
|
|
|
|
config_loader.get_config_str("Flask", "max_preview_char")) # Maximum number of character to display in the tooltip
|
|
|
|
max_preview_modal = int(
|
|
|
|
config_loader.get_config_str("Flask", "max_preview_modal")) # Maximum number of character to display in the modal
|
2016-12-09 08:46:37 +01:00
|
|
|
|
2019-03-20 13:25:02 +01:00
|
|
|
max_tags_result = 50
|
|
|
|
|
2023-01-18 16:28:08 +01:00
|
|
|
DiffMaxLineLength = int(config_loader.get_config_str("Flask",
|
|
|
|
"DiffMaxLineLength")) # Use to display the estimated percentage instead of a raw value
|
2018-06-01 11:26:45 +02:00
|
|
|
|
|
|
|
bootstrap_label = ['primary', 'success', 'danger', 'warning', 'info']
|
2018-06-08 16:49:20 +02:00
|
|
|
|
2023-01-18 16:28:08 +01:00
|
|
|
dict_update_description = {'v1.5': {'nb_background_update': 5,
|
|
|
|
'update_warning_message': 'An Update is running on the background. Some informations like Tags, screenshot can be',
|
|
|
|
'update_warning_message_notice_me': 'missing from the UI.'},
|
|
|
|
'v2.4': {'nb_background_update': 1,
|
|
|
|
'update_warning_message': 'An Update is running on the background. Some informations like Domain Tags/Correlation can be',
|
|
|
|
'update_warning_message_notice_me': 'missing from the UI.'},
|
|
|
|
'v2.6': {'nb_background_update': 1,
|
|
|
|
'update_warning_message': 'An Update is running on the background. Some informations like Domain Tags/Correlation can be',
|
|
|
|
'update_warning_message_notice_me': 'missing from the UI.'},
|
|
|
|
'v2.7': {'nb_background_update': 1,
|
|
|
|
'update_warning_message': 'An Update is running on the background. Some informations like Domain Tags can be',
|
|
|
|
'update_warning_message_notice_me': 'missing from the UI.'},
|
|
|
|
'v3.4': {'nb_background_update': 1,
|
|
|
|
'update_warning_message': 'An Update is running on the background. Some informations like Domain Languages can be',
|
|
|
|
'update_warning_message_notice_me': 'missing from the UI.'},
|
|
|
|
'v3.7': {'nb_background_update': 1,
|
|
|
|
'update_warning_message': 'An Update is running on the background. Some informations like Tracker first_seen/last_seen can be',
|
|
|
|
'update_warning_message_notice_me': 'missing from the UI.'}
|
|
|
|
}
|
2019-04-18 10:56:00 +02:00
|
|
|
|
2018-06-08 16:49:20 +02:00
|
|
|
UPLOAD_FOLDER = os.path.join(os.environ['AIL_FLASK'], 'submitted')
|
2018-07-26 11:35:54 +02:00
|
|
|
|
2019-10-28 13:48:43 +01:00
|
|
|
PASTES_FOLDER = os.path.join(os.environ['AIL_HOME'], config_loader.get_config_str("Directories", "pastes")) + '/'
|
2021-01-08 17:37:18 +01:00
|
|
|
SCREENSHOT_FOLDER = config_loader.get_files_directory('screenshot')
|
2018-08-16 17:24:39 +02:00
|
|
|
|
2020-04-20 17:50:40 +02:00
|
|
|
REPO_ORIGIN = 'https://github.com/ail-project/ail-framework.git'
|
2019-04-16 17:24:59 +02:00
|
|
|
|
2019-10-28 13:48:43 +01:00
|
|
|
max_dashboard_logs = int(config_loader.get_config_str("Flask", "max_dashboard_logs"))
|
2018-08-24 10:35:28 +02:00
|
|
|
|
2019-10-28 13:48:43 +01:00
|
|
|
crawler_enabled = config_loader.get_config_boolean("Crawler", "activate_crawler")
|
2019-06-04 14:22:46 +02:00
|
|
|
|
2019-06-24 13:43:16 +02:00
|
|
|
email_regex = r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}'
|
2019-06-20 10:56:31 +02:00
|
|
|
email_regex = re.compile(email_regex)
|
|
|
|
|
2021-04-28 15:24:33 +02:00
|
|
|
# SubmitPaste vars
|
|
|
|
SUBMIT_PASTE_TEXT_MAX_SIZE = int(config_loader.get_config_str("SubmitPaste", "TEXT_MAX_SIZE"))
|
|
|
|
SUBMIT_PASTE_FILE_MAX_SIZE = int(config_loader.get_config_str("SubmitPaste", "FILE_MAX_SIZE"))
|
|
|
|
SUBMIT_PASTE_FILE_ALLOWED_EXTENSIONS = [item.strip() for item in config_loader.get_config_str("SubmitPaste", "FILE_ALLOWED_EXTENSIONS").split(',')]
|
|
|
|
|
2018-08-24 10:35:28 +02:00
|
|
|
# VT
|
2018-06-29 10:02:29 +02:00
|
|
|
try:
|
|
|
|
from virusTotalKEYS import vt_key
|
2023-01-18 16:28:08 +01:00
|
|
|
|
2018-06-29 10:02:29 +02:00
|
|
|
if vt_key != '':
|
|
|
|
vt_auth = vt_key
|
|
|
|
vt_enabled = True
|
|
|
|
print('VT submission is enabled')
|
|
|
|
else:
|
|
|
|
vt_enabled = False
|
|
|
|
print('VT submission is disabled')
|
|
|
|
except:
|
2019-10-28 13:48:43 +01:00
|
|
|
vt_auth = {'apikey': config_loader.get_config_str("Flask", "max_preview_char")}
|
2018-06-29 10:02:29 +02:00
|
|
|
vt_enabled = False
|
|
|
|
print('VT submission is disabled')
|