atomicshop 2.15.11__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/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/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/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/enums.py +2 -2
- atomicshop/basics/exceptions.py +5 -1
- atomicshop/basics/list_of_classes.py +29 -0
- atomicshop/basics/multiprocesses.py +374 -50
- atomicshop/basics/strings.py +72 -3
- atomicshop/basics/threads.py +14 -0
- atomicshop/basics/tracebacks.py +13 -3
- atomicshop/certificates.py +153 -52
- atomicshop/config_init.py +11 -6
- atomicshop/console_user_response.py +7 -14
- atomicshop/consoles.py +9 -0
- atomicshop/datetimes.py +1 -1
- atomicshop/diff_check.py +3 -3
- atomicshop/dns.py +128 -3
- atomicshop/etws/_pywintrace_fix.py +17 -0
- atomicshop/etws/trace.py +40 -42
- atomicshop/etws/traces/trace_dns.py +56 -44
- atomicshop/etws/traces/trace_tcp.py +130 -0
- atomicshop/file_io/csvs.py +27 -5
- atomicshop/file_io/docxs.py +34 -17
- atomicshop/file_io/file_io.py +31 -17
- atomicshop/file_io/jsons.py +49 -0
- atomicshop/file_io/tomls.py +139 -0
- atomicshop/filesystem.py +616 -291
- atomicshop/get_process_list.py +3 -3
- 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 -80
- 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 +136 -40
- atomicshop/mitm/statistic_analyzer_helper/moving_average_helper.py +265 -83
- atomicshop/monitor/checks/dns.py +1 -1
- atomicshop/networks.py +671 -0
- atomicshop/on_exit.py +39 -9
- 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 -42
- atomicshop/process.py +24 -6
- atomicshop/process_poller/process_pool.py +0 -1
- atomicshop/process_poller/simple_process_pool.py +204 -5
- atomicshop/python_file_patcher.py +1 -1
- atomicshop/python_functions.py +27 -75
- atomicshop/speech_recognize.py +8 -0
- atomicshop/ssh_remote.py +158 -172
- atomicshop/system_resource_monitor.py +61 -47
- atomicshop/system_resources.py +8 -8
- atomicshop/tempfiles.py +1 -2
- atomicshop/urls.py +6 -0
- atomicshop/venvs.py +28 -0
- atomicshop/versioning.py +27 -0
- atomicshop/web.py +98 -27
- 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/const.py +97 -47
- atomicshop/wrappers/ctyping/etw_winapi/etw_functions.py +178 -49
- 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 +2 -2
- 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/githubw.py +537 -54
- atomicshop/wrappers/loggingw/consts.py +1 -1
- atomicshop/wrappers/loggingw/filters.py +23 -0
- atomicshop/wrappers/loggingw/formatters.py +12 -0
- atomicshop/wrappers/loggingw/handlers.py +214 -107
- atomicshop/wrappers/loggingw/loggers.py +19 -0
- atomicshop/wrappers/loggingw/loggingw.py +860 -22
- atomicshop/wrappers/loggingw/reading.py +134 -112
- atomicshop/wrappers/mongodbw/mongo_infra.py +31 -0
- atomicshop/wrappers/mongodbw/mongodbw.py +1324 -36
- 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 +37 -1
- atomicshop/wrappers/psutilw/psutil_networks.py +85 -0
- atomicshop/wrappers/pyopensslw.py +9 -2
- atomicshop/wrappers/pywin32w/cert_store.py +116 -0
- atomicshop/wrappers/pywin32w/win_event_log/fetch.py +174 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_create.py +3 -105
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_terminate.py +3 -57
- 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 +491 -182
- 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 +11 -7
- 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 +1 -1
- 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.15.11.dist-info → atomicshop-3.10.5.dist-info}/METADATA +31 -51
- atomicshop-3.10.5.dist-info/RECORD +306 -0
- {atomicshop-2.15.11.dist-info → atomicshop-3.10.5.dist-info}/WHEEL +1 -1
- atomicshop/_basics_temp.py +0 -101
- atomicshop/a_installs/win/fibratus.py +0 -9
- atomicshop/a_installs/win/mongodb.py +0 -9
- atomicshop/a_installs/win/pycharm.py +0 -9
- 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/__pycache__/install_fibratus_windows.cpython-312.pyc +0 -0
- atomicshop/addons/mains/__pycache__/msi_unpacker.cpython-312.pyc +0 -0
- 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/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/file_types.py +0 -24
- atomicshop/mitm/config_editor.py +0 -37
- atomicshop/mitm/engines/create_module_template_example.py +0 -13
- atomicshop/mitm/initialize_mitm_server.py +0 -268
- atomicshop/pbtkmultifile_argparse.py +0 -88
- atomicshop/permissions.py +0 -151
- 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/fibratusw/install.py +0 -81
- atomicshop/wrappers/mongodbw/infrastructure.py +0 -53
- atomicshop/wrappers/mongodbw/install_mongodb.py +0 -190
- atomicshop/wrappers/msiw.py +0 -149
- atomicshop/wrappers/nodejsw/install_nodejs.py +0 -139
- atomicshop/wrappers/process_wrapper_pbtk.py +0 -16
- atomicshop/wrappers/psutilw/networks.py +0 -45
- atomicshop/wrappers/pycharmw.py +0 -81
- atomicshop/wrappers/socketw/base.py +0 -59
- atomicshop/wrappers/socketw/get_process.py +0 -107
- atomicshop/wrappers/wslw.py +0 -191
- atomicshop-2.15.11.dist-info/RECORD +0 -302
- /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 → 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 → a_mains/addons}/process_list/compile.cmd +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/compiled/Win10x64/process_list.dll +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/compiled/Win10x64/process_list.exp +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/compiled/Win10x64/process_list.lib +0 -0
- /atomicshop/{addons → a_mains/addons}/process_list/process_list.cpp +0 -0
- /atomicshop/{archiver → permissions}/__init__.py +0 -0
- /atomicshop/{wrappers/fibratusw → web_apis}/__init__.py +0 -0
- /atomicshop/wrappers/{nodejsw → pywin32w/wmis}/__init__.py +0 -0
- /atomicshop/wrappers/pywin32w/{wmi_win32process.py → wmis/win32process.py} +0 -0
- {atomicshop-2.15.11.dist-info → atomicshop-3.10.5.dist-info/licenses}/LICENSE.txt +0 -0
- {atomicshop-2.15.11.dist-info → atomicshop-3.10.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# These are specified with hardcoded paths instead of relative, because 'create_module_template.py' copies the content.
|
|
2
|
+
from atomicshop.mitm.engines.__parent.requester___parent import RequesterParent
|
|
3
|
+
from atomicshop.mitm.shared_functions import create_custom_logger
|
|
4
|
+
from atomicshop.mitm.message import ClientMessage
|
|
5
|
+
from atomicshop.mitm import config_static
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
import time
|
|
9
|
+
datetime
|
|
10
|
+
import binascii
|
|
11
|
+
|
|
12
|
+
# This is 'example' '.proto' file that contains message 'ExampleResponse'.
|
|
13
|
+
from .example_pb2 import ExampleRequest
|
|
14
|
+
# Import from 'protobuf' the 'json_format' library.
|
|
15
|
+
from google.protobuf import json_format
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class RequesterGeneral(RequesterParent):
|
|
20
|
+
"""The class that is responsible for generating request to client based on the received message."""
|
|
21
|
+
# When initializing main classes through "super" you need to pass parameters to init
|
|
22
|
+
def __init__(self):
|
|
23
|
+
super().__init__()
|
|
24
|
+
|
|
25
|
+
self.logger = create_custom_logger()
|
|
26
|
+
|
|
27
|
+
# def create_request(self, class_client_message: ClientMessage, **kwargs) -> bytes:
|
|
28
|
+
# # noinspection GrazieInspection
|
|
29
|
+
# """
|
|
30
|
+
# For more examples check the responder.
|
|
31
|
+
# Function to create Response based on ClientMessage and its Request.
|
|
32
|
+
#
|
|
33
|
+
# :param class_client_message: contains request and other parameters to help creating response.
|
|
34
|
+
# :return: 1 request in byte string.
|
|
35
|
+
# -----------------------------------
|
|
36
|
+
#
|
|
37
|
+
# # Example of creating byte string using 'build_byte_request' function:
|
|
38
|
+
# request_bytes: bytes = self.build_byte_request(
|
|
39
|
+
# http_method=class_client_message.request_raw_decoded.command,
|
|
40
|
+
# endpoint=class_client_message.request_raw_decoded.path,
|
|
41
|
+
# http_version=class_client_message.request_raw_decoded.request_version,
|
|
42
|
+
# headers=response_headers,
|
|
43
|
+
# body=b''
|
|
44
|
+
# )
|
|
45
|
+
#
|
|
46
|
+
# return request_bytes
|
|
47
|
+
# -----------------------------------
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# These are specified with hardcoded paths instead of relative, because 'create_module_template.py' copies the content.
|
|
2
2
|
from atomicshop.mitm.engines.__parent.responder___parent import ResponderParent
|
|
3
3
|
from atomicshop.mitm.shared_functions import create_custom_logger
|
|
4
|
+
from atomicshop.mitm.message import ClientMessage
|
|
5
|
+
from atomicshop.mitm import config_static
|
|
4
6
|
|
|
5
7
|
"""
|
|
6
8
|
import time
|
|
@@ -14,14 +16,71 @@ from google.protobuf import json_format
|
|
|
14
16
|
"""
|
|
15
17
|
|
|
16
18
|
|
|
17
|
-
# The class that is responsible for generating response to client based on the received message.
|
|
18
19
|
class ResponderGeneral(ResponderParent):
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
"""The class that is responsible for generating response to client based on the received message."""
|
|
21
21
|
# When initializing main classes through "super" you need to pass parameters to init
|
|
22
22
|
def __init__(self):
|
|
23
23
|
super().__init__()
|
|
24
24
|
|
|
25
|
+
self.logger = create_custom_logger()
|
|
26
|
+
|
|
27
|
+
# def create_response(self, class_client_message: ClientMessage):
|
|
28
|
+
# # noinspection GrazieInspection
|
|
29
|
+
# """
|
|
30
|
+
# Function to create Response based on ClientMessage and its Request.
|
|
31
|
+
#
|
|
32
|
+
# :param class_client_message: contains request and other parameters to help creating response.
|
|
33
|
+
# :return: list of responses in bytes.
|
|
34
|
+
# -----------------------------------
|
|
35
|
+
#
|
|
36
|
+
# # Example of creating list of bytes using 'build_byte_response' function:
|
|
37
|
+
# result_list: list[bytes] = list()
|
|
38
|
+
# result_list.append(
|
|
39
|
+
# self.build_byte_response(
|
|
40
|
+
# http_version=class_client_message.request_raw_decoded.request_version,
|
|
41
|
+
# status_code=200,
|
|
42
|
+
# headers=response_headers,
|
|
43
|
+
# body=b''
|
|
44
|
+
# )
|
|
45
|
+
# )
|
|
46
|
+
#
|
|
47
|
+
# return result_list
|
|
48
|
+
# -----------------------------------
|
|
49
|
+
# # Example of extracting variables from URL PATH based on custom PATH TEMPLATE:
|
|
50
|
+
# # (more examples in 'self.extract_variables_from_path_template' function description)
|
|
51
|
+
# template_path: str = "/hithere/<variable1>/else/<variable2>/tested/"
|
|
52
|
+
# path_variables: dict = extract_variables_from_path_template(
|
|
53
|
+
# path=class_client_message.request_raw_decoded.path,
|
|
54
|
+
# template_path=template_path
|
|
55
|
+
# )
|
|
56
|
+
# -----------------------------------
|
|
57
|
+
# # Example of extracting value from URL PATH parameters after question mark:
|
|
58
|
+
# parameter_value = extract_value_from_path_parameter(
|
|
59
|
+
# path=class_client_message.request_raw_decoded.path,
|
|
60
|
+
# parameter='test_id'
|
|
61
|
+
# )
|
|
62
|
+
# """
|
|
63
|
+
#
|
|
64
|
+
# # byte_response: bytes = b''
|
|
65
|
+
# # self.logger.info(f"Response: {byte_response}")
|
|
66
|
+
#
|
|
67
|
+
# response_bytes_list: list[bytes] = list()
|
|
68
|
+
# # response_bytes_list.append(byte_response)
|
|
69
|
+
# return response_bytes_list
|
|
70
|
+
|
|
71
|
+
# def create_connect_response(self, class_client_message: ClientMessage):
|
|
72
|
+
# """
|
|
73
|
+
# This is almost the same as 'create_response' function, but it's used only when the client connects and before
|
|
74
|
+
# sending any data.
|
|
75
|
+
# """
|
|
76
|
+
#
|
|
77
|
+
# # byte_response: bytes = b''
|
|
78
|
+
# # self.logger.info(f"Response: {byte_response}")
|
|
79
|
+
#
|
|
80
|
+
# response_bytes_list: list[bytes] = list()
|
|
81
|
+
# # response_bytes_list.append(byte_response)
|
|
82
|
+
# return response_bytes_list
|
|
83
|
+
|
|
25
84
|
# ==================================================================================================================
|
|
26
85
|
# Uncomment this section in order to begin building custom responder.
|
|
27
86
|
# @staticmethod
|
|
@@ -89,7 +148,7 @@ class ResponderGeneral(ResponderParent):
|
|
|
89
148
|
# # === Building Headers. ===========================
|
|
90
149
|
# # Response Date example: 'Tue, 08 Nov 2022 14:23: 00 GMT'
|
|
91
150
|
# resp_headers = {
|
|
92
|
-
# 'Date': self.
|
|
151
|
+
# 'Date': self.get_current_formatted_time_http(),
|
|
93
152
|
# 'Content-Length': str(len(resp_body)),
|
|
94
153
|
# }
|
|
95
154
|
#
|
|
@@ -109,7 +168,7 @@ class ResponderGeneral(ResponderParent):
|
|
|
109
168
|
# # === Building Headers. ===========================
|
|
110
169
|
# # Response Date example: 'Tue, 08 Nov 2022 14:23: 00 GMT'
|
|
111
170
|
# resp_headers = {
|
|
112
|
-
# 'Date': self.
|
|
171
|
+
# 'Date': self.get_current_formatted_time_http(),
|
|
113
172
|
# 'Content-Length': str(len(resp_body)),
|
|
114
173
|
# 'Connection': 'keep-alive'
|
|
115
174
|
# }
|
|
@@ -118,10 +177,10 @@ class ResponderGeneral(ResponderParent):
|
|
|
118
177
|
#
|
|
119
178
|
# def create_response(self, class_client_message: ClientMessage):
|
|
120
179
|
# # Arranging important request entries to appropriate variables.
|
|
121
|
-
# req_path = class_client_message.
|
|
122
|
-
# req_command = class_client_message.
|
|
123
|
-
# req_headers = class_client_message.
|
|
124
|
-
# req_body = class_client_message.
|
|
180
|
+
# req_path = class_client_message.request_auto_parsed.path
|
|
181
|
+
# req_command = class_client_message.request_auto_parsed.command
|
|
182
|
+
# req_headers = class_client_message.request_auto_parsed.headers
|
|
183
|
+
# req_body = class_client_message.request_auto_parsed.body
|
|
125
184
|
#
|
|
126
185
|
# # ====================================
|
|
127
186
|
# # Case specific.
|
|
@@ -144,10 +203,33 @@ class ResponderGeneral(ResponderParent):
|
|
|
144
203
|
#
|
|
145
204
|
# # ==============================================================================
|
|
146
205
|
# # === Building byte response. ==================================================
|
|
147
|
-
# self.build_byte_response(
|
|
148
|
-
# http_version=class_client_message.
|
|
206
|
+
# byte_response = self.build_byte_response(
|
|
207
|
+
# http_version=class_client_message.request_auto_parsed.request_version,
|
|
149
208
|
# status_code=resp_status_code,
|
|
150
209
|
# headers=resp_headers,
|
|
151
|
-
# body=resp_body_bytes
|
|
152
|
-
# client_message=class_client_message
|
|
210
|
+
# body=resp_body_bytes
|
|
153
211
|
# )
|
|
212
|
+
#
|
|
213
|
+
# result_response_list: list[bytes] = [byte_response]
|
|
214
|
+
# return result_response_list
|
|
215
|
+
#
|
|
216
|
+
# ==================================================================================================================
|
|
217
|
+
# TEST RESPONSE.
|
|
218
|
+
# def create_response(self, class_client_message: ClientMessage):
|
|
219
|
+
# resp_body_text: bytes = b"<html><body>TEST OK!</body></html>\n"
|
|
220
|
+
# resp_status_code: int = 200
|
|
221
|
+
# resp_headers: dict = {
|
|
222
|
+
# # Tell the browser it’s plain text (could be “text/html” if you wrap it in HTML).
|
|
223
|
+
# "Content-Type": "text/html; charset=utf-8"}
|
|
224
|
+
#
|
|
225
|
+
# # Build the raw bytes to send.
|
|
226
|
+
# byte_response = self.build_byte_response(
|
|
227
|
+
# http_version="HTTP/1.1",
|
|
228
|
+
# status_code=resp_status_code,
|
|
229
|
+
# headers=resp_headers,
|
|
230
|
+
# body=resp_body_text
|
|
231
|
+
#
|
|
232
|
+
# )
|
|
233
|
+
#
|
|
234
|
+
# result_response_list: list[bytes] = [byte_response]
|
|
235
|
+
# return result_response_list
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import sys
|
|
1
2
|
import os
|
|
3
|
+
import argparse
|
|
2
4
|
from typing import Literal
|
|
3
5
|
|
|
4
|
-
from ... import filesystem
|
|
6
|
+
from ... import filesystem, consoles
|
|
5
7
|
from ...basics import strings
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
console = Console()
|
|
6
12
|
|
|
7
13
|
|
|
8
14
|
GENERAL_CLASS_NAME: str = "General"
|
|
@@ -13,6 +19,7 @@ CONFIG_FILE_NAME: str = "engine_config.toml"
|
|
|
13
19
|
|
|
14
20
|
REFERENCE_PARSER_FILE_NAME: str = f"parser_{REFERENCE_ENGINE_NAME}.py"
|
|
15
21
|
REFERENCE_RESPONDER_FILE_NAME: str = f"responder_{REFERENCE_ENGINE_NAME}.py"
|
|
22
|
+
REFERENCE_REQUESTER_FILE_NAME: str = f"requester_{REFERENCE_ENGINE_NAME}.py"
|
|
16
23
|
REFERENCE_RECORDER_FILE_NAME: str = f"recorder_{REFERENCE_ENGINE_NAME}.py"
|
|
17
24
|
|
|
18
25
|
SCRIPT_DIRECTORY: str = filesystem.get_file_directory(__file__)
|
|
@@ -20,10 +27,13 @@ ENGINES_DIRECTORY_PATH: str = filesystem.get_working_directory() + os.sep + ENGI
|
|
|
20
27
|
|
|
21
28
|
|
|
22
29
|
class CreateModuleTemplate:
|
|
23
|
-
def __init__(
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
engine_name: str = None
|
|
33
|
+
):
|
|
24
34
|
# === Get input variables. ===
|
|
25
35
|
self.engine_name: str = engine_name
|
|
26
|
-
self.domains: list =
|
|
36
|
+
self.domains: list = ['example.com:443', 'example.org:80']
|
|
27
37
|
|
|
28
38
|
# New engine's directory.
|
|
29
39
|
self.new_engine_directory: str = ENGINES_DIRECTORY_PATH + os.sep + self.engine_name
|
|
@@ -36,11 +46,13 @@ class CreateModuleTemplate:
|
|
|
36
46
|
reference_folder_path: str = SCRIPT_DIRECTORY + os.sep + REFERENCE_ENGINE_NAME
|
|
37
47
|
self.parser_general_path: str = reference_folder_path + os.sep + REFERENCE_PARSER_FILE_NAME
|
|
38
48
|
self.responder_general_path: str = reference_folder_path + os.sep + REFERENCE_RESPONDER_FILE_NAME
|
|
49
|
+
self.requester_general_path: str = reference_folder_path + os.sep + REFERENCE_REQUESTER_FILE_NAME
|
|
39
50
|
self.recorder_general_path: str = reference_folder_path + os.sep + REFERENCE_RECORDER_FILE_NAME
|
|
40
51
|
|
|
41
|
-
self.parser_file_name: str = f"
|
|
42
|
-
self.responder_file_name: str = f"
|
|
43
|
-
self.
|
|
52
|
+
self.parser_file_name: str = f"parser.py"
|
|
53
|
+
self.responder_file_name: str = f"responder.py"
|
|
54
|
+
self.requester_file_name: str = f"requester.py"
|
|
55
|
+
self.recorder_file_name: str = f"recorder.py"
|
|
44
56
|
|
|
45
57
|
self.create_template()
|
|
46
58
|
|
|
@@ -51,11 +63,12 @@ class CreateModuleTemplate:
|
|
|
51
63
|
# Create the 'engines' directory if it doesn't exist.
|
|
52
64
|
filesystem.create_directory(ENGINES_DIRECTORY_PATH)
|
|
53
65
|
|
|
54
|
-
# Create new engines folder.
|
|
66
|
+
# Create new engines' folder.
|
|
55
67
|
filesystem.create_directory(self.new_engine_directory)
|
|
56
68
|
|
|
57
69
|
self._create_engine_module_from_reference(file_path=self.parser_general_path, module_type='parser')
|
|
58
70
|
self._create_engine_module_from_reference(file_path=self.responder_general_path, module_type='responder')
|
|
71
|
+
self._create_engine_module_from_reference(file_path=self.requester_general_path, module_type='requester')
|
|
59
72
|
self._create_engine_module_from_reference(file_path=self.recorder_general_path, module_type='recorder')
|
|
60
73
|
|
|
61
74
|
self.create_config_file()
|
|
@@ -66,35 +79,42 @@ class CreateModuleTemplate:
|
|
|
66
79
|
|
|
67
80
|
# Add "" to each domain.
|
|
68
81
|
domains_with_quotes: list = [f'"{domain}"' for domain in self.domains]
|
|
82
|
+
|
|
83
|
+
config_lines_list.append('[engine]')
|
|
69
84
|
config_lines_list.append(f'domains = [{", ".join(domains_with_quotes)}]\n')
|
|
70
|
-
config_lines_list.append(
|
|
71
|
-
config_lines_list.append(
|
|
72
|
-
config_lines_list.append(
|
|
85
|
+
config_lines_list.append('[on_port_connect]')
|
|
86
|
+
config_lines_list.append('#5000 = "31.31.31.31:443"')
|
|
87
|
+
config_lines_list.append('#5000 = "ip_port_address.txt"\n')
|
|
88
|
+
config_lines_list.append('[mtls]')
|
|
89
|
+
config_lines_list.append('# "subdomain.domain.com" = "file_name_in_current_dir.pem"\n')
|
|
90
|
+
# config_lines_list.append(f'\n')
|
|
73
91
|
|
|
74
92
|
config_file_path = self.new_engine_directory + os.sep + CONFIG_FILE_NAME
|
|
75
93
|
|
|
76
94
|
with open(config_file_path, 'w') as output_file:
|
|
77
95
|
output_file.write('\n'.join(config_lines_list))
|
|
78
96
|
|
|
79
|
-
print(f"Config File Created: {config_file_path}")
|
|
97
|
+
console.print(f"Config File Created: {config_file_path}", style="bright_blue")
|
|
80
98
|
|
|
81
99
|
def _create_engine_module_from_reference(
|
|
82
100
|
self,
|
|
83
101
|
file_path: str,
|
|
84
|
-
module_type: Literal['parser', 'responder', 'recorder']
|
|
102
|
+
module_type: Literal['parser', 'responder', 'requester', 'recorder']
|
|
85
103
|
):
|
|
86
104
|
|
|
87
105
|
if module_type == 'parser':
|
|
88
106
|
new_module_file_name = self.parser_file_name
|
|
89
107
|
elif module_type == 'responder':
|
|
90
108
|
new_module_file_name = self.responder_file_name
|
|
109
|
+
elif module_type == 'requester':
|
|
110
|
+
new_module_file_name = self.requester_file_name
|
|
91
111
|
elif module_type == 'recorder':
|
|
92
112
|
new_module_file_name = self.recorder_file_name
|
|
93
113
|
else:
|
|
94
114
|
raise ValueError(f"Module type is not recognized: {module_type}")
|
|
95
115
|
|
|
96
116
|
# Reading the module file to string.
|
|
97
|
-
with open(file_path, 'r') as input_file:
|
|
117
|
+
with open(file_path, 'r', encoding='utf-8') as input_file:
|
|
98
118
|
file_content_string = input_file.read()
|
|
99
119
|
|
|
100
120
|
new_module_full_path: str = str()
|
|
@@ -107,4 +127,28 @@ class CreateModuleTemplate:
|
|
|
107
127
|
output_file.write(new_content_string)
|
|
108
128
|
|
|
109
129
|
print(f"Converted: {file_path}")
|
|
110
|
-
print(f"To: {new_module_full_path}")
|
|
130
|
+
console.print(f"To: {new_module_full_path}", style="green")
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def create_template(engine_name: str) -> int:
|
|
134
|
+
CreateModuleTemplate(engine_name=engine_name)
|
|
135
|
+
return 0
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _make_parser() -> argparse.ArgumentParser:
|
|
139
|
+
parser = argparse.ArgumentParser(description='Create a new engine module template.')
|
|
140
|
+
parser.add_argument('engine_name', type=str, help='The name of the new engine.')
|
|
141
|
+
return parser
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def main() -> int:
|
|
145
|
+
arg_parser: argparse.ArgumentParser = _make_parser()
|
|
146
|
+
args = arg_parser.parse_args()
|
|
147
|
+
|
|
148
|
+
rc: int = create_template(**vars(args))
|
|
149
|
+
consoles.wait_any_key()
|
|
150
|
+
return rc
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
if __name__ == '__main__':
|
|
154
|
+
sys.exit(main())
|