atomicshop 2.15.12__py3-none-any.whl → 2.16.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of atomicshop might be problematic. Click here for more details.

Files changed (42) hide show
  1. atomicshop/__init__.py +1 -1
  2. atomicshop/a_mains/dns_gateway_setting.py +11 -0
  3. atomicshop/basics/booleans.py +14 -5
  4. atomicshop/dns.py +104 -0
  5. atomicshop/file_io/docxs.py +8 -0
  6. atomicshop/file_io/tomls.py +133 -0
  7. atomicshop/filesystem.py +5 -4
  8. atomicshop/get_process_list.py +3 -3
  9. atomicshop/mitm/config_static.py +195 -0
  10. atomicshop/mitm/config_toml_editor.py +55 -0
  11. atomicshop/mitm/connection_thread_worker.py +54 -90
  12. atomicshop/mitm/import_config.py +147 -139
  13. atomicshop/mitm/initialize_engines.py +7 -2
  14. atomicshop/mitm/initialize_mitm_server.py +161 -107
  15. atomicshop/mitm/shared_functions.py +0 -1
  16. atomicshop/mitm/statistic_analyzer.py +13 -1
  17. atomicshop/mitm/statistic_analyzer_helper/moving_average_helper.py +54 -14
  18. atomicshop/script_as_string_processor.py +5 -1
  19. atomicshop/wrappers/cryptographyw.py +3 -3
  20. atomicshop/wrappers/psutilw/networks.py +25 -1
  21. atomicshop/wrappers/pywin32w/wmis/__init__.py +0 -0
  22. atomicshop/wrappers/pywin32w/wmis/helpers.py +127 -0
  23. atomicshop/wrappers/pywin32w/wmis/win32networkadapter.py +167 -0
  24. atomicshop/wrappers/socketw/accepter.py +8 -8
  25. atomicshop/wrappers/socketw/base.py +13 -0
  26. atomicshop/wrappers/socketw/certificator.py +202 -149
  27. atomicshop/wrappers/socketw/creator.py +15 -35
  28. atomicshop/wrappers/socketw/dns_server.py +157 -103
  29. atomicshop/wrappers/socketw/exception_wrapper.py +8 -27
  30. atomicshop/wrappers/socketw/get_process.py +115 -95
  31. atomicshop/wrappers/socketw/sni.py +298 -164
  32. atomicshop/wrappers/socketw/socket_client.py +5 -12
  33. atomicshop/wrappers/socketw/socket_server_tester.py +1 -1
  34. atomicshop/wrappers/socketw/socket_wrapper.py +328 -72
  35. atomicshop/wrappers/socketw/statistics_csv.py +94 -16
  36. {atomicshop-2.15.12.dist-info → atomicshop-2.16.0.dist-info}/METADATA +1 -1
  37. {atomicshop-2.15.12.dist-info → atomicshop-2.16.0.dist-info}/RECORD +41 -36
  38. atomicshop/mitm/config_editor.py +0 -37
  39. /atomicshop/wrappers/pywin32w/{wmi_win32process.py → wmis/win32process.py} +0 -0
  40. {atomicshop-2.15.12.dist-info → atomicshop-2.16.0.dist-info}/LICENSE.txt +0 -0
  41. {atomicshop-2.15.12.dist-info → atomicshop-2.16.0.dist-info}/WHEEL +0 -0
  42. {atomicshop-2.15.12.dist-info → atomicshop-2.16.0.dist-info}/top_level.txt +0 -0
@@ -1,86 +1,45 @@
1
1
  from datetime import datetime
2
2
 
3
- from .message import ClientMessage
4
- from .initialize_engines import assign_class_by_domain
5
- from ..wrappers.socketw.receiver import Receiver
6
- from ..wrappers.socketw.sender import Sender
7
- from ..wrappers.socketw.socket_client import SocketClient
3
+ from ..wrappers.socketw import receiver, sender, socket_client, base
8
4
  from ..http_parse import HTTPRequestParse, HTTPResponseParse
9
5
  from ..basics.threads import current_thread_id
10
6
  from ..print_api import print_api
11
7
 
8
+ from .message import ClientMessage
9
+ from .initialize_engines import assign_class_by_domain
10
+ from . import config_static
11
+
12
12
 
13
13
  # Thread function on client connect.
14
14
  def thread_worker_main(
15
15
  function_client_socket_object,
16
16
  process_commandline: str,
17
17
  is_tls: bool,
18
+ tls_type: str,
19
+ tls_version: str,
18
20
  domain_from_dns,
19
21
  network_logger,
20
- statistics_logger,
22
+ statistics_writer,
21
23
  engines_list,
22
- reference_module,
23
- config):
24
+ reference_module
25
+ ):
24
26
  def output_statistics_csv_row():
25
- statistics_dict['host'] = client_message.server_name
26
- try:
27
- statistics_dict['path'] = client_message.request_raw_decoded.path
28
- except Exception:
29
- pass
30
- try:
31
- statistics_dict['status_code'] = \
32
- ','.join([str(x.code) for x in client_message.response_list_of_raw_decoded])
33
- except Exception:
34
- pass
35
- try:
36
- statistics_dict['command'] = client_message.request_raw_decoded.command
37
- except Exception:
38
- pass
39
- try:
40
- statistics_dict['request_time_sent'] = client_message.request_time_received
41
- except Exception:
42
- pass
43
- try:
44
- statistics_dict['request_size_bytes'] = len(client_message.request_raw_bytes)
45
- except Exception:
46
- pass
47
- try:
48
- statistics_dict['response_size_bytes'] = \
49
- ','.join([str(len(x)) for x in client_message.response_list_of_raw_bytes])
50
- except Exception:
51
- pass
52
- # try:
53
- # statistics_dict['request_hex'] = client_message.request_raw_hex
54
- # except Exception:
55
- # pass
56
- # try:
57
- # statistics_dict['response_hex'] = \
58
- # f'"' + ','.join([x for x in client_message.response_list_of_raw_hex]) + '"'
59
- # except Exception:
60
- # pass
61
- try:
62
- statistics_dict['file_path'] = recorded_file
63
- except Exception:
64
- pass
65
- try:
66
- statistics_dict['process_cmd'] = process_commandline
67
- except Exception:
68
- pass
69
- statistics_dict['error'] = str()
70
-
71
- statistics_logger.info(f"{statistics_dict['request_time_sent']},"
72
- f"{statistics_dict['host']},"
73
- f"\"{statistics_dict['path']}\","
74
- f"{statistics_dict['command']},"
75
- f"{statistics_dict['status_code']},"
76
- f"{statistics_dict['request_size_bytes']},"
77
- f"{statistics_dict['response_size_bytes']},"
78
- # f"{statistics_dict['request_hex']},"
79
- # f"{statistics_dict['response_hex']},"
80
- f"\"{statistics_dict['file_path']}\","
81
- f"\"{statistics_dict['process_cmd']}\","
82
- f"{statistics_dict['error']}"
83
- )
27
+ status_code = ','.join([str(x.code) for x in client_message.response_list_of_raw_decoded])
28
+ response_size_bytes = ','.join([str(len(x)) for x in client_message.response_list_of_raw_bytes])
29
+
30
+ statistics_writer.write_row(
31
+ host=client_message.server_name,
32
+ tls_type=tls_type,
33
+ tls_version=tls_version,
34
+ path=client_message.request_raw_decoded.path,
35
+ status_code=status_code,
36
+ command=client_message.request_raw_decoded.command,
37
+ request_time_sent=client_message.request_time_received,
38
+ request_size_bytes=len(client_message.request_raw_bytes),
39
+ response_size_bytes=response_size_bytes,
40
+ recorded_file_path=recorded_file,
41
+ process_cmd=process_commandline,
42
+ error=str())
84
43
 
85
44
  try:
86
45
  # Defining variables before assignment
@@ -113,8 +72,12 @@ def thread_worker_main(
113
72
  # Loading parser by domain, if there is no parser for current domain - general reference parser is loaded.
114
73
  # These should be outside any loop and initialized only once entering the thread.
115
74
  parser, responder, recorder = assign_class_by_domain(
116
- engines_list, client_message.server_name, reference_module=reference_module, config=config,
117
- logger=network_logger)
75
+ engines_usage=config_static.TCPServer.engines_usage,
76
+ engines_list=engines_list,
77
+ message_domain_name=client_message.server_name,
78
+ reference_module=reference_module,
79
+ logger=network_logger
80
+ )
118
81
 
119
82
  # Defining client connection boolean variable to enter the loop
120
83
  client_connection_boolean: bool = True
@@ -128,22 +91,22 @@ def thread_worker_main(
128
91
  client_message.reinitialize()
129
92
 
130
93
  # Initialize statistics_dict for the same reason as 'client_message.reinitialize()'.
131
- statistics_dict: dict = dict()
132
- statistics_dict['host'] = client_message.server_name
133
- statistics_dict['path'] = str()
134
- statistics_dict['status_code'] = str()
135
- statistics_dict['command'] = str()
136
- statistics_dict['request_time_sent'] = str()
137
- statistics_dict['request_size_bytes'] = str()
138
- # statistics_dict['response_time_sent'] = str()
139
- statistics_dict['response_size_bytes'] = str()
140
- statistics_dict['file_path'] = str()
141
- statistics_dict['process_cmd'] = str()
142
- statistics_dict['error'] = str()
94
+ # statistics_dict: dict = dict()
95
+ # statistics_dict['host'] = client_message.server_name
96
+ # statistics_dict['path'] = str()
97
+ # statistics_dict['status_code'] = str()
98
+ # statistics_dict['command'] = str()
99
+ # statistics_dict['request_time_sent'] = str()
100
+ # statistics_dict['request_size_bytes'] = str()
101
+ # # statistics_dict['response_time_sent'] = str()
102
+ # statistics_dict['response_size_bytes'] = str()
103
+ # statistics_dict['file_path'] = str()
104
+ # statistics_dict['process_cmd'] = str()
105
+ # statistics_dict['error'] = str()
143
106
 
144
107
  network_logger.info("Initializing Receiver")
145
108
  # Getting message from the client over the socket using specific class.
146
- client_received_raw_data = Receiver(function_client_socket_object).receive()
109
+ client_received_raw_data = receiver.Receiver(function_client_socket_object).receive()
147
110
 
148
111
  # If the message is empty, then the connection was closed already by the other side,
149
112
  # so we can close the socket as well.
@@ -214,7 +177,7 @@ def thread_worker_main(
214
177
  pass
215
178
 
216
179
  # If we're in response mode, execute responder.
217
- if config['tcp']['server_response_mode']:
180
+ if config_static.TCPServer.server_response_mode:
218
181
  # Since we're in response mode, we'll record the request anyway, after the responder did its job.
219
182
  client_message.info = "In Server Response Mode"
220
183
 
@@ -251,14 +214,15 @@ def thread_worker_main(
251
214
  if not service_client:
252
215
  # If we're on localhost, then use external services list in order to resolve the domain:
253
216
  # config['tcp']['forwarding_dns_service_ipv4_list___only_for_localhost']
254
- if client_message.client_ip == "127.0.0.1":
255
- service_client = SocketClient(
217
+ if client_message.client_ip in base.THIS_DEVICE_IP_LIST:
218
+ service_client = socket_client.SocketClient(
256
219
  service_name=client_message.server_name, service_port=client_message.destination_port,
257
220
  tls=is_tls,
258
- dns_servers_list=config['tcp']['forwarding_dns_service_ipv4_list___only_for_localhost'])
221
+ dns_servers_list=
222
+ config_static.TCPServer.forwarding_dns_service_ipv4_list___only_for_localhost)
259
223
  # If we're not on localhost, then connect to domain directly.
260
224
  else:
261
- service_client = SocketClient(
225
+ service_client = socket_client.SocketClient(
262
226
  service_name=client_message.server_name, service_port=client_message.destination_port,
263
227
  tls=is_tls)
264
228
 
@@ -289,7 +253,7 @@ def thread_worker_main(
289
253
  # Recording the message, doesn't matter what type of mode this is.
290
254
  try:
291
255
  recorded_file = recorder(class_client_message=client_message,
292
- record_path=config['recorder']['recordings_path']).record()
256
+ record_path=config_static.Recorder.recordings_path).record()
293
257
  except Exception:
294
258
  message = "Exception in Recorder"
295
259
  print_api(
@@ -315,7 +279,7 @@ def thread_worker_main(
315
279
 
316
280
  # Iterate through the list of byte responses.
317
281
  for response_raw_bytes in client_message.response_list_of_raw_bytes:
318
- function_data_sent = Sender(function_client_socket_object, response_raw_bytes).send()
282
+ function_data_sent = sender.Sender(function_client_socket_object, response_raw_bytes).send()
319
283
 
320
284
  # If there was problem with sending data, we'll break current loop.
321
285
  if not function_data_sent:
@@ -348,7 +312,7 @@ def thread_worker_main(
348
312
  if not function_recorded:
349
313
  try:
350
314
  recorded_file = recorder(
351
- class_client_message=client_message, record_path=config['recorder']['recordings_path']).record()
315
+ class_client_message=client_message, record_path=config_static.Recorder.recordings_path).record()
352
316
  except Exception:
353
317
  message = "Exception in Recorder"
354
318
  print_api(
@@ -1,145 +1,153 @@
1
- import sys
1
+ from pathlib import Path
2
2
 
3
- from ..wrappers.configparserw import ConfigParserWrapper
4
- from .. import filesystem
5
- from ..permissions import is_admin
6
- from ..basics.booleans import check_3_booleans_when_only_1_can_be_true
3
+ from ..print_api import print_api
4
+ from .. import config_init, permissions, filesystem, dns
5
+ from ..wrappers.socketw import base
6
+ from ..basics import booleans
7
7
 
8
+ from . import config_static
8
9
 
9
- class ImportConfig:
10
+
11
+ def assign_bool(dict_instance: dict, section: str, key: str):
12
+ # If the value is already boolean, don't do anything.
13
+ if dict_instance[section][key] is True or dict_instance[section][key] is False:
14
+ return
15
+ elif dict_instance[section][key] == 1:
16
+ dict_instance[section][key] = True
17
+ elif dict_instance[section][key] == 0:
18
+ dict_instance[section][key] = False
19
+ else:
20
+ print_api(f"Error: {section}.{key} must be 0 or 1.", color='red')
21
+ return 1
22
+
23
+
24
+ def import_config_file(
25
+ config_file_path: str
26
+ ):
27
+ """
28
+ Import the configuration file 'config.toml' and write all the values to 'config_static' dataclasses module.
29
+ :param config_file_path:
30
+ :return:
31
+ """
32
+
33
+ config_toml: dict = config_init.get_config(
34
+ script_directory=str(Path(config_file_path).parent), config_file_name=Path(config_file_path).name)
35
+
36
+ # Assign boolean values to the toml dict module.
37
+ for boolean_tuple in config_static.LIST_OF_BOOLEANS:
38
+ assign_bool(config_toml, boolean_tuple[0], boolean_tuple[1])
39
+
40
+ # Assign the configuration file content to the 'config_static' dataclasses module.
41
+ for category, category_settings in config_toml.items():
42
+ for setting_name, value in category_settings.items():
43
+ # Get the dynamic class or dataclass from the 'config_static' module.
44
+ dynamic_class = getattr(config_static, config_static.TOML_TO_STATIC_CATEGORIES[category])
45
+ # Set the value to the dynamic class setting.
46
+ setattr(dynamic_class, setting_name, value)
47
+
48
+ manipulations_after_import()
49
+
50
+ result = check_configurations()
51
+ return result
52
+
53
+
54
+ def check_configurations() -> int:
10
55
  """
11
- ImportConfig class is responsible for importing 'config.ini' file and its variables.
56
+ Check the configurations from the 'config.toml' file.
57
+ If there are any errors, print them and return 1.
58
+ :return: int, status code.
12
59
  """
13
60
 
14
- def __init__(self, file_name: str, directory_path: str):
15
- self.directory_path: str = directory_path
16
- self.admin_rights = None
17
- self.config_parser = ConfigParserWrapper(file_name=file_name, directory_path=self.directory_path)
18
- self.config: dict = dict()
19
-
20
- def open(self) -> None:
21
- """
22
- Open configuration file
23
-
24
- :return:
25
- """
26
-
27
- # Read file to dictionary.
28
- self.config_parser.read_to_dict()
29
-
30
- # === Convert string values to python objects. ===
31
- # Auto convert to booleans.
32
- self.config_parser.auto_convert_values(integers=False)
33
- # Convert keys.
34
- self.config_parser.convert_string_values(['listening_port', 'cache_timeout_minutes'], 'int')
35
- self.config_parser.convert_string_values(
36
- ['forwarding_dns_service_ipv4_list___only_for_localhost'], 'list')
37
- self.config_parser.convert_string_values(['listening_port_list'], 'list_of_int')
38
- self.config_parser.convert_string_values(
39
- ['logs_path', 'recordings_path', 'custom_server_certificate_path', 'custom_private_key_path',
40
- 'sni_server_certificates_cache_directory',
41
- 'sni_server_certificate_from_server_socket_download_directory'],
42
- 'path_relative_to_full')
43
-
44
- # Move final dict to local config.
45
- self.config = self.config_parser.config
46
-
47
- self.check_configurations()
48
- self.manipulations_after_import()
49
-
50
- def check_configurations(self):
51
- # Check if both DNS and TCP servers are disabled. ==============================================================
52
- if not self.config['dns']['enable_dns_server'] and not self.config['tcp']['enable_tcp_server']:
53
- print("What are you trying to do? You had disabled both DNS and TCP servers in config ini file.\n"
54
- "Exiting...")
55
- sys.exit()
56
-
57
- # Check [tcp_server] boolean configurations. ===================================================================
58
- if not self.config['tcp']['engines_usage'] and self.config['tcp']['server_response_mode']:
59
- print(
60
- "You can't set [server_response_mode = True], while setting\n"
61
- "[engines_usage = False].\n"
62
- "No engine modules will be loaded - so nothing to respond to.\n"
63
- "Exiting..."
64
- )
65
-
66
- # Check [dns] boolean configurations. ==========================================================================
67
- check_3_booleans_when_only_1_can_be_true(
68
- (self.config['dns']['route_to_tcp_server_only_engine_domains'], 'route_to_tcp_server_only_engine_domains'),
69
- (self.config['dns']['route_to_tcp_server_all_domains'], 'route_to_tcp_server_all_domains'),
70
- (self.config['dns']['regular_resolving'], 'regular_resolving')
71
- )
72
-
73
- check_3_booleans_when_only_1_can_be_true(
74
- (self.config['certificates']['default_server_certificate_usage'], 'default_server_certificate_usage'),
75
- (self.config['certificates']['sni_create_server_certificate_for_each_domain'],
76
- 'sni_create_server_certificate_for_each_domain'),
77
- (self.config['certificates']['custom_server_certificate_usage'], 'custom_server_certificate_usage'))
78
-
79
- if not self.config['certificates']['default_server_certificate_usage'] and \
80
- self.config['certificates']['sni_default_server_certificate_addons']:
81
- print(
82
- f"No point setting [default_server_certificate_addons = True]\n"
83
- f"If you're not going to use default certificates [default_server_certificate_usage = False]\n"
84
- f"Exiting...")
85
- sys.exit()
86
-
87
- if self.config['certificates']['sni_get_server_certificate_from_server_socket'] and \
88
- not self.config['certificates']['sni_create_server_certificate_for_each_domain']:
89
- print("[sni_get_server_certificate_from_server_socket] was set to 'True', "
90
- "but no [sni_create_server_certificate_for_each_domain] was specified.\n"
91
- "Exiting...")
92
- sys.exit()
93
-
94
- if self.config['certificates']['custom_server_certificate_usage'] and \
95
- not self.config['certificates']['custom_server_certificate_path']:
96
- print("[custom_server_certificate_usage] was set to 'True', but no [custom_server_certificate_path] "
97
- "was specified.\n"
98
- "Exiting...")
99
- sys.exit()
100
-
101
- # Check admin right if on localhost ============================================================================
102
- # If the 'config.dns['target_tcp_server_ipv4']' IP address is localhost, then we need to check if the script
103
- # is executed with admin rights. There are some processes that 'psutil' can't get their command line if not
104
- # executed with administrative privileges.
105
- # Also, check Admin privileges only if 'config.tcp['get_process_name']' was set to 'True' in 'config.ini' of
106
- # the script.
107
- if self.config['dns']['target_tcp_server_ipv4'] == "127.0.0.1" and self.config['ssh']['get_process_name']:
108
- self.admin_rights = is_admin()
109
-
110
- # If we're not running with admin rights, prompt to the user and make him decide what to do.
111
- # If he wants to continue running with 'psutil' exceptions or close the script and rerun with admin rights.
112
- if not self.admin_rights:
113
- print("=============================================================")
114
- error_on_admin: str = \
115
- "[!!!] You're running the script in LOCALHOST mode without Administrative Privileges.\n" \
116
- "[!!!] 'psutil' needs them to read Command Lines of system Processes.\n" \
117
- "[!!!] Press [ENTER] to CONTINUE running with errors " \
118
- "on Process Command Line harvesting or rerun the script with Administrative Rights..."
119
- print(error_on_admin)
120
- # Stopping execution and waiting for user's [ENTER] key.
121
- input()
122
- print("=============================================================")
123
-
124
- def manipulations_after_import(self):
125
- # If 'custom_certificate_usage' was set to 'True'.
126
- if self.config['certificates']['custom_server_certificate_usage']:
127
- # Check file existence.
128
- if not filesystem.is_file_exists(file_path=self.config['certificates']['custom_server_certificate_path']):
129
- raise FileNotFoundError
130
-
131
- # And if 'custom_private_key_path' field was populated in [advanced] section, we'll check its existence.
132
- if self.config['certificates']['custom_private_key_path']:
133
- # Check private key file existence.
134
- if not filesystem.is_file_exists(file_path=self.config['certificates']['custom_private_key_path']):
135
- raise FileNotFoundError
136
-
137
- skip_extensions: list = list()
138
- if self.config['skip_extensions']['tls_web_client_authentication']:
139
- skip_extensions.append('1.3.6.1.5.5.7.3.2')
140
- if self.config['skip_extensions']['crl_distribution_points']:
141
- skip_extensions.append('2.5.29.31')
142
- if self.config['skip_extensions']['authority_information_access']:
143
- skip_extensions.append('1.3.6.1.5.5.7.1.1')
144
-
145
- self.config['skip_extensions'] = skip_extensions
61
+ is_admin = permissions.is_admin()
62
+
63
+ # Check if both DNS and TCP servers are disabled. ==============================================================
64
+ if not config_static.DNSServer.enable and not config_static.TCPServer.enable:
65
+ print_api("Both DNS and TCP servers in config ini file, nothing to run. Exiting...", color='red')
66
+ return 1
67
+
68
+ # Check [tcp_server] boolean configurations. ===================================================================
69
+ if not config_static.TCPServer.engines_usage and config_static.TCPServer.server_response_mode:
70
+ message = "You can't set [server_response_mode = True], while setting\n" \
71
+ "[engines_usage = False].\n" \
72
+ "No engine modules will be loaded - so nothing to respond to.\n" \
73
+ "Exiting..."
74
+ print_api(message, color='red')
75
+ return 1
76
+
77
+ # Check admin right if on localhost ============================================================================
78
+ # If the 'config.dns['target_tcp_server_ipv4']' IP address is localhost, then we need to check if the script
79
+ # is executed with admin rights. There are some processes that 'psutil' can't get their command line if not
80
+ # executed with administrative privileges.
81
+ # Also, check Admin privileges only if 'config.tcp['get_process_name']' was set to 'True' in 'config.ini' of
82
+ # the script.
83
+ if (config_static.DNSServer.target_tcp_server_ipv4 in base.THIS_DEVICE_IP_LIST and
84
+ config_static.ProcessName.get_process_name):
85
+ # If we're not running with admin rights, prompt to the user and make him decide what to do.
86
+ # If he wants to continue running with 'psutil' exceptions or close the script and rerun with admin rights.
87
+ if not is_admin:
88
+ message: str = \
89
+ ("Need to run the script with administrative rights to get the process name while TCP running "
90
+ "on the same computer.\nExiting...")
91
+ print_api(message, color='red')
92
+ return 1
93
+
94
+ if config_static.DNSServer.set_default_dns_gateway or \
95
+ config_static.DNSServer.set_default_dns_gateway_to_localhost or \
96
+ config_static.DNSServer.set_default_dns_gateway_to_default_interface_ipv4:
97
+ try:
98
+ booleans.check_3_booleans_when_only_1_can_be_true(
99
+ (config_static.DNSServer.set_default_dns_gateway, '[dns][set_default_dns_gateway]'),
100
+ (config_static.DNSServer.set_default_dns_gateway_to_localhost,
101
+ '[dns][set_default_dns_gateway_to_localhost]'),
102
+ (config_static.DNSServer.set_default_dns_gateway_to_default_interface_ipv4,
103
+ '[dns][set_default_dns_gateway_to_default_interface_ipv4]'))
104
+ except ValueError as e:
105
+ print_api(str(e), color='red')
106
+ return 1
107
+
108
+ if (config_static.DNSServer.set_default_dns_gateway or
109
+ config_static.DNSServer.set_default_dns_gateway_to_localhost or
110
+ config_static.DNSServer.set_default_dns_gateway_to_default_interface_ipv4):
111
+ is_dns_dynamic, current_dns_gateway = dns.get_default_dns_gateway()
112
+ if is_dns_dynamic and not is_admin:
113
+ message: str = \
114
+ "Need to run the script with administrative rights to set the default DNS gateway.\nExiting..."
115
+ print_api(message, color='red')
116
+ return 1
117
+
118
+ return 0
119
+
120
+
121
+ def manipulations_after_import():
122
+ # Convert extensions to skip to a list of extension IDs.
123
+ skip_extensions: list = list()
124
+ if config_static.SkipExtensions.tls_web_client_authentication:
125
+ skip_extensions.append('1.3.6.1.5.5.7.3.2')
126
+ if config_static.SkipExtensions.crl_distribution_points:
127
+ skip_extensions.append('2.5.29.31')
128
+ if config_static.SkipExtensions.authority_information_access:
129
+ skip_extensions.append('1.3.6.1.5.5.7.1.1')
130
+ config_static.SkipExtensions.SKIP_EXTENSION_ID_LIST = skip_extensions
131
+
132
+ # If the paths are relative, convert them to absolute paths.
133
+ config_static.Log.logs_path = filesystem.check_absolute_path___add_full(
134
+ config_static.Log.logs_path, config_static.MainConfig.SCRIPT_DIRECTORY)
135
+ config_static.Recorder.recordings_path = filesystem.check_absolute_path___add_full(
136
+ config_static.Recorder.recordings_path, config_static.MainConfig.SCRIPT_DIRECTORY)
137
+ config_static.Certificates.custom_server_certificate_path = filesystem.check_absolute_path___add_full(
138
+ config_static.Certificates.custom_server_certificate_path, config_static.MainConfig.SCRIPT_DIRECTORY)
139
+
140
+ # At this point the user that sets the config can set it to null or empty string ''. We will make sure
141
+ # that the path is None if it's empty.
142
+ if config_static.Certificates.custom_private_key_path:
143
+ config_static.Certificates.custom_private_key_path = filesystem.check_absolute_path___add_full(
144
+ config_static.Certificates.custom_private_key_path, config_static.MainConfig.SCRIPT_DIRECTORY)
145
+ else:
146
+ config_static.Certificates.custom_private_key_path = None
147
+
148
+ config_static.Certificates.sni_server_certificates_cache_directory = filesystem.check_absolute_path___add_full(
149
+ config_static.Certificates.sni_server_certificates_cache_directory, config_static.MainConfig.SCRIPT_DIRECTORY)
150
+ config_static.Certificates.sni_server_certificate_from_server_socket_download_directory = \
151
+ filesystem.check_absolute_path___add_full(
152
+ config_static.Certificates.sni_server_certificate_from_server_socket_download_directory,
153
+ config_static.MainConfig.SCRIPT_DIRECTORY)
@@ -96,7 +96,12 @@ class ModuleCategory:
96
96
  # Assigning external class object by message domain received from client. If the domain is not in the list,
97
97
  # the reference general module will be assigned.
98
98
  def assign_class_by_domain(
99
- engines_list: list, message_domain_name: str, reference_module, config, logger=None):
99
+ engines_usage: bool,
100
+ engines_list: list,
101
+ message_domain_name: str,
102
+ reference_module,
103
+ logger=None
104
+ ):
100
105
  # Defining return variables:
101
106
  function_parser = None
102
107
  function_responder = None
@@ -106,7 +111,7 @@ def assign_class_by_domain(
106
111
  if message_domain_name:
107
112
  # If the engines_usage is set to True in the config file, then we'll iterate through the list of engines
108
113
  # to find the domain in the list of domains of the engine.
109
- if config['tcp']['engines_usage']:
114
+ if engines_usage:
110
115
  # Checking if current domain is in engines' domain list to activate domain specific engine
111
116
  for function_module in engines_list:
112
117
  # The list: matches_list = ["domain1.com", "domain2.com", "domain3.com"]