From f4102dd2423f9322308a7490b575530cf3278eea Mon Sep 17 00:00:00 2001 From: Terrtia Date: Mon, 30 May 2022 09:15:50 +0200 Subject: [PATCH] fix: [Hosts module] module + launcher --- bin/LAUNCH.sh | 7 ++-- bin/modules/Hosts.py | 77 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100755 bin/modules/Hosts.py diff --git a/bin/LAUNCH.sh b/bin/LAUNCH.sh index bd6755b3..b0942517 100755 --- a/bin/LAUNCH.sh +++ b/bin/LAUNCH.sh @@ -209,8 +209,6 @@ function launching_scripts { sleep 0.1 screen -S "Script_AIL" -X screen -t "Decoder" bash -c "cd ${AIL_BIN}/modules; ${ENV_PY} ./Decoder.py; read x" sleep 0.1 - screen -S "Script_AIL" -X screen -t "DomClassifier" bash -c "cd ${AIL_BIN}/modules; ${ENV_PY} ./DomClassifier.py; read x" - sleep 0.1 screen -S "Script_AIL" -X screen -t "Keys" bash -c "cd ${AIL_BIN}/modules; ${ENV_PY} ./Keys.py; read x" sleep 0.1 screen -S "Script_AIL" -X screen -t "Onion" bash -c "cd ${AIL_BIN}/modules; ${ENV_PY} ./Onion.py; read x" @@ -220,6 +218,11 @@ function launching_scripts { screen -S "Script_AIL" -X screen -t "Telegram" bash -c "cd ${AIL_BIN}/modules; ${ENV_PY} ./Telegram.py; read x" sleep 0.1 + screen -S "Script_AIL" -X screen -t "Hosts" bash -c "cd ${AIL_BIN}/modules; ${ENV_PY} ./Hosts.py; read x" + sleep 0.1 + screen -S "Script_AIL" -X screen -t "DomClassifier" bash -c "cd ${AIL_BIN}/modules; ${ENV_PY} ./DomClassifier.py; read x" + sleep 0.1 + screen -S "Script_AIL" -X screen -t "Urls" bash -c "cd ${AIL_BIN}/modules; ${ENV_PY} ./Urls.py; read x" sleep 0.1 screen -S "Script_AIL" -X screen -t "SQLInjectionDetection" bash -c "cd ${AIL_BIN}/modules; ${ENV_PY} ./SQLInjectionDetection.py; read x" diff --git a/bin/modules/Hosts.py b/bin/modules/Hosts.py new file mode 100755 index 00000000..5c89a5dc --- /dev/null +++ b/bin/modules/Hosts.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# -*-coding:UTF-8 -* + +""" +The Hosts Module +====================== + +This module is consuming the Redis-list created by the Global module. + +It is looking for Hosts + +""" + +################################## +# Import External packages +################################## +import os +import re +import sys +import time + +sys.path.append(os.environ['AIL_BIN']) +################################## +# Import Project packages +################################## +from modules.abstract_module import AbstractModule +from lib.ConfigLoader import ConfigLoader +from lib import regex_helper +#from lib.objects.Items import Item +from packages.Item import Item + +class Hosts(AbstractModule): + """ + Hosts module for AIL framework + """ + + def __init__(self): + super(Hosts, self).__init__() + + config_loader = ConfigLoader() + self.r_cache = config_loader.get_redis_conn("Redis_Cache") + + self.redis_cache_key = regex_helper.generate_redis_cache_key(self.module_name) + + # regex timeout + self.regex_timeout = 30 + + # Waiting time in secondes between to message proccessed + self.pending_seconds = 1 + + self.host_regex = r'\b([a-zA-Z\d-]{,63}(?:\.[a-zA-Z\d-]{,63})+)\b' + re.compile(self.host_regex) + + self.redis_logger.info(f"Module: {self.module_name} Launched") + + + def compute(self, message): + item = Item(message) + + # mimetype = item_basic.get_item_mimetype(item.get_id()) + # if mimetype.split('/')[0] == "text": + + content = item.get_content() + + hosts = regex_helper.regex_findall(self.module_name, self.redis_cache_key, self.host_regex, item.get_id(), content) + for host in hosts: + #print(host) + + msg = f'{host} {item.get_id()}' + self.send_message_to_queue(msg, 'Host') + + + +if __name__ == '__main__': + + module = Hosts() + module.run()