diff --git a/api/server.py b/api/server.py index f5998fa2..10fd9622 100644 --- a/api/server.py +++ b/api/server.py @@ -25,7 +25,7 @@ fix_skip, fix_filter_query, msg_structure, - root_dir) + root_dir, get_running_modules_details) from config import ( api_configuration, user_configuration) @@ -648,6 +648,46 @@ def all_module_names(): abort(500) +@app.route("/api/core/running/modules", methods=["GET"]) +def all_running_module_details(): + """ + Get the list of details of all running module details + --- + responses: + '200': + description: Ok + examples: + application/json: + [ + { + "Command":"\"/bin/sh -c 'service\u2026\"", + "CreatedAt":"2022-07-27 21:49:43 +0530 IST", + "ID":"b5760a5cc113", + "Image":"ohp_ftpserver_weak_password", + "LocalVolumes":"0", + "Mounts":"/host_mnt/User\u2026", + "Names":"ohp_ftpserver_weak_password", + "Networks":"ohp_internet", + "Ports":"0.0.0.0:21->21/tcp", + "RunningFor":"About an hour ago", + "Size":"3B (virtual 293MB)", + "State":"running", + "Status":"Up About an hour" + } + ] + '500': + description: Internal Server Error + examples: + application/json: { "msg": "file/path not found!", "status": "error" } + """ + try: + return jsonify( + get_running_modules_details() + ), 200 + except Exception: + abort(500) + + @app.route("/docs-configuration") def spec(): """ diff --git a/api/utility.py b/api/utility.py index 68106431..a57438d8 100644 --- a/api/utility.py +++ b/api/utility.py @@ -1,8 +1,10 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - +import json import os +from core.get_modules import load_all_modules_docker_names + def msg_structure(status="", msg=""): """ @@ -232,3 +234,25 @@ def aggregate_function(data_connection, agr_query): allowDiskUse=True ) ) + + +def get_running_modules_details(): + """ + Get all running modules details + Returns: + list of details of running modules + + """ + module_details = [] + delimiter = "}" + data = os.popen("docker ps --format '{{json .}}'").read().replace("\n", "").split(delimiter) + if len(data) > 1 and data[-1] == "": + data = data[:-1] + else: + data = [] + for str_module_data in data: + module_data = json.loads(str_module_data + delimiter) + if module_data["Names"] in load_all_modules_docker_names(): + module_details.append(module_data) + + return module_details diff --git a/core/compatible.py b/core/compatible.py index 91602e95..ee0cd0e1 100644 --- a/core/compatible.py +++ b/core/compatible.py @@ -70,7 +70,8 @@ def check_for_requirements(start_api_server): http_auth=api_config["api_database_http_auth"] ) connection.indices.get_alias("*") - except Exception: + except Exception as e: + print(e) exit_failure(messages["elasticsearch_not_found"]) # check if its honeypot server not api server if not start_api_server: diff --git a/core/get_modules.py b/core/get_modules.py index 83cc9922..08e5023a 100644 --- a/core/get_modules.py +++ b/core/get_modules.py @@ -77,3 +77,30 @@ def load_all_modules(): else: warn(messages["module_not_available"].format(module_name)) return module_names + + +def load_all_modules_docker_names(): + """ + load all available modules names + + Returns: + an array of all module names used while creating docker containers + """ + module_names = [] + module_basepath = os.path.dirname(inspect.getfile(modules)) + path_pattern = module_basepath + '/*/*/__init__.py' + + for module in glob(path_pattern): + + module_dir = os.path.split(module)[0] + sub_module_name = os.path.split(module_dir)[1] + category_name = os.path.split(os.path.split(module_dir)[0])[1] + module_name = category_name + '/' + sub_module_name + dockerfile_path = os.path.join(module_dir, "Dockerfile") + + if os.path.exists(dockerfile_path): + if module_name not in module_names: + module_names.append('ohp_' + category_name + 'server_' + sub_module_name) + else: + warn(messages["module_not_available"].format(module_name)) + return module_names diff --git a/lib/messages/de_DE.yaml b/lib/messages/de_DE.yaml index 998c61c5..25f6f08b 100644 --- a/lib/messages/de_DE.yaml +++ b/lib/messages/de_DE.yaml @@ -82,4 +82,9 @@ received_network_event: 'Empfangenes Netzwerkereignis, ip_dest:{0}, port_dest:{1 received_honeypot_credential_event: 'Empfangenes Honeypot-Anmeldedatenereignis, ip_dest:{0}, username:{1}, password:{2}, module_name:{3}, machine_name:{4}' received_honeypot_file_change_event: 'Empfangenes Honeypot-Dateiänderungsereignis, file_path:{0}, status:{1}, module_name:{2}, module_name:{3}, machine_name:{3}' received_honeypot_data_event: 'Empfangenes Honeypot-Datenereignis, ip_dest:{0}, module_name:{1}, machine_name:{2}, data:{3}' -received_network_traffic_file: 'Empfangene Netzwerkdatenverkehrsdatei:{0}, Datum:{1}. Einfügen in das Dateiarchiv' \ No newline at end of file +received_network_traffic_file: 'Empfangene Netzwerkdatenverkehrsdatei:{0}, Datum:{1}. Einfügen in das Dateiarchiv' +running_module: Laufende Module +running_modules_message: Details zu laufenden Modulen (Netzwerkerfassungsprozess) +no_modules_running_message: Derzeit laufen keine Module +modules_api_error_message: Beim Laden laufender Module ist ein Fehler aufgetreten. Bitte versuchen Sie es später erneut. +export_module_heading: Export Running Module Details \ No newline at end of file diff --git a/lib/messages/en_US.yaml b/lib/messages/en_US.yaml index 1a8ef44e..7d3240ca 100644 --- a/lib/messages/en_US.yaml +++ b/lib/messages/en_US.yaml @@ -83,3 +83,8 @@ received_honeypot_credential_event: 'Received honeypot credential event, ip_dest received_honeypot_file_change_event: 'Received honeypot file change event, file_path:{0}, status:{1}, module_name:{2}, module_name:{3}, machine_name:{3}' received_honeypot_data_event: 'Received honeypot data event, ip_dest:{0}, module_name:{1}, machine_name:{2}, data:{3}' received_network_traffic_file: 'Received network traffic file:{0}, date:{1}. Inserting it in the File Archive' +running_module: Running Modules +running_modules_message: Details of Running Modules (Network Capture Process) +no_modules_running_message: No modules are running currently +modules_api_error_message: There is some error while loading running modules. Please try again later. +export_module_heading: Export Running Module Details \ No newline at end of file diff --git a/lib/messages/es_ES.yaml b/lib/messages/es_ES.yaml index 5b6e6a47..57158a94 100644 --- a/lib/messages/es_ES.yaml +++ b/lib/messages/es_ES.yaml @@ -82,4 +82,9 @@ received_network_event: 'Evento de red recibido, ip_dest: {0}, port_dest: {1}, i received_honeypot_credential_event: 'Recibido evento de credencial de honeypot, ip_dest:{0}, username:{1}, password:{2}, module_name:{3}, machine_name:{4}' received_honeypot_file_change_event: 'Recibido evento de cambio de archivo honeypot, file_path:{0}, status:{1}, module_name:{2}, module_name:{3}, machine_name:{3}' received_honeypot_data_event: 'Recibido evento de datos de honeypot, ip_dest:{0}, module_name:{1}, machine_name:{2}, data:{3}' -received_network_traffic_file: 'Archivo de tráfico de red recibido: {0}, fecha: {1}. Insertarlo en el archivo de archivos' \ No newline at end of file +received_network_traffic_file: 'Archivo de tráfico de red recibido: {0}, fecha: {1}. Insertarlo en el archivo de archivos' +running_module: Módulos en ejecución +running_modules_message: Detalles de los módulos en ejecución (proceso de captura de red) +no_modules_running_message: No hay módulos en ejecución actualmente +modules_api_error_message: Hay algún error al cargar módulos en ejecución. Por favor, inténtelo de nuevo más tarde. +export_module_heading: Exportar detalles del módulo en ejecución \ No newline at end of file diff --git a/lib/messages/fr_FR.yaml b/lib/messages/fr_FR.yaml index f553ed77..e920f13f 100644 --- a/lib/messages/fr_FR.yaml +++ b/lib/messages/fr_FR.yaml @@ -82,4 +82,9 @@ received_network_event: 'Événement réseau reçu, ip_dest:{0}, port_dest:{1}, received_honeypot_credential_event: "Événement d'identification Honeypot reçu, ip_dest:{0}, username:{1}, password:{2}, module_name:{3}, machine_name:{4}" received_honeypot_file_change_event: 'Événement de changement de fichier Honeypot reçu, file_path:{0}, status:{1}, module_name:{2}, module_name:{3}, machine_name:{3}' received_honeypot_data_event: 'Événement de données de pot de miel reçu, ip_dest:{0}, module_name:{1}, machine_name:{2}, data:{3}' -received_network_traffic_file: "Fichier de trafic réseau reçu :{0}, date :{1}. L'insérer dans l'archive de fichiers" \ No newline at end of file +received_network_traffic_file: "Fichier de trafic réseau reçu :{0}, date :{1}. L'insérer dans l'archive de fichiers" +running_module: Modules en cours d'exécution +running_modules_message: Détails des modules en cours d'exécution (processus de capture réseau) +no_modules_running_message: Aucun module n'est en cours d'exécution actuellement +modules_api_error_message: Il y a une erreur lors du chargement des modules en cours d'exécution. Veuillez réessayer plus tard. +export_module_heading: Exporter les détails du module en cours d'exécution \ No newline at end of file diff --git a/lib/messages/ru_RU.yaml b/lib/messages/ru_RU.yaml index 23646d1b..1756861f 100644 --- a/lib/messages/ru_RU.yaml +++ b/lib/messages/ru_RU.yaml @@ -82,4 +82,9 @@ received_network_event: 'Получено сетевое событие, ip_dest received_honeypot_credential_event: 'Получено событие учетных данных Honeypot, ip_dest:{0}, username:{1}, password:{2}, module_name:{3}, machine_name:{4}' received_honeypot_file_change_event: 'Получено событие изменения файла Honeypot, file_path:{0}, status:{1}, module_name:{2}, module_name:{3}, machine_name:{3}' received_honeypot_data_event: 'Получено событие данных HoneyPot, ip_dest:{0}, module_name:{1}, machine_name:{2}, data:{3}' -received_network_traffic_file: 'Получен файл сетевого трафика: {0}, дата: {1}. Вставка в файловый архив' \ No newline at end of file +received_network_traffic_file: 'Получен файл сетевого трафика: {0}, дата: {1}. Вставка в файловый архив' +running_module: Запуск модулей +running_modules_message: Сведения о запущенных модулях (процесс захвата сети) +no_modules_running_message: В настоящее время ни один модуль не запущен +modules_api_error_message: Произошла ошибка при загрузке запущенных модулей. Пожалуйста, попробуйте позже. +export_module_heading: Экспорт сведений о работающем модуле \ No newline at end of file diff --git a/web/static/css/style.css b/web/static/css/style.css index a334004c..d3b9fef9 100644 --- a/web/static/css/style.css +++ b/web/static/css/style.css @@ -37,7 +37,7 @@ body { float: center; } -#error-message-element{ +#error-message-element, #error-message-element-modules { text-align: center; max-width: 80%; margin: 0 auto; @@ -201,4 +201,11 @@ blink { .button:hover { transform: scale(1.05); +} + +table, +th, +td { + border: 1px solid black; + border-collapse: collapse; } \ No newline at end of file diff --git a/web/static/img/csv.png b/web/static/img/csv.png new file mode 100644 index 00000000..cb99b82a Binary files /dev/null and b/web/static/img/csv.png differ diff --git a/web/static/img/excel.jpg b/web/static/img/excel.jpg new file mode 100644 index 00000000..5ba39daa Binary files /dev/null and b/web/static/img/excel.jpg differ diff --git a/web/static/img/json.png b/web/static/img/json.png new file mode 100644 index 00000000..d0ff1fd9 Binary files /dev/null and b/web/static/img/json.png differ diff --git a/web/static/img/pdf.png b/web/static/img/pdf.png new file mode 100644 index 00000000..318db043 Binary files /dev/null and b/web/static/img/pdf.png differ diff --git a/web/static/index.html b/web/static/index.html index 63c16b2f..8c664aab 100644 --- a/web/static/index.html +++ b/web/static/index.html @@ -25,6 +25,7 @@ + @@ -44,6 +45,10 @@ +