atomicshop 2.11.47__py3-none-any.whl → 3.10.5__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.
- atomicshop/__init__.py +1 -1
- atomicshop/{addons/mains → a_mains}/FACT/update_extract.py +3 -2
- atomicshop/a_mains/addons/process_list/compile.cmd +7 -0
- atomicshop/a_mains/addons/process_list/compiled/Win10x64/process_list.dll +0 -0
- atomicshop/a_mains/addons/process_list/compiled/Win10x64/process_list.exp +0 -0
- atomicshop/a_mains/addons/process_list/compiled/Win10x64/process_list.lib +0 -0
- atomicshop/{addons → a_mains/addons}/process_list/process_list.cpp +8 -1
- atomicshop/a_mains/dns_gateway_setting.py +11 -0
- atomicshop/a_mains/get_local_tcp_ports.py +85 -0
- atomicshop/a_mains/github_wrapper.py +11 -0
- atomicshop/a_mains/install_ca_certificate.py +172 -0
- atomicshop/{addons/mains → a_mains}/msi_unpacker.py +3 -1
- atomicshop/a_mains/process_from_port.py +119 -0
- atomicshop/a_mains/set_default_dns_gateway.py +90 -0
- atomicshop/a_mains/update_config_toml.py +38 -0
- atomicshop/appointment_management.py +5 -3
- atomicshop/basics/ansi_escape_codes.py +3 -1
- atomicshop/basics/argparse_template.py +2 -0
- atomicshop/basics/booleans.py +27 -30
- atomicshop/basics/bytes_arrays.py +43 -0
- atomicshop/basics/classes.py +149 -1
- atomicshop/basics/dicts.py +12 -0
- atomicshop/basics/enums.py +2 -2
- atomicshop/basics/exceptions.py +5 -1
- atomicshop/basics/list_of_classes.py +29 -0
- atomicshop/basics/list_of_dicts.py +69 -5
- atomicshop/basics/lists.py +14 -0
- atomicshop/basics/multiprocesses.py +374 -50
- atomicshop/basics/package_module.py +10 -0
- atomicshop/basics/strings.py +160 -7
- atomicshop/basics/threads.py +14 -0
- atomicshop/basics/tracebacks.py +13 -4
- atomicshop/certificates.py +153 -52
- atomicshop/config_init.py +12 -7
- atomicshop/console_user_response.py +7 -14
- atomicshop/consoles.py +9 -0
- atomicshop/datetimes.py +98 -0
- atomicshop/diff_check.py +340 -40
- atomicshop/dns.py +128 -12
- atomicshop/etws/_pywintrace_fix.py +17 -0
- atomicshop/etws/const.py +38 -0
- atomicshop/etws/providers.py +21 -0
- atomicshop/etws/sessions.py +43 -0
- atomicshop/etws/trace.py +168 -0
- atomicshop/etws/traces/trace_dns.py +162 -0
- atomicshop/etws/traces/trace_sysmon_process_creation.py +126 -0
- atomicshop/etws/traces/trace_tcp.py +130 -0
- atomicshop/file_io/csvs.py +222 -24
- atomicshop/file_io/docxs.py +35 -18
- atomicshop/file_io/file_io.py +35 -19
- atomicshop/file_io/jsons.py +49 -0
- atomicshop/file_io/tomls.py +139 -0
- atomicshop/filesystem.py +864 -293
- atomicshop/get_process_list.py +133 -0
- atomicshop/{process_name_cmd.py → get_process_name_cmd_dll.py} +52 -19
- atomicshop/http_parse.py +149 -93
- atomicshop/ip_addresses.py +6 -1
- atomicshop/mitm/centered_settings.py +132 -0
- atomicshop/mitm/config_static.py +207 -0
- atomicshop/mitm/config_toml_editor.py +55 -0
- atomicshop/mitm/connection_thread_worker.py +875 -357
- atomicshop/mitm/engines/__parent/parser___parent.py +4 -17
- atomicshop/mitm/engines/__parent/recorder___parent.py +108 -51
- atomicshop/mitm/engines/__parent/requester___parent.py +116 -0
- atomicshop/mitm/engines/__parent/responder___parent.py +75 -114
- atomicshop/mitm/engines/__reference_general/parser___reference_general.py +10 -7
- atomicshop/mitm/engines/__reference_general/recorder___reference_general.py +5 -5
- atomicshop/mitm/engines/__reference_general/requester___reference_general.py +47 -0
- atomicshop/mitm/engines/__reference_general/responder___reference_general.py +95 -13
- atomicshop/mitm/engines/create_module_template.py +58 -14
- atomicshop/mitm/import_config.py +359 -139
- atomicshop/mitm/initialize_engines.py +160 -74
- atomicshop/mitm/message.py +64 -23
- atomicshop/mitm/mitm_main.py +892 -0
- atomicshop/mitm/recs_files.py +183 -0
- atomicshop/mitm/shared_functions.py +4 -10
- atomicshop/mitm/ssh_tester.py +82 -0
- atomicshop/mitm/statistic_analyzer.py +257 -166
- atomicshop/mitm/statistic_analyzer_helper/analyzer_helper.py +136 -0
- atomicshop/mitm/statistic_analyzer_helper/moving_average_helper.py +525 -0
- atomicshop/monitor/change_monitor.py +96 -120
- atomicshop/monitor/checks/dns.py +139 -70
- atomicshop/monitor/checks/file.py +77 -0
- atomicshop/monitor/checks/network.py +81 -77
- atomicshop/monitor/checks/process_running.py +33 -34
- atomicshop/monitor/checks/url.py +94 -0
- atomicshop/networks.py +671 -0
- atomicshop/on_exit.py +205 -0
- atomicshop/package_mains_processor.py +84 -0
- atomicshop/permissions/permissions.py +22 -0
- atomicshop/permissions/ubuntu_permissions.py +239 -0
- atomicshop/permissions/win_permissions.py +33 -0
- atomicshop/print_api.py +24 -41
- atomicshop/process.py +63 -17
- atomicshop/process_poller/__init__.py +0 -0
- atomicshop/process_poller/pollers/__init__.py +0 -0
- atomicshop/process_poller/pollers/psutil_pywin32wmi_dll.py +95 -0
- atomicshop/process_poller/process_pool.py +207 -0
- atomicshop/process_poller/simple_process_pool.py +311 -0
- atomicshop/process_poller/tracer_base.py +45 -0
- atomicshop/process_poller/tracers/__init__.py +0 -0
- atomicshop/process_poller/tracers/event_log.py +46 -0
- atomicshop/process_poller/tracers/sysmon_etw.py +68 -0
- atomicshop/python_file_patcher.py +1 -1
- atomicshop/python_functions.py +27 -75
- atomicshop/question_answer_engine.py +2 -2
- atomicshop/scheduling.py +24 -5
- atomicshop/sound.py +4 -2
- atomicshop/speech_recognize.py +8 -0
- atomicshop/ssh_remote.py +158 -172
- atomicshop/startup/__init__.py +0 -0
- atomicshop/startup/win/__init__.py +0 -0
- atomicshop/startup/win/startup_folder.py +53 -0
- atomicshop/startup/win/task_scheduler.py +119 -0
- atomicshop/system_resource_monitor.py +61 -46
- atomicshop/system_resources.py +8 -8
- atomicshop/tempfiles.py +1 -2
- atomicshop/timer.py +30 -11
- atomicshop/urls.py +41 -0
- atomicshop/venvs.py +28 -0
- atomicshop/versioning.py +27 -0
- atomicshop/web.py +110 -25
- atomicshop/web_apis/__init__.py +0 -0
- atomicshop/web_apis/google_custom_search.py +44 -0
- atomicshop/web_apis/google_llm.py +188 -0
- atomicshop/websocket_parse.py +450 -0
- atomicshop/wrappers/certauthw/certauth.py +1 -0
- atomicshop/wrappers/cryptographyw.py +29 -8
- atomicshop/wrappers/ctyping/etw_winapi/__init__.py +0 -0
- atomicshop/wrappers/ctyping/etw_winapi/const.py +335 -0
- atomicshop/wrappers/ctyping/etw_winapi/etw_functions.py +393 -0
- atomicshop/wrappers/ctyping/file_details_winapi.py +67 -0
- atomicshop/wrappers/ctyping/msi_windows_installer/cabs.py +2 -1
- atomicshop/wrappers/ctyping/msi_windows_installer/extract_msi_main.py +13 -9
- atomicshop/wrappers/ctyping/msi_windows_installer/tables.py +35 -0
- atomicshop/wrappers/ctyping/setup_device.py +466 -0
- atomicshop/wrappers/ctyping/win_console.py +39 -0
- atomicshop/wrappers/dockerw/dockerw.py +113 -2
- atomicshop/wrappers/elasticsearchw/config_basic.py +0 -12
- atomicshop/wrappers/elasticsearchw/elastic_infra.py +75 -0
- atomicshop/wrappers/elasticsearchw/elasticsearchw.py +2 -20
- atomicshop/wrappers/factw/get_file_data.py +12 -5
- atomicshop/wrappers/factw/install/install_after_restart.py +89 -5
- atomicshop/wrappers/factw/install/pre_install_and_install_before_restart.py +20 -14
- atomicshop/wrappers/factw/postgresql/firmware.py +4 -6
- atomicshop/wrappers/githubw.py +583 -51
- atomicshop/wrappers/loggingw/consts.py +49 -0
- atomicshop/wrappers/loggingw/filters.py +102 -0
- atomicshop/wrappers/loggingw/formatters.py +58 -71
- atomicshop/wrappers/loggingw/handlers.py +459 -40
- atomicshop/wrappers/loggingw/loggers.py +19 -0
- atomicshop/wrappers/loggingw/loggingw.py +1010 -178
- atomicshop/wrappers/loggingw/reading.py +344 -19
- atomicshop/wrappers/mongodbw/__init__.py +0 -0
- atomicshop/wrappers/mongodbw/mongo_infra.py +31 -0
- atomicshop/wrappers/mongodbw/mongodbw.py +1432 -0
- atomicshop/wrappers/netshw.py +271 -0
- atomicshop/wrappers/playwrightw/engine.py +34 -19
- atomicshop/wrappers/playwrightw/infra.py +5 -0
- atomicshop/wrappers/playwrightw/javascript.py +7 -3
- atomicshop/wrappers/playwrightw/keyboard.py +14 -0
- atomicshop/wrappers/playwrightw/scenarios.py +172 -5
- atomicshop/wrappers/playwrightw/waits.py +9 -7
- atomicshop/wrappers/powershell_networking.py +80 -0
- atomicshop/wrappers/psutilw/processes.py +81 -0
- atomicshop/wrappers/psutilw/psutil_networks.py +85 -0
- atomicshop/wrappers/psutilw/psutilw.py +9 -0
- atomicshop/wrappers/pyopensslw.py +9 -2
- atomicshop/wrappers/pywin32w/__init__.py +0 -0
- atomicshop/wrappers/pywin32w/cert_store.py +116 -0
- atomicshop/wrappers/pywin32w/console.py +34 -0
- atomicshop/wrappers/pywin32w/win_event_log/__init__.py +0 -0
- atomicshop/wrappers/pywin32w/win_event_log/fetch.py +174 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribe.py +212 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/__init__.py +0 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_create.py +57 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_terminate.py +49 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/schannel_logging.py +97 -0
- atomicshop/wrappers/pywin32w/winshell.py +19 -0
- atomicshop/wrappers/pywin32w/wmis/__init__.py +0 -0
- atomicshop/wrappers/pywin32w/wmis/msft_netipaddress.py +113 -0
- atomicshop/wrappers/pywin32w/wmis/win32_networkadapterconfiguration.py +259 -0
- atomicshop/wrappers/pywin32w/wmis/win32networkadapter.py +112 -0
- atomicshop/wrappers/pywin32w/wmis/wmi_helpers.py +236 -0
- atomicshop/wrappers/socketw/accepter.py +21 -7
- atomicshop/wrappers/socketw/certificator.py +216 -150
- atomicshop/wrappers/socketw/creator.py +190 -50
- atomicshop/wrappers/socketw/dns_server.py +500 -173
- atomicshop/wrappers/socketw/exception_wrapper.py +45 -52
- atomicshop/wrappers/socketw/process_getter.py +86 -0
- atomicshop/wrappers/socketw/receiver.py +144 -102
- atomicshop/wrappers/socketw/sender.py +65 -35
- atomicshop/wrappers/socketw/sni.py +334 -165
- atomicshop/wrappers/socketw/socket_base.py +134 -0
- atomicshop/wrappers/socketw/socket_client.py +137 -95
- atomicshop/wrappers/socketw/socket_server_tester.py +14 -9
- atomicshop/wrappers/socketw/socket_wrapper.py +717 -116
- atomicshop/wrappers/socketw/ssl_base.py +15 -14
- atomicshop/wrappers/socketw/statistics_csv.py +148 -17
- atomicshop/wrappers/sysmonw.py +157 -0
- atomicshop/wrappers/ubuntu_terminal.py +65 -26
- atomicshop/wrappers/win_auditw.py +189 -0
- atomicshop/wrappers/winregw/__init__.py +0 -0
- atomicshop/wrappers/winregw/winreg_installed_software.py +58 -0
- atomicshop/wrappers/winregw/winreg_network.py +232 -0
- {atomicshop-2.11.47.dist-info → atomicshop-3.10.5.dist-info}/METADATA +31 -49
- atomicshop-3.10.5.dist-info/RECORD +306 -0
- {atomicshop-2.11.47.dist-info → atomicshop-3.10.5.dist-info}/WHEEL +1 -1
- atomicshop/_basics_temp.py +0 -101
- atomicshop/addons/a_setup_scripts/install_psycopg2_ubuntu.sh +0 -3
- atomicshop/addons/a_setup_scripts/install_pywintrace_0.3.cmd +0 -2
- atomicshop/addons/mains/install_docker_rootless_ubuntu.py +0 -11
- atomicshop/addons/mains/install_docker_ubuntu_main_sudo.py +0 -11
- atomicshop/addons/mains/install_elastic_search_and_kibana_ubuntu.py +0 -10
- atomicshop/addons/mains/install_wsl_ubuntu_lts_admin.py +0 -9
- atomicshop/addons/package_setup/CreateWheel.cmd +0 -7
- atomicshop/addons/package_setup/Setup in Edit mode.cmd +0 -6
- atomicshop/addons/package_setup/Setup.cmd +0 -7
- atomicshop/addons/process_list/compile.cmd +0 -2
- atomicshop/addons/process_list/compiled/Win10x64/process_list.dll +0 -0
- atomicshop/addons/process_list/compiled/Win10x64/process_list.exp +0 -0
- atomicshop/addons/process_list/compiled/Win10x64/process_list.lib +0 -0
- atomicshop/archiver/_search_in_zip.py +0 -189
- atomicshop/archiver/archiver.py +0 -34
- atomicshop/archiver/search_in_archive.py +0 -250
- atomicshop/archiver/sevenz_app_w.py +0 -86
- atomicshop/archiver/sevenzs.py +0 -44
- atomicshop/archiver/zips.py +0 -293
- atomicshop/etw/dns_trace.py +0 -118
- atomicshop/etw/etw.py +0 -61
- atomicshop/file_types.py +0 -24
- atomicshop/mitm/engines/create_module_template_example.py +0 -13
- atomicshop/mitm/initialize_mitm_server.py +0 -240
- atomicshop/monitor/checks/hash.py +0 -44
- atomicshop/monitor/checks/hash_checks/file.py +0 -55
- atomicshop/monitor/checks/hash_checks/url.py +0 -62
- atomicshop/pbtkmultifile_argparse.py +0 -88
- atomicshop/permissions.py +0 -110
- atomicshop/process_poller.py +0 -237
- atomicshop/script_as_string_processor.py +0 -38
- atomicshop/ssh_scripts/process_from_ipv4.py +0 -37
- atomicshop/ssh_scripts/process_from_port.py +0 -27
- atomicshop/wrappers/_process_wrapper_curl.py +0 -27
- atomicshop/wrappers/_process_wrapper_tar.py +0 -21
- atomicshop/wrappers/dockerw/install_docker.py +0 -209
- atomicshop/wrappers/elasticsearchw/infrastructure.py +0 -265
- atomicshop/wrappers/elasticsearchw/install_elastic.py +0 -232
- atomicshop/wrappers/ffmpegw.py +0 -125
- atomicshop/wrappers/loggingw/checks.py +0 -20
- atomicshop/wrappers/nodejsw/install_nodejs.py +0 -139
- atomicshop/wrappers/process_wrapper_pbtk.py +0 -16
- atomicshop/wrappers/socketw/base.py +0 -59
- atomicshop/wrappers/socketw/get_process.py +0 -107
- atomicshop/wrappers/wslw.py +0 -191
- atomicshop-2.11.47.dist-info/RECORD +0 -251
- /atomicshop/{addons/mains → a_mains}/FACT/factw_fact_extractor_docker_image_main_sudo.py +0 -0
- /atomicshop/{addons → a_mains/addons}/PlayWrightCodegen.cmd +0 -0
- /atomicshop/{addons → a_mains/addons}/ScriptExecution.cmd +0 -0
- /atomicshop/{addons/mains → a_mains/addons}/inits/init_to_import_all_modules.py +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/ReadMe.txt +0 -0
- /atomicshop/{addons/mains → a_mains}/search_for_hyperlinks_in_docx.py +0 -0
- /atomicshop/{archiver → etws}/__init__.py +0 -0
- /atomicshop/{etw → etws/traces}/__init__.py +0 -0
- /atomicshop/{monitor/checks/hash_checks → mitm/statistic_analyzer_helper}/__init__.py +0 -0
- /atomicshop/{wrappers/nodejsw → permissions}/__init__.py +0 -0
- /atomicshop/wrappers/pywin32w/{wmi_win32process.py → wmis/win32process.py} +0 -0
- {atomicshop-2.11.47.dist-info → atomicshop-3.10.5.dist-info/licenses}/LICENSE.txt +0 -0
- {atomicshop-2.11.47.dist-info → atomicshop-3.10.5.dist-info}/top_level.txt +0 -0
atomicshop/mitm/import_config.py
CHANGED
|
@@ -1,145 +1,365 @@
|
|
|
1
|
-
import
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import socket
|
|
2
4
|
|
|
3
|
-
from ..
|
|
4
|
-
from ..
|
|
5
|
-
from ..permissions import
|
|
6
|
-
from ..
|
|
5
|
+
from ..print_api import print_api
|
|
6
|
+
from .. import config_init, filesystem, dns
|
|
7
|
+
from ..permissions import permissions
|
|
8
|
+
from ..wrappers.socketw import socket_base
|
|
9
|
+
from ..basics import booleans
|
|
7
10
|
|
|
11
|
+
from . import config_static, initialize_engines
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
|
|
14
|
+
def import_config_files(
|
|
15
|
+
config_file_path: str,
|
|
16
|
+
print_kwargs: dict = None
|
|
17
|
+
):
|
|
10
18
|
"""
|
|
11
|
-
|
|
19
|
+
Import the configuration file 'config.toml' and write all the values to 'config_static' dataclasses module.
|
|
20
|
+
|
|
21
|
+
:param config_file_path:
|
|
22
|
+
:param print_kwargs: dict, additional arguments to pass to the print function.
|
|
23
|
+
:return:
|
|
12
24
|
"""
|
|
13
25
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
#
|
|
102
|
-
|
|
103
|
-
#
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
26
|
+
config_toml: dict = config_init.get_config(
|
|
27
|
+
script_directory=str(Path(config_file_path).parent),
|
|
28
|
+
config_file_name=Path(config_file_path).name,
|
|
29
|
+
print_kwargs=print_kwargs or {}
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
config_static.MainConfig.is_offline = bool(config_toml['dnstcp']['offline'])
|
|
34
|
+
config_static.MainConfig.network_interface = config_toml['dnstcp']['network_interface']
|
|
35
|
+
config_static.MainConfig.is_localhost = bool(config_toml['dnstcp']['localhost'])
|
|
36
|
+
config_static.MainConfig.set_default_dns_gateway = config_toml['dnstcp']['set_default_dns_gateway']
|
|
37
|
+
|
|
38
|
+
config_static.DNSServer.is_enabled = bool(config_toml['dns']['enable'])
|
|
39
|
+
config_static.DNSServer.listening_ipv4 = config_toml['dns']['listening_ipv4']
|
|
40
|
+
config_static.DNSServer.listening_port = config_toml['dns']['listening_port']
|
|
41
|
+
config_static.DNSServer.forwarding_dns_service_ipv4 = config_toml['dns']['forwarding_dns_service_ipv4']
|
|
42
|
+
config_static.DNSServer.cache_timeout_minutes = config_toml['dns']['cache_timeout_minutes']
|
|
43
|
+
config_static.DNSServer.resolve_by_engine = bool(config_toml['dns']['resolve_by_engine'])
|
|
44
|
+
config_static.DNSServer.resolve_regular_pass_thru = bool(config_toml['dns']['resolve_regular_pass_thru'])
|
|
45
|
+
config_static.DNSServer.resolve_all_domains_to_ipv4 = config_toml['dns']['resolve_all_domains_to_ipv4']
|
|
46
|
+
|
|
47
|
+
config_static.TCPServer.is_enabled = bool(config_toml['tcp']['enable'])
|
|
48
|
+
config_static.TCPServer.no_engines_usage_to_listen_addresses = config_toml['tcp']['no_engines_usage_to_listen_addresses']
|
|
49
|
+
|
|
50
|
+
config_static.LogRec.logs_path = config_toml['logrec']['logs_path']
|
|
51
|
+
config_static.LogRec.enable_request_response_recordings_in_logs = bool(config_toml['logrec']['enable_request_response_recordings_in_logs'])
|
|
52
|
+
config_static.LogRec.store_logs_for_x_days = config_toml['logrec']['store_logs_for_x_days']
|
|
53
|
+
|
|
54
|
+
config_static.Certificates.install_ca_certificate_to_root_store = bool(config_toml['certificates']['install_ca_certificate_to_root_store'])
|
|
55
|
+
config_static.Certificates.uninstall_unused_ca_certificates_with_mitm_ca_name = bool(config_toml['certificates']['uninstall_unused_ca_certificates_with_mitm_ca_name'])
|
|
56
|
+
config_static.Certificates.default_server_certificate_usage = bool(config_toml['certificates']['default_server_certificate_usage'])
|
|
57
|
+
config_static.Certificates.sni_add_new_domains_to_default_server_certificate = bool(config_toml['certificates']['sni_add_new_domains_to_default_server_certificate'])
|
|
58
|
+
config_static.Certificates.custom_server_certificate_usage = bool(config_toml['certificates']['custom_server_certificate_usage'])
|
|
59
|
+
config_static.Certificates.custom_server_certificate_path = config_toml['certificates']['custom_server_certificate_path']
|
|
60
|
+
config_static.Certificates.custom_private_key_path = config_toml['certificates']['custom_private_key_path']
|
|
61
|
+
config_static.Certificates.sni_create_server_certificate_for_each_domain = bool(config_toml['certificates']['sni_create_server_certificate_for_each_domain'])
|
|
62
|
+
config_static.Certificates.sni_server_certificates_cache_directory = config_toml['certificates']['sni_server_certificates_cache_directory']
|
|
63
|
+
config_static.Certificates.sni_get_server_certificate_from_server_socket = bool(config_toml['certificates']['sni_get_server_certificate_from_server_socket'])
|
|
64
|
+
config_static.Certificates.sni_server_certificate_from_server_socket_download_directory = config_toml['certificates']['sni_server_certificate_from_server_socket_download_directory']
|
|
65
|
+
|
|
66
|
+
config_static.SkipExtensions.tls_web_client_authentication = bool(config_toml['skip_extensions']['tls_web_client_authentication'])
|
|
67
|
+
config_static.SkipExtensions.crl_distribution_points = bool(config_toml['skip_extensions']['crl_distribution_points'])
|
|
68
|
+
config_static.SkipExtensions.authority_information_access = bool(config_toml['skip_extensions']['authority_information_access'])
|
|
69
|
+
|
|
70
|
+
config_static.ProcessName.get_process_name = bool(config_toml['process_name']['get_process_name'])
|
|
71
|
+
config_static.ProcessName.ssh_user = config_toml['process_name']['ssh_user']
|
|
72
|
+
config_static.ProcessName.ssh_pass = config_toml['process_name']['ssh_pass']
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
manipulations_after_import()
|
|
76
|
+
|
|
77
|
+
result = import_engines_configs(print_kwargs=print_kwargs or {})
|
|
78
|
+
if result != 0:
|
|
79
|
+
return result
|
|
80
|
+
|
|
81
|
+
result = check_configurations()
|
|
82
|
+
return result
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def import_engines_configs(print_kwargs: dict) -> int:
|
|
86
|
+
"""
|
|
87
|
+
Import the engines configuration files and write all the values to 'config_static' dataclasses module.
|
|
88
|
+
|
|
89
|
+
:return: int, status code.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
# Get full paths of all the 'engine_config.ini' files.
|
|
93
|
+
engine_config_path_list = filesystem.get_paths_from_directory(
|
|
94
|
+
directory_path=config_static.MainConfig.ENGINES_DIRECTORY_PATH,
|
|
95
|
+
get_file=True,
|
|
96
|
+
file_name_check_pattern=config_static.MainConfig.ENGINE_CONFIG_FILE_NAME)
|
|
97
|
+
|
|
98
|
+
# Iterate through all the 'engine_config.ini' file paths.
|
|
99
|
+
domains_engine_list_full: list = list()
|
|
100
|
+
engines_list: list = list()
|
|
101
|
+
for engine_config_path in engine_config_path_list:
|
|
102
|
+
# Initialize engine.
|
|
103
|
+
current_module: initialize_engines.ModuleCategory = initialize_engines.ModuleCategory(config_static.MainConfig.SCRIPT_DIRECTORY)
|
|
104
|
+
rc, error = current_module.fill_engine_fields_from_config(engine_config_path.path, print_kwargs=print_kwargs or {})
|
|
105
|
+
if rc != 0:
|
|
106
|
+
print_api(f"Error reading engine config file: {engine_config_path.path}\n{error}", color='red')
|
|
107
|
+
return rc
|
|
108
|
+
rc, error = current_module.initialize_engine(print_kwargs=print_kwargs or {})
|
|
109
|
+
if rc != 0:
|
|
110
|
+
print_api(f"Error initializing engine from directory: {Path(engine_config_path.path).parent}\n{error}", color='red')
|
|
111
|
+
return rc
|
|
112
|
+
|
|
113
|
+
# Extending the full engine domain list with this list.
|
|
114
|
+
domains_engine_list_full.extend(current_module.domain_list)
|
|
115
|
+
# Append the object to the engines list
|
|
116
|
+
engines_list.append(current_module)
|
|
117
|
+
# === EOF Importing engine modules =============================================================================
|
|
118
|
+
# ==== Initialize Reference Module =============================================================================
|
|
119
|
+
reference_module: initialize_engines.ModuleCategory = initialize_engines.ModuleCategory(config_static.MainConfig.SCRIPT_DIRECTORY)
|
|
120
|
+
reference_module.fill_engine_fields_from_general_reference(config_static.MainConfig.ENGINES_DIRECTORY_PATH)
|
|
121
|
+
result_code, error = reference_module.initialize_engine(reference_general=True)
|
|
122
|
+
if result_code != 0:
|
|
123
|
+
print_api(f"Error initializing reference engine from file: {config_static.MainConfig.ENGINES_DIRECTORY_PATH}\n{error}", color='red')
|
|
124
|
+
return result_code
|
|
125
|
+
|
|
126
|
+
# Assigning all the engines domains to all time domains, that will be responsible for adding new domains.
|
|
127
|
+
domains_all_times_with_ports: list[str] = list(domains_engine_list_full)
|
|
128
|
+
|
|
129
|
+
domains_all_times: list[str] = list()
|
|
130
|
+
for domain_and_port in domains_all_times_with_ports:
|
|
131
|
+
domain: str = domain_and_port.split(':')[0]
|
|
132
|
+
if domain not in domains_engine_list_full:
|
|
133
|
+
domains_all_times.append(domain)
|
|
134
|
+
|
|
135
|
+
config_static.Certificates.domains_all_times = domains_all_times
|
|
136
|
+
|
|
137
|
+
config_static.ENGINES_LIST = engines_list
|
|
138
|
+
config_static.REFERENCE_MODULE = reference_module
|
|
139
|
+
|
|
140
|
+
return 0
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def check_configurations() -> int:
|
|
144
|
+
"""
|
|
145
|
+
Check the configurations from the 'config.toml' file.
|
|
146
|
+
If there are any errors, print them and return 1.
|
|
147
|
+
:return: int, status code.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
is_admin = permissions.is_admin()
|
|
151
|
+
|
|
152
|
+
# Check if both DNS and TCP servers are disabled. ==============================================================
|
|
153
|
+
if not config_static.DNSServer.is_enabled and not config_static.TCPServer.is_enabled:
|
|
154
|
+
print_api("Both DNS and TCP servers in config ini file, nothing to run. Exiting...", color='red')
|
|
155
|
+
return 1
|
|
156
|
+
|
|
157
|
+
# Checking if listening interfaces were set.
|
|
158
|
+
if not config_static.TCPServer.no_engines_usage_to_listen_addresses_enable:
|
|
159
|
+
# If no engines were found, check if listening interfaces were set in the main config.
|
|
160
|
+
if not config_static.ENGINES_LIST:
|
|
161
|
+
message = (
|
|
162
|
+
"\n"
|
|
163
|
+
"No engines found. Create with [create_template.py].\n"
|
|
164
|
+
"Exiting...")
|
|
165
|
+
print_api(message, color="red")
|
|
166
|
+
return 1
|
|
167
|
+
else:
|
|
168
|
+
if not config_static.TCPServer.no_engines_listening_address_list:
|
|
169
|
+
message = (
|
|
170
|
+
"\n"
|
|
171
|
+
"No listening interfaces. Set [no_engines_usage_to_listen_addresses] in the main [config.toml].\n"
|
|
172
|
+
"Exiting...")
|
|
173
|
+
print_api(message, color="red")
|
|
174
|
+
return 1
|
|
175
|
+
|
|
176
|
+
if not config_static.ENGINES_LIST and config_static.DNSServer.resolve_by_engine:
|
|
177
|
+
error_message = (
|
|
178
|
+
f"No engines were found in: [{config_static.MainConfig.ENGINES_DIRECTORY_PATH}]\n"
|
|
179
|
+
f"But the DNS routing is set to use them for routing.\n"
|
|
180
|
+
f"Please check your DNS routing configuration in the [config.toml] file or create an engine with [create_template.py].")
|
|
181
|
+
print_api(error_message, color="red")
|
|
182
|
+
return 1
|
|
183
|
+
|
|
184
|
+
for engine in config_static.ENGINES_LIST:
|
|
185
|
+
port_list: list[str] = []
|
|
186
|
+
for domain_port in engine.domain_list:
|
|
187
|
+
# Check if the domains has port.
|
|
188
|
+
if ':' not in domain_port:
|
|
189
|
+
message = (
|
|
190
|
+
f"[*] Domain [{domain_port}] doesn't have a port.\n"
|
|
191
|
+
f"Please check your engine configuration file.")
|
|
192
|
+
print_api(message, color="red")
|
|
193
|
+
return 1
|
|
194
|
+
else:
|
|
195
|
+
# Split the domain and port.
|
|
196
|
+
domain, port = domain_port.split(':')
|
|
197
|
+
port_list.append(port)
|
|
198
|
+
# Check if the port is a number.
|
|
199
|
+
if not port.isdigit():
|
|
200
|
+
message = (
|
|
201
|
+
f"[*] Port [{port}] is not a number.\n"
|
|
202
|
+
f"Please check your engine configuration file.")
|
|
203
|
+
print_api(message, color="red")
|
|
204
|
+
return 1
|
|
205
|
+
|
|
206
|
+
# Check if the ports in on_port_connect are unique.
|
|
207
|
+
if engine.on_port_connect:
|
|
208
|
+
ports_on_connect: list[str] = list(engine.on_port_connect.keys())
|
|
209
|
+
# Check if any of the ports in the on_port_connect are not in the domain list.
|
|
210
|
+
ports_in_domain_list: list[str] = []
|
|
211
|
+
for port in ports_on_connect:
|
|
212
|
+
if port in port_list:
|
|
213
|
+
ports_in_domain_list.append(port)
|
|
214
|
+
|
|
215
|
+
if ports_in_domain_list:
|
|
216
|
+
message = (
|
|
217
|
+
f"[*] Ports in [on_port_connect] config in engine_config.toml: {ports_in_domain_list}\n"
|
|
218
|
+
f"are also in the [domains] field.\n"
|
|
219
|
+
f"This is not supported.")
|
|
220
|
+
print_api(message, color="red")
|
|
221
|
+
return 1
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
if not config_static.MainConfig.is_localhost and not is_admin:
|
|
225
|
+
# If we're not in localhost mode, this means we need to set virtual IPv4 addresses, which requires admin rights.
|
|
226
|
+
message = "In order to run the server in non-localhost mode, administrative rights are required.\nExiting..."
|
|
227
|
+
print_api(message, color='red')
|
|
228
|
+
return 1
|
|
229
|
+
|
|
230
|
+
# Check admin right if on localhost ============================================================================
|
|
231
|
+
# If any of the DNS IP target addresses is localhost loopback, then we need to check if the script
|
|
232
|
+
# is executed with admin rights. There are some processes that 'psutil' can't get their command line if not
|
|
233
|
+
# executed with administrative privileges.
|
|
234
|
+
# Also, check Admin privileges only if 'config.tcp['get_process_name']' was set to 'True' in 'config.ini' of
|
|
235
|
+
# the script.
|
|
236
|
+
if config_static.ProcessName.get_process_name:
|
|
237
|
+
# If the DNS server was set to resolve by engines, we need to check all relevant engine settings.
|
|
238
|
+
if config_static.DNSServer.resolve_by_engine:
|
|
239
|
+
# Check if the DNS target is localhost loopback.
|
|
240
|
+
if config_static.MainConfig.is_localhost and not is_admin:
|
|
241
|
+
message: str = \
|
|
242
|
+
("Need to run the script with administrative rights to get the process name while TCP "
|
|
243
|
+
"running on the same computer.\nExiting...")
|
|
244
|
+
print_api(message, color='red')
|
|
245
|
+
return 1
|
|
246
|
+
if config_static.DNSServer.resolve_all_domains_to_ipv4:
|
|
247
|
+
if config_static.DNSServer.target_ipv4 in socket_base.THIS_DEVICE_IP_LIST or \
|
|
248
|
+
config_static.DNSServer.target_ipv4.startswith('127.'):
|
|
249
|
+
if not is_admin:
|
|
250
|
+
message: str = \
|
|
251
|
+
("Need to run the script with administrative rights to get the process name while TCP "
|
|
252
|
+
"running on the same computer.\nExiting...")
|
|
253
|
+
print_api(message, color='red')
|
|
254
|
+
return 1
|
|
255
|
+
|
|
256
|
+
if (config_static.MainConfig.set_default_dns_gateway or
|
|
257
|
+
config_static.MainConfig.set_default_dns_gateway_to_network_interface_ipv4):
|
|
258
|
+
# Get current settings of the DNS gateway.
|
|
259
|
+
is_dns_dynamic, current_dns_gateway = dns.get_default_dns_gateway()
|
|
260
|
+
|
|
261
|
+
if not is_admin:
|
|
262
|
+
if config_static.MainConfig.set_default_dns_gateway:
|
|
263
|
+
ipv4_address_list = config_static.MainConfig.set_default_dns_gateway
|
|
264
|
+
elif config_static.MainConfig.set_default_dns_gateway_to_network_interface_ipv4 and config_static.MainConfig.is_localhost:
|
|
265
|
+
ipv4_address_list = [config_static.MainConfig.default_localhost_dns_gateway_ipv4]
|
|
266
|
+
elif config_static.MainConfig.set_default_dns_gateway_to_network_interface_ipv4 and not config_static.MainConfig.is_localhost:
|
|
267
|
+
ipv4_address_list = [socket.gethostbyname(socket.gethostname())]
|
|
268
|
+
else:
|
|
269
|
+
raise ValueError("Error: DNS gateway configuration is not set.")
|
|
270
|
+
|
|
271
|
+
# If the setting is dynamic or static, but the needed target address is not in the current DNS gateway.
|
|
272
|
+
if (is_dns_dynamic or
|
|
273
|
+
(not is_dns_dynamic and current_dns_gateway != ipv4_address_list)):
|
|
274
|
+
status_string = 'Dynamic' if is_dns_dynamic else 'Static'
|
|
275
|
+
message: str = (
|
|
276
|
+
"Need to run the script with administrative rights to set the default DNS gateway.\n"
|
|
277
|
+
f"Current DNS gateway: {status_string}, {current_dns_gateway}\n"
|
|
278
|
+
f"Target DNS gateway: Static, {ipv4_address_list}")
|
|
279
|
+
print_api(message, color='red')
|
|
280
|
+
return 1
|
|
281
|
+
|
|
282
|
+
if not config_static.DNSServer.resolve_by_engine and not config_static.DNSServer.resolve_regular_pass_thru and not \
|
|
283
|
+
config_static.DNSServer.resolve_all_domains_to_ipv4_enable:
|
|
284
|
+
message: str = (
|
|
285
|
+
"No DNS server resolving settings were set.\n"
|
|
286
|
+
"Please check your DNS server settings in the [config.toml] file.")
|
|
287
|
+
print_api(message, color='red')
|
|
288
|
+
return 1
|
|
289
|
+
|
|
290
|
+
# This is checked directly in the SocketWrapper.
|
|
291
|
+
# if (config_static.Certificates.install_ca_certificate_to_root_store and not is_admin) or \
|
|
292
|
+
# (config_static.Certificates.uninstall_unused_ca_certificates_with_mitm_ca_name and not is_admin):
|
|
293
|
+
# message: str = \
|
|
294
|
+
# "Need to run the script with administrative rights to install or uninstall CA certificate.\nExiting..."
|
|
295
|
+
# print_api(message, color='red')
|
|
296
|
+
# return 1
|
|
297
|
+
|
|
298
|
+
return 0
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def manipulations_after_import():
|
|
302
|
+
for key, value in config_static.DNSServer.resolve_all_domains_to_ipv4.items():
|
|
303
|
+
key = bool(int(key))
|
|
304
|
+
config_static.DNSServer.resolve_all_domains_to_ipv4_enable = key
|
|
305
|
+
config_static.DNSServer.target_ipv4 = value
|
|
306
|
+
break
|
|
307
|
+
|
|
308
|
+
if config_static.MainConfig.set_default_dns_gateway:
|
|
309
|
+
if config_static.MainConfig.set_default_dns_gateway[0] == 'l':
|
|
310
|
+
config_static.MainConfig.set_default_dns_gateway_to_localhost = True
|
|
311
|
+
config_static.MainConfig.set_default_dns_gateway = list()
|
|
312
|
+
elif config_static.MainConfig.set_default_dns_gateway[0] == 'n':
|
|
313
|
+
config_static.MainConfig.set_default_dns_gateway_to_network_interface_ipv4 = True
|
|
314
|
+
config_static.MainConfig.set_default_dns_gateway = list()
|
|
315
|
+
|
|
316
|
+
for key, value in config_static.TCPServer.no_engines_usage_to_listen_addresses.items():
|
|
317
|
+
key = bool(int(key))
|
|
318
|
+
# If the key is False, it means that the user doesn't want to use the no_engines_listening_address_list.
|
|
319
|
+
# So, we'll assign an empty list to it.
|
|
320
|
+
if not key:
|
|
321
|
+
config_static.TCPServer.no_engines_usage_to_listen_addresses_enable = False
|
|
322
|
+
config_static.TCPServer.no_engines_listening_address_list = list()
|
|
323
|
+
# If the key is True, it means that the user wants to use the no_engines_listening_address_list.
|
|
324
|
+
else:
|
|
325
|
+
config_static.TCPServer.no_engines_usage_to_listen_addresses_enable = key
|
|
326
|
+
config_static.TCPServer.no_engines_listening_address_list = value
|
|
327
|
+
break
|
|
328
|
+
|
|
329
|
+
# Convert extensions to skip to a list of extension IDs.
|
|
330
|
+
skip_extensions: list = list()
|
|
331
|
+
if config_static.SkipExtensions.tls_web_client_authentication:
|
|
332
|
+
skip_extensions.append('1.3.6.1.5.5.7.3.2')
|
|
333
|
+
if config_static.SkipExtensions.crl_distribution_points:
|
|
334
|
+
skip_extensions.append('2.5.29.31')
|
|
335
|
+
if config_static.SkipExtensions.authority_information_access:
|
|
336
|
+
skip_extensions.append('1.3.6.1.5.5.7.1.1')
|
|
337
|
+
config_static.SkipExtensions.SKIP_EXTENSION_ID_LIST = skip_extensions
|
|
338
|
+
|
|
339
|
+
# If the paths are relative, convert them to absolute paths.
|
|
340
|
+
config_static.LogRec.logs_path = filesystem.check_absolute_path___add_full(
|
|
341
|
+
config_static.LogRec.logs_path, config_static.MainConfig.SCRIPT_DIRECTORY)
|
|
342
|
+
config_static.Certificates.custom_server_certificate_path = filesystem.check_absolute_path___add_full(
|
|
343
|
+
config_static.Certificates.custom_server_certificate_path, config_static.MainConfig.SCRIPT_DIRECTORY)
|
|
344
|
+
|
|
345
|
+
config_static.LogRec.recordings_path = (
|
|
346
|
+
config_static.LogRec.logs_path + os.sep + config_static.LogRec.recordings_directory_name)
|
|
347
|
+
|
|
348
|
+
# At this point the user that sets the config can set it to null or empty string ''. We will make sure
|
|
349
|
+
# that the path is None if it's empty.
|
|
350
|
+
if config_static.Certificates.custom_private_key_path:
|
|
351
|
+
config_static.Certificates.custom_private_key_path = filesystem.check_absolute_path___add_full(
|
|
352
|
+
config_static.Certificates.custom_private_key_path, config_static.MainConfig.SCRIPT_DIRECTORY)
|
|
353
|
+
else:
|
|
354
|
+
# noinspection PyTypeChecker
|
|
355
|
+
config_static.Certificates.custom_private_key_path = None
|
|
356
|
+
|
|
357
|
+
config_static.Certificates.sni_server_certificates_cache_directory = filesystem.check_absolute_path___add_full(
|
|
358
|
+
config_static.Certificates.sni_server_certificates_cache_directory, config_static.MainConfig.SCRIPT_DIRECTORY)
|
|
359
|
+
config_static.Certificates.sni_server_certificate_from_server_socket_download_directory = \
|
|
360
|
+
filesystem.check_absolute_path___add_full(
|
|
361
|
+
config_static.Certificates.sni_server_certificate_from_server_socket_download_directory,
|
|
362
|
+
config_static.MainConfig.SCRIPT_DIRECTORY)
|
|
363
|
+
config_static.Certificates.sslkeylog_file_path = (f"{config_static.LogRec.logs_path}{os.sep}"
|
|
364
|
+
f"{config_static.Certificates.sslkeylog_file_name}")
|
|
365
|
+
|