Merge branch 'master' of github.com:ail-project/ail-framework

pull/586/head
Terrtia 2021-10-14 14:23:24 +02:00
commit 4e481603b5
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
16 changed files with 723 additions and 580 deletions

View File

@ -10,56 +10,61 @@ It apply CVE regexes on paste content and warn if a reference to a CVE is spotte
""" """
##################################
# Import External packages
##################################
import time import time
import re import re
from pubsublogger import publisher
##################################
# Import Project packages
##################################
from modules.abstract_module import AbstractModule
from packages import Paste from packages import Paste
from Helper import Process
def search_cve(message): class Cve(AbstractModule):
filepath, count = message.split() """
paste = Paste.Paste(filepath) Cve module for AIL framework
content = paste.get_p_content() """
# regex to find CVE
reg_cve = re.compile(r'(CVE-)[1-2]\d{1,4}-\d{1,5}')
# list of the regex results in the Paste, may be null
results = set(reg_cve.findall(content))
# if the list is greater than 2, we consider the Paste may contain a list of cve def __init__(self):
if len(results) > 0: super(Cve, self).__init__()
print('{} contains CVEs'.format(paste.p_name))
publisher.warning('{} contains CVEs'.format(paste.p_name)) # regex to find CVE
self.reg_cve = re.compile(r'(CVE-)[1-2]\d{1,4}-\d{1,5}')
# Waiting time in secondes between to message proccessed
self.pending_seconds = 1
# Send module state to logs
self.redis_logger.info(f'Module {self.module_name} initialized')
def compute(self, message):
filepath, count = message.split()
paste = Paste.Paste(filepath)
content = paste.get_p_content()
# list of the regex results in the Paste, may be null
results = set(self.reg_cve.findall(content))
# if the list is positive, we consider the Paste may contain a list of cve
if len(results) > 0:
warning = f'{paste.p_name} contains CVEs'
print(warning)
self.redis_logger.warning(warning)
msg = f'infoleak:automatic-detection="cve";{filepath}'
# Send to Tags Queue
self.send_message_to_queue(msg, 'Tags')
# Send to Duplicate Queue
self.send_message_to_queue(filepath, 'Duplicate')
msg = 'infoleak:automatic-detection="cve";{}'.format(filepath)
p.populate_set_out(msg, 'Tags')
#Send to duplicate
p.populate_set_out(filepath, 'Duplicate')
if __name__ == '__main__': if __name__ == '__main__':
# If you wish to use an other port of channel, do not forget to run a subscriber accordingly (see launch_logs.sh)
# Port of the redis instance used by pubsublogger
publisher.port = 6380
# Script is the default channel used for the modules.
publisher.channel = 'Script'
# Section name in bin/packages/modules.cfg module = Cve()
config_section = 'Cve' module.run()
# Setup the I/O queues
p = Process(config_section)
# Sent to the logging a description of the module
publisher.info("Run CVE module")
# Endless loop getting messages from the input queue
while True:
# Get one message from the input queue
message = p.get_from_set()
if message is None:
publisher.debug("{} queue is empty, waiting".format(config_section))
time.sleep(1)
continue
# Do something with the message from the queue
search_cve(message)

View File

@ -106,6 +106,9 @@ def get_tracker_tags(tracker_uuid):
def get_tracker_mails(tracker_uuid): def get_tracker_mails(tracker_uuid):
return list(r_serv_tracker.smembers('tracker:mail:{}'.format(tracker_uuid))) return list(r_serv_tracker.smembers('tracker:mail:{}'.format(tracker_uuid)))
def get_tracker_webhook(tracker_uuid):
return r_serv_tracker.hget('tracker:{}'.format(tracker_uuid), 'webhook')
def get_tracker_uuid_sources(tracker_uuid): def get_tracker_uuid_sources(tracker_uuid):
return list(r_serv_tracker.smembers(f'tracker:sources:{tracker_uuid}')) return list(r_serv_tracker.smembers(f'tracker:sources:{tracker_uuid}'))
@ -129,12 +132,12 @@ def get_tracker_last_seen(tracker_uuid):
else: else:
return None return None
def get_tracker_metedata(tracker_uuid, user_id=False, description=False, level=False, tags=False, mails=False, sources=True, sparkline=False): def get_tracker_metadata(tracker_uuid, user_id=False, description=False, level=False, tags=False, mails=False, sources=True, sparkline=False, webhook=False):
dict_uuid = {} dict_uuid = {}
dict_uuid['uuid'] = tracker_uuid
dict_uuid['tracker'] = get_tracker_by_uuid(tracker_uuid) dict_uuid['tracker'] = get_tracker_by_uuid(tracker_uuid)
dict_uuid['type'] = get_tracker_type(tracker_uuid) dict_uuid['type'] = get_tracker_type(tracker_uuid)
dict_uuid['date'] = get_tracker_date(tracker_uuid) dict_uuid['date'] = get_tracker_date(tracker_uuid)
dict_uuid['description'] = get_tracker_description(tracker_uuid)
dict_uuid['first_seen'] = get_tracker_first_seen(tracker_uuid) dict_uuid['first_seen'] = get_tracker_first_seen(tracker_uuid)
dict_uuid['last_seen'] = get_tracker_last_seen(tracker_uuid) dict_uuid['last_seen'] = get_tracker_last_seen(tracker_uuid)
if user_id: if user_id:
@ -149,7 +152,11 @@ def get_tracker_metedata(tracker_uuid, user_id=False, description=False, level=F
dict_uuid['tags'] = get_tracker_tags(tracker_uuid) dict_uuid['tags'] = get_tracker_tags(tracker_uuid)
if sparkline: if sparkline:
dict_uuid['sparkline'] = get_tracker_sparkline(tracker_uuid) dict_uuid['sparkline'] = get_tracker_sparkline(tracker_uuid)
dict_uuid['uuid'] = tracker_uuid if description:
dict_uuid['description'] = get_tracker_description(tracker_uuid)
if webhook:
dict_uuid['webhook'] = get_tracker_webhook(tracker_uuid)
return dict_uuid return dict_uuid
# tracker sparkline # tracker sparkline
@ -369,7 +376,7 @@ def api_validate_tracker_to_add(tracker , tracker_type, nb_words=1):
return ({"status": "error", "reason": "Incorrect type"}, 400) return ({"status": "error", "reason": "Incorrect type"}, 400)
return ({"status": "success", "tracker": tracker, "type": tracker_type}, 200) return ({"status": "success", "tracker": tracker, "type": tracker_type}, 200)
def create_tracker(tracker, tracker_type, user_id, level, tags, mails, description, dashboard=0, tracker_uuid=None, sources=[]): def create_tracker(tracker, tracker_type, user_id, level, tags, mails, description, webhook, dashboard=0, tracker_uuid=None, sources=[]):
# edit tracker # edit tracker
if tracker_uuid: if tracker_uuid:
edit_tracker = True edit_tracker = True
@ -410,6 +417,9 @@ def create_tracker(tracker, tracker_type, user_id, level, tags, mails, descripti
if description: if description:
r_serv_tracker.hset('tracker:{}'.format(tracker_uuid), 'description', description) r_serv_tracker.hset('tracker:{}'.format(tracker_uuid), 'description', description)
if webhook:
r_serv_tracker.hset('tracker:{}'.format(tracker_uuid), 'webhook', webhook)
# type change # type change
if edit_tracker: if edit_tracker:
r_serv_tracker.srem('all:tracker:{}'.format(old_type), old_tracker) r_serv_tracker.srem('all:tracker:{}'.format(old_type), old_tracker)
@ -464,7 +474,6 @@ def create_tracker(tracker, tracker_type, user_id, level, tags, mails, descripti
for source in sources: for source in sources:
# escape source ? # escape source ?
r_serv_tracker.sadd(f'tracker:sources:{tracker_uuid}', escape(source)) r_serv_tracker.sadd(f'tracker:sources:{tracker_uuid}', escape(source))
# toggle refresh module tracker list/set # toggle refresh module tracker list/set
r_serv_tracker.set('tracker:refresh:{}'.format(tracker_type), time.time()) r_serv_tracker.set('tracker:refresh:{}'.format(tracker_type), time.time())
if tracker_type != old_type: # toggle old type refresh if tracker_type != old_type: # toggle old type refresh
@ -474,14 +483,15 @@ def create_tracker(tracker, tracker_type, user_id, level, tags, mails, descripti
def api_add_tracker(dict_input, user_id): def api_add_tracker(dict_input, user_id):
tracker = dict_input.get('tracker', None) tracker = dict_input.get('tracker', None)
if not tracker: if not tracker:
return ({"status": "error", "reason": "Tracker not provided"}, 400) return {"status": "error", "reason": "Tracker not provided"}, 400
tracker_type = dict_input.get('type', None) tracker_type = dict_input.get('type', None)
if not tracker_type: if not tracker_type:
return ({"status": "error", "reason": "Tracker type not provided"}, 400) return {"status": "error", "reason": "Tracker type not provided"}, 400
nb_words = dict_input.get('nb_words', 1) nb_words = dict_input.get('nb_words', 1)
description = dict_input.get('description', '') description = dict_input.get('description', '')
description = escape(description) description = escape(description)
webhook = dict_input.get('webhook', '')
webhook = escape(webhook)
res = api_validate_tracker_to_add(tracker , tracker_type, nb_words=nb_words) res = api_validate_tracker_to_add(tracker , tracker_type, nb_words=nb_words)
if res[1]!=200: if res[1]!=200:
return res return res
@ -518,14 +528,14 @@ def api_add_tracker(dict_input, user_id):
# check if tracker already tracked in global # check if tracker already tracked in global
if level==1: if level==1:
if is_tracker_in_global_level(tracker, tracker_type) and not tracker_uuid: if is_tracker_in_global_level(tracker, tracker_type) and not tracker_uuid:
return ({"status": "error", "reason": "Tracker already exist"}, 409) return {"status": "error", "reason": "Tracker already exist"}, 409
else: else:
if is_tracker_in_user_level(tracker, tracker_type, user_id) and not tracker_uuid: if is_tracker_in_user_level(tracker, tracker_type, user_id) and not tracker_uuid:
return ({"status": "error", "reason": "Tracker already exist"}, 409) return {"status": "error", "reason": "Tracker already exist"}, 409
tracker_uuid = create_tracker(tracker , tracker_type, user_id, level, tags, mails, description, tracker_uuid=tracker_uuid, sources=sources) tracker_uuid = create_tracker(tracker , tracker_type, user_id, level, tags, mails, description, webhook, tracker_uuid=tracker_uuid, sources=sources)
return ({'tracker': tracker, 'type': tracker_type, 'uuid': tracker_uuid}, 200) return {'tracker': tracker, 'type': tracker_type, 'uuid': tracker_uuid}, 200
##-- CREATE TRACKER --## ##-- CREATE TRACKER --##

View File

@ -1394,7 +1394,7 @@ def test_ail_crawlers():
# # TODO: test regular domain # # TODO: test regular domain
if not ping_splash_manager(): if not ping_splash_manager():
manager_url = get_splash_manager_url() manager_url = get_splash_manager_url()
error_message = f'Error: Can\'t connect to AIL Splash Manager, http://{manager_url}' error_message = f'Error: Can\'t connect to AIL Splash Manager, {manager_url}'
print(error_message) print(error_message)
save_test_ail_crawlers_result(False, error_message) save_test_ail_crawlers_result(False, error_message)
return False return False

View File

@ -83,7 +83,7 @@ def is_father(item_id):
def is_children(item_id): def is_children(item_id):
return r_serv_metadata.hexists('paste_metadata:{}'.format(item_id), 'father') return r_serv_metadata.hexists('paste_metadata:{}'.format(item_id), 'father')
def is_root_node(): def is_root_node(item_id):
if is_father(item_id) and not is_children(item_id): if is_father(item_id) and not is_children(item_id):
return True return True
else: else:
@ -131,8 +131,8 @@ def _delete_node(item_id):
# only if item isn't deleted # only if item isn't deleted
#if is_crawled(item_id): #if is_crawled(item_id):
# r_serv_metadata.hrem('paste_metadata:{}'.format(item_id), 'real_link') # r_serv_metadata.hrem('paste_metadata:{}'.format(item_id), 'real_link')
for chidren_id in get_item_children(item_id): for children_id in get_item_children(item_id):
r_serv_metadata.hdel('paste_metadata:{}'.format(chidren_id), 'father') r_serv_metadata.hdel('paste_metadata:{}'.format(children_id), 'father')
r_serv_metadata.delete('paste_children:{}'.format(item_id)) r_serv_metadata.delete('paste_children:{}'.format(item_id))
# delete regular # delete regular
@ -210,9 +210,12 @@ def _get_dir_source_name(directory, source_name=None, l_sources_name=set(), filt
def get_all_items_sources(filter_dir=False, r_list=False): def get_all_items_sources(filter_dir=False, r_list=False):
res = _get_dir_source_name(PASTES_FOLDER, filter_dir=filter_dir) res = _get_dir_source_name(PASTES_FOLDER, filter_dir=filter_dir)
if r_list: if res:
res = list(res) if r_list:
return res res = list(res)
return res
else:
return []
def verify_sources_list(sources): def verify_sources_list(sources):
all_sources = get_all_items_sources() all_sources = get_all_items_sources()

View File

@ -374,6 +374,9 @@ def get_term_tags(term_uuid):
def get_term_mails(term_uuid): def get_term_mails(term_uuid):
return list(r_serv_term.smembers('tracker:mail:{}'.format(term_uuid))) return list(r_serv_term.smembers('tracker:mail:{}'.format(term_uuid)))
def get_term_webhook(term_uuid):
return r_serv_term.hget('tracker:{}'.format(term_uuid), "webhook")
def add_tracked_item(term_uuid, item_id, item_date): def add_tracked_item(term_uuid, item_id, item_date):
# track item # track item
r_serv_term.sadd('tracker:item:{}:{}'.format(term_uuid, item_date), item_id) r_serv_term.sadd('tracker:item:{}:{}'.format(term_uuid, item_date), item_id)

View File

@ -5,13 +5,14 @@ The Tracker_Regex trackers module
=================== ===================
This Module is used for regex tracking. This Module is used for regex tracking.
It processes every item coming from the global module and test the regexs It processes every item coming from the global module and test the regex
""" """
import os import os
import re import re
import sys import sys
import time import time
import requests
sys.path.append(os.environ['AIL_BIN']) sys.path.append(os.environ['AIL_BIN'])
################################## ##################################
@ -75,6 +76,8 @@ class Tracker_Regex(AbstractModule):
for tracker_uuid in uuid_list: for tracker_uuid in uuid_list:
# Source Filtering # Source Filtering
item_source = item.get_source() item_source = item.get_source()
item_date = item.get_date()
tracker_sources = Tracker.get_tracker_uuid_sources(tracker_uuid) tracker_sources = Tracker.get_tracker_uuid_sources(tracker_uuid)
if tracker_sources and item_source not in tracker_sources: if tracker_sources and item_source not in tracker_sources:
continue continue
@ -93,7 +96,27 @@ class Tracker_Regex(AbstractModule):
for mail in mail_to_notify: for mail in mail_to_notify:
NotificationHelper.sendEmailNotification(mail, mail_subject, mail_body) NotificationHelper.sendEmailNotification(mail, mail_subject, mail_body)
if __name__ == "__main__": # Webhook
webhook_to_post = Term.get_term_webhook(tracker_uuid)
if webhook_to_post:
json_request = {"trackerId": tracker_uuid,
"itemId": item_id,
"itemURL": self.full_item_url + item_id,
"tracker": tracker,
"itemSource": item_source,
"itemDate": item_date,
"tags": tags_to_add,
"emailNotification": f'{mail_to_notify}',
"trackerType": tracker_type
}
try:
response = requests.post(webhook_to_post, json=json_request)
if response.status_code >= 400:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: {response.reason}")
except:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: Something went wrong")
if __name__ == "__main__":
module = Tracker_Regex() module = Tracker_Regex()
module.run() module.run()

View File

@ -13,6 +13,8 @@ import os
import sys import sys
import time import time
import signal import signal
import requests
sys.path.append(os.environ['AIL_BIN']) sys.path.append(os.environ['AIL_BIN'])
################################## ##################################
@ -24,21 +26,24 @@ from packages.Item import Item
from packages import Term from packages import Term
from lib import Tracker from lib import Tracker
class TimeoutException(Exception): class TimeoutException(Exception):
pass pass
def timeout_handler(signum, frame): def timeout_handler(signum, frame):
raise TimeoutException raise TimeoutException
signal.signal(signal.SIGALRM, timeout_handler) signal.signal(signal.SIGALRM, timeout_handler)
class Tracker_Term(AbstractModule): class Tracker_Term(AbstractModule):
mail_body_template = "AIL Framework,\nNew occurrence for tracked term: {}\nitem id: {}\nurl: {}{}" mail_body_template = "AIL Framework,\nNew occurrence for tracked term: {}\nitem id: {}\nurl: {}{}"
""" """
Tracker_Term module for AIL framework Tracker_Term module for AIL framework
""" """
def __init__(self): def __init__(self):
super(Tracker_Term, self).__init__() super(Tracker_Term, self).__init__()
@ -56,7 +61,6 @@ class Tracker_Term(AbstractModule):
self.redis_logger.info(f"Module: {self.module_name} Launched") self.redis_logger.info(f"Module: {self.module_name} Launched")
def compute(self, item_id): def compute(self, item_id):
# refresh Tracked term # refresh Tracked term
if self.last_refresh_word < Term.get_tracked_term_last_updated_by_type('word'): if self.last_refresh_word < Term.get_tracked_term_last_updated_by_type('word'):
@ -88,7 +92,7 @@ class Tracker_Term(AbstractModule):
if dict_words_freq: if dict_words_freq:
# create token statistics # create token statistics
#for word in dict_words_freq: # for word in dict_words_freq:
# Term.create_token_statistics(item_date, word, dict_words_freq[word]) # Term.create_token_statistics(item_date, word, dict_words_freq[word])
item_source = item.get_source() item_source = item.get_source()
@ -115,7 +119,7 @@ class Tracker_Term(AbstractModule):
uuid_list = Term.get_term_uuid_list(term, term_type) uuid_list = Term.get_term_uuid_list(term, term_type)
self.redis_logger.info(f'new tracked term found: {term} in {item_id}') self.redis_logger.info(f'new tracked term found: {term} in {item_id}')
print(f'new tracked term found: {term} in {item_id}') print(f'new tracked term found: {term} in {item_id}')
item_date = Item.get_date()
for term_uuid in uuid_list: for term_uuid in uuid_list:
tracker_sources = Tracker.get_tracker_uuid_sources(term_uuid) tracker_sources = Tracker.get_tracker_uuid_sources(term_uuid)
if not tracker_sources or item_source in tracker_sources: if not tracker_sources or item_source in tracker_sources:
@ -135,8 +139,28 @@ class Tracker_Term(AbstractModule):
print(f'S print(item_content)end Mail {mail_subject}') print(f'S print(item_content)end Mail {mail_subject}')
NotificationHelper.sendEmailNotification(mail, mail_subject, mail_body) NotificationHelper.sendEmailNotification(mail, mail_subject, mail_body)
# Webhook
webhook_to_post = Term.get_term_webhook(term_uuid)
if webhook_to_post:
json_request = {"trackerId": term_uuid,
"itemId": item_id,
"itemURL": self.full_item_url + item_id,
"term": term,
"itemSource": item_source,
"itemDate": item_date,
"tags": tags_to_add,
"emailNotification": f'{mail_to_notify}',
"trackerType": term_type
}
try:
response = requests.post(webhook_to_post, json=json_request)
if response.status_code >= 400:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: {response.reason}")
except:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: Something went wrong")
if __name__ == '__main__': if __name__ == '__main__':
module = Tracker_Term() module = Tracker_Term()
module.run() module.run()

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*-coding:UTF-8 -* # -*-coding:UTF-8 -*
""" ##################################
The Tracker_Yara trackers module # The Tracker_Yara trackers module
=================== ##################################
"""
################################## ##################################
# Import External packages # Import External packages
@ -14,6 +12,7 @@ import re
import sys import sys
import time import time
import yara import yara
import requests
sys.path.append(os.environ['AIL_BIN']) sys.path.append(os.environ['AIL_BIN'])
################################## ##################################
@ -24,7 +23,7 @@ from packages import Term
from packages.Item import Item from packages.Item import Item
from lib import Tracker from lib import Tracker
import NotificationHelper # # TODO: refractor import NotificationHelper # # TODO: refactor
class Tracker_Yara(AbstractModule): class Tracker_Yara(AbstractModule):
@ -71,6 +70,7 @@ class Tracker_Yara(AbstractModule):
tracker_uuid = data['namespace'] tracker_uuid = data['namespace']
item_id = self.item.get_id() item_id = self.item.get_id()
item_source = self.item.get_source() item_source = self.item.get_source()
item_date = self.item.get_date()
# Source Filtering # Source Filtering
tracker_sources = Tracker.get_tracker_uuid_sources(tracker_uuid) tracker_sources = Tracker.get_tracker_uuid_sources(tracker_uuid)
@ -96,10 +96,30 @@ class Tracker_Yara(AbstractModule):
print(f'Send Mail {mail_subject}') print(f'Send Mail {mail_subject}')
NotificationHelper.sendEmailNotification(mail, mail_subject, mail_body) NotificationHelper.sendEmailNotification(mail, mail_subject, mail_body)
# Webhook
webhook_to_post = Term.get_term_webhook(tracker_uuid)
if webhook_to_post:
json_request = {"trackerId": tracker_uuid,
"itemId": item_id,
"itemURL": self.full_item_url + item_id,
"dataRule": data["rule"],
"itemSource": item_source,
"itemDate": item_date,
"tags": tags_to_add,
"emailNotification": f'{mail_to_notify}',
"trackerType": "yara"
}
try:
response = requests.post(webhook_to_post, json=json_request)
if response.status_code >= 400:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: {response.reason}")
except:
self.redis_logger.error(f"Webhook request failed for {webhook_to_post}\nReason: Something went wrong")
return yara.CALLBACK_CONTINUE return yara.CALLBACK_CONTINUE
if __name__ == '__main__': if __name__ == '__main__':
module = Tracker_Yara() module = Tracker_Yara()
module.run() module.run()

View File

@ -77,6 +77,7 @@ PySocks>=1.7.1
pycountry>=20.7.3 pycountry>=20.7.3
https://github.com/saffsd/langid.py/archive/master.zip https://github.com/saffsd/langid.py/archive/master.zip
requests
##### Old packages ##### Old packages

View File

@ -70,7 +70,7 @@ r_cache = config_loader.get_redis_conn("Redis_Cache")
# logs # logs
log_dir = os.path.join(os.environ['AIL_HOME'], 'logs') log_dir = os.path.join(os.environ['AIL_HOME'], 'logs')
if not os.path.isdir(log_dir): if not os.path.isdir(log_dir):
os.makedirs(logs_dir) os.makedirs(log_dir)
# log_filename = os.path.join(log_dir, 'flask_server.logs') # log_filename = os.path.join(log_dir, 'flask_server.logs')
# logger = logging.getLogger() # logger = logging.getLogger()

View File

@ -192,7 +192,7 @@ def get_json_retro_hunt_nb_items_by_date():
if date_from and date_to: if date_from and date_to:
res = Tracker.get_retro_hunt_nb_item_by_day([task_uuid], date_from=date_from, date_to=date_to) res = Tracker.get_retro_hunt_nb_item_by_day([task_uuid], date_from=date_from, date_to=date_to)
else: else:
res = Term.get_retro_hunt_nb_item_by_day([task_uuid]) res = Tracker.get_retro_hunt_nb_item_by_day([task_uuid])
return jsonify(res) return jsonify(res)

View File

@ -96,6 +96,7 @@ def add_tracked_menu():
tracker_type = request.form.get("tracker_type") tracker_type = request.form.get("tracker_type")
nb_words = request.form.get("nb_word", 1) nb_words = request.form.get("nb_word", 1)
description = request.form.get("description", '') description = request.form.get("description", '')
webhook = request.form.get("webhook", '')
level = request.form.get("level", 0) level = request.form.get("level", 0)
tags = request.form.get("tags", []) tags = request.form.get("tags", [])
mails = request.form.get("mails", []) mails = request.form.get("mails", [])
@ -125,7 +126,7 @@ def add_tracked_menu():
input_dict = {"tracker": tracker, "type": tracker_type, "nb_words": nb_words, input_dict = {"tracker": tracker, "type": tracker_type, "nb_words": nb_words,
"tags": tags, "mails": mails, "sources": sources, "tags": tags, "mails": mails, "sources": sources,
"level": level, "description": description} "level": level, "description": description, "webhook": webhook}
user_id = current_user.get_id() user_id = current_user.get_id()
# edit tracker # edit tracker
if tracker_uuid: if tracker_uuid:
@ -155,7 +156,7 @@ def edit_tracked_menu():
if res: # invalid access if res: # invalid access
return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1] return Response(json.dumps(res[0], indent=2, sort_keys=True), mimetype='application/json'), res[1]
dict_tracker = Tracker.get_tracker_metedata(tracker_uuid, user_id=True, level=True, description=True, tags=True, mails=True, sources=True) dict_tracker = Tracker.get_tracker_metadata(tracker_uuid, user_id=True, level=True, description=True, tags=True, mails=True, sources=True, webhook=True)
dict_tracker['tags'] = ' '.join(dict_tracker['tags']) dict_tracker['tags'] = ' '.join(dict_tracker['tags'])
dict_tracker['mails'] = ' '.join(dict_tracker['mails']) dict_tracker['mails'] = ' '.join(dict_tracker['mails'])
@ -202,7 +203,7 @@ def show_tracker():
if date_to: if date_to:
date_to = date_to.replace('-', '') date_to = date_to.replace('-', '')
tracker_metadata = Tracker.get_tracker_metedata(tracker_uuid, user_id=True, level=True, description=True, tags=True, mails=True, sources=True, sparkline=True) tracker_metadata = Tracker.get_tracker_metadata(tracker_uuid, user_id=True, level=True, description=True, tags=True, mails=True, sources=True, sparkline=True, webhook=True)
if tracker_metadata['type'] == 'yara': if tracker_metadata['type'] == 'yara':
yara_rule_content = Tracker.get_yara_rule_content(tracker_metadata['tracker']) yara_rule_content = Tracker.get_yara_rule_content(tracker_metadata['tracker'])

View File

@ -31,7 +31,7 @@
<div class="card my-3"> <div class="card my-3">
<div class="card-header bg-dark text-white"> <div class="card-header bg-dark text-white">
<h5 class="card-title">Edit a Tracker</h5> <h5 class="card-title">{%if dict_tracker%}Edit a{%else%}Create a new{%endif%} Tracker</h5>
</div> </div>
<div class="card-body"> <div class="card-body">
@ -53,6 +53,12 @@
<div class="input-group-text bg-secondary text-white"><i class="fas fa-at"></i></div> <div class="input-group-text bg-secondary text-white"><i class="fas fa-at"></i></div>
</div> </div>
<input id="mails" name="mails" class="form-control" placeholder="E-Mails Notification (optional, space separated)" type="text" {%if dict_tracker%}{%if dict_tracker['mails']%}value="{{dict_tracker['mails']}}"{%endif%}{%endif%}> <input id="mails" name="mails" class="form-control" placeholder="E-Mails Notification (optional, space separated)" type="text" {%if dict_tracker%}{%if dict_tracker['mails']%}value="{{dict_tracker['mails']}}"{%endif%}{%endif%}>
</div>
<div class="input-group mb-2 mr-sm-2">
<div class="input-group-prepend">
<div class="input-group-text bg-info text-white"><i class="fas fa-anchor"></i></div>
</div>
<input id="webhook" name="webhook" class="form-control" placeholder="Webhook URL" type="text" {%if dict_tracker%}{%if dict_tracker['webhook']%}value="{{dict_tracker['webhook']}}"{%endif%}{%endif%}>
</div> </div>
<div class="input-group mb-2 mr-sm-2"> <div class="input-group mb-2 mr-sm-2">
<div class="input-group-prepend"> <div class="input-group-prepend">

View File

@ -1,359 +1,400 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>AIL Framework - AIL</title> <title>AIL Framework - AIL</title>
<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png') }}"> <link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png') }}">
<!-- Core CSS --> <!-- Core CSS -->
<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/daterangepicker.min.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/daterangepicker.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">
<!-- JS --> <!-- JS -->
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script> <script src="{{ url_for('static', filename='js/jquery.js') }}"></script>
<script src="{{ url_for('static', filename='js/popper.min.js')}}"></script> <script src="{{ url_for('static', filename='js/popper.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script> <script src="{{ url_for('static', filename='js/bootstrap4.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script> <script src="{{ url_for('static', filename='js/jquery.dataTables.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script> <script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js') }}"></script>
<script language="javascript" src="{{ url_for('static', filename='js/d3.min.js') }}"></script> <script language="javascript" src="{{ url_for('static', filename='js/d3.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/d3/sparklines.js')}}"></script> <script src="{{ url_for('static', filename='js/d3/sparklines.js') }}"></script>
<script src="{{ url_for('static', filename='js/d3/graphlinesgroup.js')}}"></script> <script src="{{ url_for('static', filename='js/d3/graphlinesgroup.js') }}"></script>
<script language="javascript" src="{{ url_for('static', filename='js/moment.min.js') }}"></script> <script language="javascript" src="{{ url_for('static', filename='js/moment.min.js') }}"></script>
<script language="javascript" src="{{ url_for('static', filename='js/jquery.daterangepicker.min.js') }}"></script> <script language="javascript" src="{{ url_for('static', filename='js/jquery.daterangepicker.min.js') }}"></script>
<style> <style>
.btn-link { .btn-link {
color: #17a2b8 color: #17a2b8
} }
.btn-link:hover {
color: blue;
}
.mouse_pointer{
cursor: pointer;
}
</style>
</head> .btn-link:hover {
<body> color: blue;
}
{% include 'nav_bar.html' %} .mouse_pointer {
cursor: pointer;
}
</style>
<div class="container-fluid"> </head>
<div class="row"> <body>
{% include 'hunter/menu_sidebar.html' %} {% include 'nav_bar.html' %}
<div class="col-12 col-lg-10" id="core_content"> <div class="container-fluid">
<div class="row">
<div class="card my-3"> {% include 'hunter/menu_sidebar.html' %}
<div class="card-header" style="background-color:#d9edf7;font-size: 15px">
<h4 class="text-secondary">
{%if tracker_metadata['description']%}
{{ tracker_metadata['description'] }}
{%endif%}
<span class="btn-interaction btn-link h6 mouse_pointer" title="Edit Tracker description" onclick="edit_description();"><i class="fas fa-pencil-alt"></i></span>
</h4>
<div class="text-info">
{{ tracker_metadata['uuid'] }}
</div>
<ul class="list-group mb-2">
<li class="list-group-item py-0">
<div class="row">
<div class="col-md-10">
<table class="table">
<thead>
<tr>
<th>Type</th>
<th>Tracker</th>
<th>Date added</th>
<th>Level</th>
<th>Created by</th>
<th>First seen</th>
<th>Last seen</th>
<th>Tags <span class="btn-link btn-interaction mouse_pointer" title="Edit Tags List" onclick="edit_tags();"><i class="fas fa-pencil-alt" style="color:Red;"></i></span></th>
<th>Email <span class="btn-link btn-interaction mouse_pointer" title="Edit Email List" onclick="edit_mails();"><i class="fas fa-pencil-alt" style="color:Red;"></i></span></th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ tracker_metadata['type'] }}</td>
<td>{{ tracker_metadata['tracker'] }}</td>
<td>{{ tracker_metadata['date'][0:4] }}/{{ tracker_metadata['date'][4:6] }}/{{ tracker_metadata['date'][6:8] }}</td>
<td>{{ tracker_metadata['level'] }}</td>
<td>{{ tracker_metadata['user_id'] }}</td>
<td>
{% if tracker_metadata['first_seen'] %}
{{ tracker_metadata['first_seen'][0:4] }}/{{ tracker_metadata['first_seen'][4:6] }}/{{ tracker_metadata['first_seen'][6:8] }}
{% endif %}
</td>
<td>
{% if tracker_metadata['last_seen'] %}
{{ tracker_metadata['last_seen'][0:4] }}/{{ tracker_metadata['last_seen'][4:6] }}/{{ tracker_metadata['last_seen'][6:8] }}
{% endif %}
</td>
<td>
{% for tag in tracker_metadata['tags'] %}
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item&ltags={{ tag }}">
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }}</span>
</a>
{% endfor %}
</td> <div class="col-12 col-lg-10" id="core_content">
<td>
{% for mail in tracker_metadata['mails'] %}
{{ mail }}<br>
{% endfor %}
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-1">
<div id="sparkline"></div>
</div>
</div>
<h6>Sources:</h6>
{% if tracker_metadata['sources'] %}
{% for sources in tracker_metadata['sources'] %}
<span class="badge badge-secondary">{{ sources }}</span><br>
{% endfor %}
{% else %}
<span class="badge badge-secondary">All Souces</span><br>
{% endif %}
</li>
</ul>
<div id="div_edit_description"> <div class="card my-3">
<form action="{{ url_for('hunter.update_tracker_description') }}" method='post'> <div class="card-header" style="background-color:#d9edf7;font-size: 15px">
<input name="uuid" type="text" value="{{tracker_metadata['uuid']}}" hidden> <h4 class="text-secondary">
<div>Update this tracker description: </div> {% if tracker_metadata['description'] %}
<div class="input-group mb-2 mr-sm-2"> {{ tracker_metadata['description'] }}
<div class="input-group-prepend"> {% endif %}
<div class="input-group-text"><i class="fas fa-pencil-alt"></i></div> <span class="btn-interaction btn-link h6 mouse_pointer" title="Edit Tracker description"
</div> onclick="edit_description();"><i class="fas fa-pencil-alt"></i></span>
<input id="description" name="description" class="form-control" placeholder="Tracker Description" type="text" </h4>
value="{%if tracker_metadata['description']%}{{tracker_metadata['description']}}{%endif%}"> <div class="text-info">
</div> {{ tracker_metadata['uuid'] }}
</div>
<ul class="list-group mb-2">
<li class="list-group-item py-0">
<div class="row">
<div class="col-md-10">
<table class="table">
<thead>
<tr>
<th>Type</th>
<th>Tracker</th>
<th>Date added</th>
<th>Access Level</th>
<th>Created by</th>
<th>First seen</th>
<th>Last seen</th>
{% if tracker_metadata['webhook'] %}
<th>Webhook</th>
{% endif %}
<th>Tags <span class="btn-link btn-interaction mouse_pointer"
title="Edit Tags List" onclick="edit_tags();"><i
class="fas fa-pencil-alt" style="color:Red;"></i></span></th>
<th>Email <span class="btn-link btn-interaction mouse_pointer"
title="Edit Email List" onclick="edit_mails();"><i
class="fas fa-pencil-alt" style="color:Red;"></i></span></th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ tracker_metadata['type'] }}</td>
<td>{{ tracker_metadata['tracker'] }}</td>
<td>{{ tracker_metadata['date'][0:4] }}/{{ tracker_metadata['date'][4:6] }}/{{ tracker_metadata['date'][6:8] }}</td>
<td>
{% if tracker_metadata['level'] == 0 %}
Private
{% else %}
Global
{% endif %}
</td>
<td>{{ tracker_metadata['user_id'] }}</td>
<td>
{% if tracker_metadata['first_seen'] %}
{{ tracker_metadata['first_seen'][0:4] }}/
{{ tracker_metadata['first_seen'][4:6] }}/
{{ tracker_metadata['first_seen'][6:8] }}
{% endif %}
</td>
<td>
{% if tracker_metadata['last_seen'] %}
{{ tracker_metadata['last_seen'][0:4] }}/
{{ tracker_metadata['last_seen'][4:6] }}/
{{ tracker_metadata['last_seen'][6:8] }}
{% endif %}
</td>
{% if tracker_metadata['webhook'] %}
<td>
Turned ON
</td>
{% endif %}
<td>
{% for tag in tracker_metadata['tags'] %}
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item&ltags={{ tag }}">
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }}</span>
</a>
{% endfor %}
<button class="btn btn-info"> </td>
<i class="fas fa-pencil-alt"></i> Edit Description <td>
</button> {% for mail in tracker_metadata['mails'] %}
</form> {{ mail }}<br>
{% endfor %}
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-1">
<div id="sparkline"></div>
</div>
</div>
<h6>Sources:</h6>
{% if tracker_metadata['sources'] %}
{% for sources in tracker_metadata['sources'] %}
<span class="badge badge-secondary">{{ sources }}</span><br>
{% endfor %}
{% else %}
<span class="badge badge-secondary">All Souces</span><br>
{% endif %}
</li>
</ul>
</div> <div id="div_edit_description">
<form action="{{ url_for('hunter.update_tracker_description') }}" method='post'>
<input name="uuid" type="text" value="{{ tracker_metadata['uuid'] }}" hidden>
<div>Update this tracker description:</div>
<div class="input-group mb-2 mr-sm-2">
<div class="input-group-prepend">
<div class="input-group-text"><i class="fas fa-pencil-alt"></i></div>
</div>
<input id="description" name="description" class="form-control"
placeholder="Tracker Description" type="text"
value="
{% if tracker_metadata['description'] %}{{ tracker_metadata['description'] }}{% endif %}">
</div>
<div id="div_edit_tags"> <button class="btn btn-info">
<form action="{{ url_for('hunter.update_tracker_tags') }}" method='post'> <i class="fas fa-pencil-alt"></i> Edit Description
<input name="uuid" type="text" value="{{tracker_metadata['uuid']}}" hidden> </button>
<div>All Tags added for this tracker, space separated: </div> </form>
<div class="input-group mb-2 mr-sm-2">
<div class="input-group-prepend">
<div class="input-group-text"><i class="fas fa-tag"></i></div>
</div>
<input id="tags" name="tags" class="form-control" placeholder="Tags (optional, space separated)" type="text"
value="{% for tag in tracker_metadata['tags'] %}{{tag}} {% endfor %}">
</div>
<button class="btn btn-info"> </div>
<i class="fas fa-pencil-alt"></i> Edit Tags
</button>
</form>
</div> <div id="div_edit_tags">
<form action="{{ url_for('hunter.update_tracker_tags') }}" method='post'>
<input name="uuid" type="text" value="{{ tracker_metadata['uuid'] }}" hidden>
<div>All Tags added for this tracker, space separated:</div>
<div class="input-group mb-2 mr-sm-2">
<div class="input-group-prepend">
<div class="input-group-text"><i class="fas fa-tag"></i></div>
</div>
<input id="tags" name="tags" class="form-control"
placeholder="Tags (optional, space separated)" type="text"
value="{% for tag in tracker_metadata['tags'] %}{{ tag }} {% endfor %}">
</div>
<div id="div_edit_mails"> <button class="btn btn-info">
<form action="{{ url_for('hunter.update_tracker_mails') }}" method='post'> <i class="fas fa-pencil-alt"></i> Edit Tags
<input name="uuid" type="text" value="{{tracker_metadata['uuid']}}" hidden> </button>
<div>All E-Mails to Notify for this tracker, space separated: </div> </form>
<div class="input-group mb-2 mr-sm-2">
<div class="input-group-prepend">
<div class="input-group-text"><i class="fas fa-at"></i></div>
</div>
<input id="mails" name="mails" class="form-control" placeholder="E-Mails Notification (optional, space separated)" type="text"
value="{% for mail in tracker_metadata['mails'] %}{{mail}} {% endfor %}">
</div>
<button class="btn btn-info"> </div>
<i class="fas fa-pencil-alt"></i> Edit Email Notification
</button>
</form>
</div> <div id="div_edit_mails">
<form action="{{ url_for('hunter.update_tracker_mails') }}" method='post'>
<input name="uuid" type="text" value="{{ tracker_metadata['uuid'] }}" hidden>
<div>All E-Mails to Notify for this tracker, space separated:</div>
<div class="input-group mb-2 mr-sm-2">
<div class="input-group-prepend">
<div class="input-group-text"><i class="fas fa-at"></i></div>
</div>
<input id="mails" name="mails" class="form-control"
placeholder="E-Mails Notification (optional, space separated)" type="text"
value="{% for mail in tracker_metadata['mails'] %}{{ mail }} {% endfor %}">
</div>
<div class="d-flex flex-row-reverse"> <button class="btn btn-info">
<a href="{{ url_for('hunter.delete_tracker') }}?uuid={{tracker_metadata['uuid']}}" style="font-size: 15px"> <i class="fas fa-pencil-alt"></i> Edit Email Notification
<button class='btn btn-danger'><i class="fas fa-trash-alt"></i></button> </button>
</a> </form>
<a href="{{ url_for('hunter.edit_tracked_menu') }}?uuid={{tracker_metadata['uuid']}}" class="mx-2" style="font-size: 15px">
<button class='btn btn-info'>Edit Tracker <i class="fas fa-pencil-alt"></i></button>
</a>
</div>
{%if yara_rule_content%} </div>
<p class="my-0"></br></br><pre class="border bg-light">{{ yara_rule_content }}</pre></p>
{%endif%}
</div> <div class="d-flex flex-row-reverse">
</div> <a href="{{ url_for('hunter.delete_tracker') }}?uuid={{ tracker_metadata['uuid'] }}"
style="font-size: 15px">
<button class='btn btn-danger'><i class="fas fa-trash-alt"></i></button>
</a>
<a href="{{ url_for('hunter.edit_tracked_menu') }}?uuid={{ tracker_metadata['uuid'] }}"
class="mx-2" style="font-size: 15px">
<button class='btn btn-info'>Edit Tracker <i class="fas fa-pencil-alt"></i></button>
</a>
</div>
<div id="graphline" class="text-center"></div> {% if yara_rule_content %}
<p class="my-0"></br></br>
<pre class="border bg-light">{{ yara_rule_content }}</pre></p>
{% endif %}
<div class="card mb-5 mt-1"> </div>
<div class="card-body"> </div>
<div class="row mb-3"> <div id="graphline" class="text-center"></div>
<div class="col-md-6">
<div class="input-group" id="date-range-from">
<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-calendar-alt" aria-hidden="true"></i></span></div>
<input class="form-control" id="date-range-from-input" placeholder="yyyy-mm-dd" name="date_from" autocomplete="off"
{%if tracker_metadata['date_from']%}value="{{ tracker_metadata['date_from'] }}"{%else%}value="{{tracker_metadata['first_seen']}}"{%endif%}>
</div>
</div>
<div class="col-md-6">
<div class="input-group" id="date-range-to">
<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-calendar-alt" aria-hidden="true"></i></span></div>
<input class="form-control" id="date-range-to-input" placeholder="yyyy-mm-dd" name="date_to" autocomplete="off"
{%if tracker_metadata['date_to']%}value="{{ tracker_metadata['date_to'] }}"{%else%}value="{{tracker_metadata['last_seen']}}"{%endif%}>
</div>
</div>
</div>
<button class="btn btn-info" type="button" id="button-search-tags" onclick="getItems();"> <div class="card mb-5 mt-1">
<i class="fas fa-search"></i> Search Tracked Items <div class="card-body">
</button>
</div> <div class="row mb-3">
</div> <div class="col-md-6">
<div class="input-group" id="date-range-from">
<div class="input-group-prepend"><span class="input-group-text"><i
class="far fa-calendar-alt" aria-hidden="true"></i></span></div>
<input class="form-control" id="date-range-from-input" placeholder="yyyy-mm-dd"
name="date_from" autocomplete="off"
{% if tracker_metadata['date_from'] %}value="{{ tracker_metadata['date_from'] }}"
{% else %}value="{{ tracker_metadata['first_seen'] }}"{% endif %}>
</div>
</div>
<div class="col-md-6">
<div class="input-group" id="date-range-to">
<div class="input-group-prepend"><span class="input-group-text"><i
class="far fa-calendar-alt" aria-hidden="true"></i></span></div>
<input class="form-control" id="date-range-to-input" placeholder="yyyy-mm-dd"
name="date_to" autocomplete="off"
{% if tracker_metadata['date_to'] %}value="{{ tracker_metadata['date_to'] }}"
{% else %}value="{{ tracker_metadata['last_seen'] }}"{% endif %}>
</div>
</div>
</div>
{%if tracker_metadata['items']%} <button class="btn btn-info" type="button" id="button-search-tags" onclick="getItems();">
<div class="mt-4"> <i class="fas fa-search"></i> Search Tracked Items
<table class="table table-bordered table-hover" id="myTable_"> </button>
<thead class="thead-dark">
<tr>
<th>Date</th>
<th>Item Id</th>
</tr>
</thead>
<tbody>
{% for item in tracker_metadata['items'] %} </div>
<tr> </div>
<td>
{{item['date'][0:4]}}/{{item['date'][4:6]}}/{{item['date'][6:8]}}
</td>
<td>
<a class="text-secondary" target="_blank" href="{{ url_for('objects_item.showItem') }}?id={{item['id']}}">
<div style="line-height:0.9;">{{ item['id'] }}</div>
</a>
<div class="mb-2">
{% for tag in item['tags'] %}
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item&ltags={{ tag }}">
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
</a>
{% endfor %}
</div>
</td>
</tr>
{% endfor %}
</tbody> {% if tracker_metadata['items'] %}
</table> <div class="mt-4">
</div> <table class="table table-bordered table-hover" id="myTable_">
{% endif %} <thead class="thead-dark">
<tr>
<th>Date</th>
<th>Item Id</th>
</tr>
</thead>
<tbody>
</div> {% for item in tracker_metadata['items'] %}
</div> <tr>
</div> <td>
{{ item['date'][0:4] }}/{{ item['date'][4:6] }}/{{ item['date'][6:8] }}
</td>
<td>
<a class="text-secondary" target="_blank"
href="{{ url_for('objects_item.showItem') }}?id={{ item['id'] }}">
<div style="line-height:0.9;">{{ item['id'] }}</div>
</a>
<div class="mb-2">
{% for tag in item['tags'] %}
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item&ltags={{ tag }}">
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
</a>
{% endfor %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
</div>
</div>
<script> <script>
$(document).ready(function(){ $(document).ready(function () {
$('#div_edit_mails').hide(); $('#div_edit_mails').hide();
$('#div_edit_tags').hide(); $('#div_edit_tags').hide();
$('#div_edit_description').hide(); $('#div_edit_description').hide();
$("#page-Decoded").addClass("active"); $("#page-Decoded").addClass("active");
$('#date-range-from').dateRangePicker({ $('#date-range-from').dateRangePicker({
separator : ' to ', separator: ' to ',
getValue: function(){ getValue: function () {
if ($('#date-range-from-input').val() && $('#date-range-to-input').val() ) if ($('#date-range-from-input').val() && $('#date-range-to-input').val())
return $('#date-range-from-input').val() + ' to ' + $('#date-range-to-input').val(); return $('#date-range-from-input').val() + ' to ' + $('#date-range-to-input').val();
else else
return ''; return '';
}, },
setValue: function(s,s1,s2){ setValue: function (s, s1, s2) {
$('#date-range-from-input').val(s1); $('#date-range-from-input').val(s1);
$('#date-range-to-input').val(s2); $('#date-range-to-input').val(s2);
} }
}); });
$('#date-range-to').dateRangePicker({ $('#date-range-to').dateRangePicker({
separator : ' to ', separator: ' to ',
getValue: function(){ getValue: function () {
if ($('#date-range-from-input').val() && $('#date-range-to-input').val() ) if ($('#date-range-from-input').val() && $('#date-range-to-input').val())
return $('#date-range-from-input').val() + ' to ' + $('#date-range-to-input').val(); return $('#date-range-from-input').val() + ' to ' + $('#date-range-to-input').val();
else else
return ''; return '';
}, },
setValue: function(s,s1,s2){ setValue: function (s, s1, s2) {
$('#date-range-from-input').val(s1); $('#date-range-from-input').val(s1);
$('#date-range-to-input').val(s2); $('#date-range-to-input').val(s2);
} }
}); });
$('#myTable_').DataTable({ $('#myTable_').DataTable({
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]], "aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
"iDisplayLength": 10, "iDisplayLength": 10,
"order": [[ 0, "asc" ]] "order": [[0, "asc"]]
}); });
sparkline("sparkline", {{ tracker_metadata['sparkline'] }}, {}); sparkline("sparkline", {{ tracker_metadata['sparkline'] }}, {});
let div_width = $("#graphline").width(); let div_width = $("#graphline").width();
$.getJSON( "{{ url_for('hunter.get_json_tracker_stats') }}?uuid={{ tracker_metadata['uuid'] }}{%if tracker_metadata['date_from']%}&date_from={{ tracker_metadata['date_from'] }}{%endif%}{%if tracker_metadata['date_to']%}&date_to={{ tracker_metadata['date_to'] }}{%endif%}", $.getJSON("{{ url_for('hunter.get_json_tracker_stats') }}?uuid={{ tracker_metadata['uuid'] }}{%if tracker_metadata['date_from']%}&date_from={{ tracker_metadata['date_from'] }}{%endif%}{%if tracker_metadata['date_to']%}&date_to={{ tracker_metadata['date_to'] }}{%endif%}",
function( data ) {multilines_group("graphline", data, {"width": div_width});} function (data) {
); multilines_group("graphline", data, {"width": div_width});
}
);
}); });
function toggle_sidebar(){ function toggle_sidebar() {
if($('#nav_menu').is(':visible')){ if ($('#nav_menu').is(':visible')) {
$('#nav_menu').hide(); $('#nav_menu').hide();
$('#side_menu').removeClass('border-right') $('#side_menu').removeClass('border-right')
$('#side_menu').removeClass('col-lg-2') $('#side_menu').removeClass('col-lg-2')
$('#core_content').removeClass('col-lg-10') $('#core_content').removeClass('col-lg-10')
}else{ } else {
$('#nav_menu').show(); $('#nav_menu').show();
$('#side_menu').addClass('border-right') $('#side_menu').addClass('border-right')
$('#side_menu').addClass('col-lg-2') $('#side_menu').addClass('col-lg-2')
$('#core_content').addClass('col-lg-10') $('#core_content').addClass('col-lg-10')
} }
} }
function edit_tags(){ function edit_tags() {
$('#div_edit_mails').hide(); $('#div_edit_mails').hide();
$('#div_edit_description').hide(); $('#div_edit_description').hide();
$('#div_edit_tags').show(); $('#div_edit_tags').show();
} }
function edit_mails(){ function edit_mails() {
$('#div_edit_tags').hide(); $('#div_edit_tags').hide();
$('#div_edit_description').hide(); $('#div_edit_description').hide();
$('#div_edit_mails').show(); $('#div_edit_mails').show();
} }
function edit_description(){ function edit_description() {
$('#div_edit_tags').hide(); $('#div_edit_tags').hide();
$('#div_edit_mails').hide(); $('#div_edit_mails').hide();
$('#div_edit_description').show(); $('#div_edit_description').show();
} }
function getItems() { function getItems() {
var date_from = $('#date-range-from-input').val(); var date_from = $('#date-range-from-input').val();
var date_to =$('#date-range-to-input').val(); var date_to = $('#date-range-to-input').val();
window.location.replace("{{ url_for('hunter.show_tracker') }}?uuid={{ tracker_metadata['uuid'] }}&date_from="+date_from+"&date_to="+date_to); window.location.replace("{{ url_for('hunter.show_tracker') }}?uuid={{ tracker_metadata['uuid'] }}&date_from=" + date_from + "&date_to=" + date_to);
} }
</script> </script>

View File

@ -2,224 +2,230 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tracker Management</title> <title>Tracker Management</title>
<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png') }}"> <link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png') }}">
<!-- Core CSS --> <!-- Core CSS -->
<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script> <script src="{{ url_for('static', filename='js/jquery.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script> <script src="{{ url_for('static', filename='js/bootstrap4.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script> <script src="{{ url_for('static', filename='js/jquery.dataTables.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script> <script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/d3.min.js') }}"></script> <script src="{{ url_for('static', filename='js/d3.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/d3/sparklines.js')}}"></script> <script src="{{ url_for('static', filename='js/d3/sparklines.js') }}"></script>
<style> <style>
.btn-link { .btn-link {
color: #000000 color: #000000
} }
.mouse_pointer{
cursor: pointer; .mouse_pointer {
} cursor: pointer;
.lb-md { }
font-size: 16px;
} .lb-md {
</style> font-size: 16px;
}
</style>
</head> </head>
<body> <body>
{% include 'nav_bar.html' %} {% include 'nav_bar.html' %}
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
{% include 'hunter/menu_sidebar.html' %} {% include 'hunter/menu_sidebar.html' %}
<div class="col-12 col-lg-10" id="core_content"> <div class="col-12 col-lg-10" id="core_content">
<div class="card my-3"> <div class="card my-3">
<div class="card-header"> <div class="card-header">
<h5 class="card-title">Your {{filter_type}} Trackers</h5> <h5 class="card-title">Your {{ filter_type }} Trackers</h5>
</div> </div>
<div class="card-body"> <div class="card-body">
<table id="table_user_trackers" class="table table-striped table-bordered"> <table id="table_user_trackers" class="table table-striped table-bordered">
<thead class="bg-dark text-white"> <thead class="bg-dark text-white">
<tr> <tr>
<th>Type</th> <th>Type</th>
<th>Tracker</th> <th>Tracker</th>
<th>First seen</th> <th>First seen</th>
<th>Last seen</th> <th>Last seen</th>
<th>Email notification</th> <th>Email notification</th>
<th>sparkline</th> <th>sparkline</th>
</tr> </tr>
</thead> </thead>
<tbody style="font-size: 15px;"> <tbody style="font-size: 15px;">
{% for dict_uuid in user_term %} {% for dict_uuid in user_term %}
<tr> <tr>
<td>{{dict_uuid['type']}}</td> <td>{{ dict_uuid['type'] }}</td>
<td> <td>
<span> <span>
<a target="_blank" href="{{ url_for('hunter.show_tracker') }}?uuid={{ dict_uuid['uuid'] }}"> <a target="_blank" href="{{ url_for('hunter.show_tracker') }}?uuid={{ dict_uuid['uuid'] }}">
{% if dict_uuid['term']%} {% if dict_uuid['term'] %}
{% if dict_uuid['term']|length > 256 %} {% if dict_uuid['term']|length > 256 %}
{{ dict_uuid['term'][0:256]}}... {{ dict_uuid['term'][0:256] }}...
{% else %} {% else %}
{{ dict_uuid['term']}} {{ dict_uuid['term'] }}
{% endif %} {% endif %}
{% endif %} {% endif %}
</a> </a>
</span> </span>
<div> <div>
{% for tag in dict_uuid['tags'] %} {% for tag in dict_uuid['tags'] %}
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item&ltags={{ tag }}"> <a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item&ltags={{ tag }}">
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span> <span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
</a> </a>
{% endfor %} {% endfor %}
</div> </div>
</td> </td>
<td> <td>
{% if dict_uuid['first_seen'] %} {% if dict_uuid['first_seen'] %}
{{dict_uuid['first_seen'][0:4]}}/{{dict_uuid['first_seen'][4:6]}}/{{dict_uuid['first_seen'][6:8]}} {{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/
{% endif %} {{ dict_uuid['first_seen'][6:8] }}
</td> {% endif %}
<td> </td>
{% if dict_uuid['last_seen'] %} <td>
{{dict_uuid['last_seen'][0:4]}}/{{dict_uuid['last_seen'][4:6]}}/{{dict_uuid['last_seen'][6:8]}} {% if dict_uuid['last_seen'] %}
{% endif %} {{ dict_uuid['last_seen'][0:4] }}/{{ dict_uuid['last_seen'][4:6] }}/
</td> {{ dict_uuid['last_seen'][6:8] }}
<td> {% endif %}
{% for mail in dict_uuid['mails'] %} </td>
{{ mail }}<br> <td>
{% endfor %} {% for mail in dict_uuid['mails'] %}
</td> {{ mail }}<br>
<td id="sparklines_{{ dict_uuid['uuid'] }}" style="text-align:center;"></td> {% endfor %}
</tr> </td>
{% endfor %} <td id="sparklines_{{ dict_uuid['uuid'] }}" style="text-align:center;"></td>
</tbody> </tr>
</table> {% endfor %}
</div> </tbody>
</div> </table>
</div>
</div>
<div class="card my-3"> <div class="card my-3">
<div class="card-header"> <div class="card-header">
<h5 class="card-title">Global {{filter_type}} Trackers</h5> <h5 class="card-title">Global {{ filter_type }} Trackers</h5>
</div> </div>
<div class="card-body"> <div class="card-body">
<table id="table_global_trackers" class="table table-striped table-bordered"> <table id="table_global_trackers" class="table table-striped table-bordered">
<thead class="bg-dark text-white"> <thead class="bg-dark text-white">
<tr> <tr>
<th>Type</th> <th>Type</th>
<th>Tracker</th> <th>Tracker</th>
<th>First seen</th> <th>First seen</th>
<th>Last seen</th> <th>Last seen</th>
<th>Email notification</th> <th>Email notification</th>
<th>sparkline</th> <th>sparkline</th>
</tr> </tr>
</thead> </thead>
<tbody style="font-size: 15px;"> <tbody style="font-size: 15px;">
{% for dict_uuid in global_term %} {% for dict_uuid in global_term %}
<tr> <tr>
<td>{{dict_uuid['type']}}</td> <td>{{ dict_uuid['type'] }}</td>
<td> <td>
<span> <span>
<a target="_blank" href="{{ url_for('hunter.show_tracker') }}?uuid={{ dict_uuid['uuid'] }}"> <a target="_blank" href="{{ url_for('hunter.show_tracker') }}?uuid={{ dict_uuid['uuid'] }}">
{% if dict_uuid['term']%} {% if dict_uuid['term'] %}
{% if dict_uuid['term']|length > 256 %} {% if dict_uuid['term']|length > 256 %}
{{ dict_uuid['term'][0:256]}}... {{ dict_uuid['term'][0:256] }}...
{% else %} {% else %}
{{ dict_uuid['term']}} {{ dict_uuid['term'] }}
{% endif %} {% endif %}
{% endif %} {% endif %}
</a> </a>
</span> </span>
<div> <div>
{% for tag in dict_uuid['tags'] %} {% for tag in dict_uuid['tags'] %}
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item&ltags={{ tag }}"> <a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type=item&ltags={{ tag }}">
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }}</span> <span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }}</span>
</a> </a>
{% endfor %} {% endfor %}
</div> </div>
</td> </td>
<td> <td>
{% if dict_uuid['first_seen'] %} {% if dict_uuid['first_seen'] %}
{{dict_uuid['first_seen'][0:4]}}/{{dict_uuid['first_seen'][4:6]}}/{{dict_uuid['first_seen'][6:8]}} {{ dict_uuid['first_seen'][0:4] }}/{{ dict_uuid['first_seen'][4:6] }}/
{% endif %} {{ dict_uuid['first_seen'][6:8] }}
</td> {% endif %}
<td> </td>
{% if dict_uuid['last_seen'] %} <td>
{{dict_uuid['last_seen'][0:4]}}/{{dict_uuid['last_seen'][4:6]}}/{{dict_uuid['last_seen'][6:8]}} {% if dict_uuid['last_seen'] %}
{% endif %} {{ dict_uuid['last_seen'][0:4] }}/{{ dict_uuid['last_seen'][4:6] }}/
</td> {{ dict_uuid['last_seen'][6:8] }}
<td> {% endif %}
{% for mail in dict_uuid['mails'] %} </td>
{{ mail }}<br>
{% endfor %} <td>
</td> {% for mail in dict_uuid['mails'] %}
<td id="sparklines_{{ dict_uuid['uuid'] }}" style="text-align:center;"></td> {{ mail }}<br>
</tr> {% endfor %}
{% endfor %} </td>
</tbody> <td id="sparklines_{{ dict_uuid['uuid'] }}" style="text-align:center;"></td>
</table> </tr>
</div> {% endfor %}
</tbody>
</table>
</div>
</div>
<a class="btn btn-info my-4" href="{{ url_for('hunter.add_tracked_menu') }}">
<i class="fas fa-plus-circle ml-auto"></i>
Create New Tracker
</a>
</div> </div>
</div>
</div>
<a class="btn btn-info my-4" href="{{url_for('hunter.add_tracked_menu')}}">
<i class="fas fa-plus-circle ml-auto"></i>
Create New Tracker
</a>
</div>
</div>
</div>
<script> <script>
$(document).ready(function(){ $(document).ready(function () {
$("#page-Tracker").addClass("active"); $("#page-Tracker").addClass("active");
$("#nav_tracker_{{filter_type}}").addClass("active"); $("#nav_tracker_{{filter_type}}").addClass("active");
{% for dict_uuid in user_term %} {% for dict_uuid in user_term %}
sparkline("sparklines_{{ dict_uuid['uuid'] }}", {{ dict_uuid['sparkline'] }}, {height: 40}); sparkline("sparklines_{{ dict_uuid['uuid'] }}", {{ dict_uuid['sparkline'] }}, {height: 40});
{% endfor %} {% endfor %}
{% for dict_uuid in global_term %} {% for dict_uuid in global_term %}
sparkline("sparklines_{{ dict_uuid['uuid'] }}", {{ dict_uuid['sparkline'] }}, {height: 40}); sparkline("sparklines_{{ dict_uuid['uuid'] }}", {{ dict_uuid['sparkline'] }}, {height: 40});
{% endfor %} {% endfor %}
$('#table_user_trackers').DataTable({ $('#table_user_trackers').DataTable({
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]], "aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
"iDisplayLength": 10, "iDisplayLength": 10,
"order": [[ 0, "desc" ]] "order": [[0, "desc"]]
}); });
$('#table_global_trackers').DataTable({ $('#table_global_trackers').DataTable({
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]], "aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
"iDisplayLength": 10, "iDisplayLength": 10,
"order": [[ 0, "desc" ]] "order": [[0, "desc"]]
}); });
}); });
function toggle_sidebar(){ function toggle_sidebar() {
if($('#nav_menu').is(':visible')){ if ($('#nav_menu').is(':visible')) {
$('#nav_menu').hide(); $('#nav_menu').hide();
$('#side_menu').removeClass('border-right') $('#side_menu').removeClass('border-right')
$('#side_menu').removeClass('col-lg-2') $('#side_menu').removeClass('col-lg-2')
$('#core_content').removeClass('col-lg-10') $('#core_content').removeClass('col-lg-10')
}else{ } else {
$('#nav_menu').show(); $('#nav_menu').show();
$('#side_menu').addClass('border-right') $('#side_menu').addClass('border-right')
$('#side_menu').addClass('col-lg-2') $('#side_menu').addClass('col-lg-2')
$('#core_content').addClass('col-lg-10') $('#core_content').addClass('col-lg-10')
} }
} }
</script> </script>
</body> </body>

View File

@ -45,7 +45,7 @@
<input type="hidden" name="index_name" class="form-control" value="0" placeholder="Index Name"> <input type="hidden" name="index_name" class="form-control" value="0" placeholder="Index Name">
<button class="btn btn-outline-info my-2 my-sm-0" type="submit"><i class="fas fa-search"></i></button> <button class="btn btn-outline-info my-2 my-sm-0" type="submit"><i class="fas fa-search"></i></button>
</div> </div>
<small id="advanced_search" class="form-text"><a class="nav text-muted" href="#" aria-disabled="true">Advanced Search</a></small> {#<small id="advanced_search" class="form-text"><a class="nav text-muted" href="#" aria-disabled="true">Advanced Search</a></small>#}
</div> </div>
</form> </form>
</div> </div>