atomicshop 3.3.8__py3-none-any.whl → 3.10.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.
- atomicshop/__init__.py +1 -1
- atomicshop/a_mains/get_local_tcp_ports.py +85 -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/basics/strings.py +1 -1
- atomicshop/certificates.py +2 -2
- atomicshop/dns.py +26 -28
- atomicshop/etws/traces/trace_tcp.py +1 -2
- atomicshop/mitm/centered_settings.py +133 -0
- atomicshop/mitm/config_static.py +22 -44
- atomicshop/mitm/connection_thread_worker.py +383 -165
- atomicshop/mitm/engines/__parent/recorder___parent.py +1 -1
- atomicshop/mitm/engines/__parent/requester___parent.py +1 -1
- atomicshop/mitm/engines/__parent/responder___parent.py +15 -2
- atomicshop/mitm/engines/create_module_template.py +1 -2
- atomicshop/mitm/import_config.py +91 -89
- atomicshop/mitm/initialize_engines.py +1 -2
- atomicshop/mitm/message.py +5 -4
- atomicshop/mitm/mitm_main.py +238 -122
- atomicshop/mitm/recs_files.py +61 -5
- atomicshop/mitm/ssh_tester.py +82 -0
- atomicshop/mitm/statistic_analyzer.py +33 -12
- atomicshop/mitm/statistic_analyzer_helper/moving_average_helper.py +104 -31
- atomicshop/networks.py +160 -92
- atomicshop/package_mains_processor.py +84 -0
- atomicshop/permissions/ubuntu_permissions.py +47 -0
- atomicshop/print_api.py +3 -5
- atomicshop/process.py +11 -4
- atomicshop/python_functions.py +23 -108
- atomicshop/speech_recognize.py +8 -0
- atomicshop/ssh_remote.py +140 -164
- atomicshop/web.py +63 -22
- atomicshop/web_apis/google_llm.py +22 -14
- atomicshop/wrappers/ctyping/msi_windows_installer/cabs.py +2 -1
- atomicshop/wrappers/ctyping/msi_windows_installer/extract_msi_main.py +2 -1
- atomicshop/wrappers/dockerw/dockerw.py +2 -2
- atomicshop/wrappers/elasticsearchw/config_basic.py +0 -12
- atomicshop/wrappers/elasticsearchw/elastic_infra.py +0 -190
- atomicshop/wrappers/factw/install/pre_install_and_install_before_restart.py +5 -5
- atomicshop/wrappers/githubw.py +180 -68
- atomicshop/wrappers/loggingw/consts.py +1 -1
- atomicshop/wrappers/loggingw/handlers.py +1 -1
- atomicshop/wrappers/loggingw/loggingw.py +20 -4
- atomicshop/wrappers/loggingw/reading.py +18 -0
- atomicshop/wrappers/mongodbw/mongo_infra.py +0 -38
- atomicshop/wrappers/netshw.py +124 -3
- atomicshop/wrappers/playwrightw/scenarios.py +1 -1
- atomicshop/wrappers/powershell_networking.py +80 -0
- atomicshop/wrappers/psutilw/psutil_networks.py +9 -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/win32_networkadapterconfiguration.py +12 -27
- atomicshop/wrappers/pywin32w/wmis/win32networkadapter.py +15 -9
- atomicshop/wrappers/socketw/certificator.py +19 -9
- atomicshop/wrappers/socketw/creator.py +101 -14
- atomicshop/wrappers/socketw/dns_server.py +17 -5
- atomicshop/wrappers/socketw/exception_wrapper.py +21 -16
- atomicshop/wrappers/socketw/process_getter.py +86 -0
- atomicshop/wrappers/socketw/receiver.py +29 -9
- atomicshop/wrappers/socketw/sender.py +10 -9
- atomicshop/wrappers/socketw/sni.py +31 -10
- atomicshop/wrappers/socketw/{base.py → socket_base.py} +33 -1
- atomicshop/wrappers/socketw/socket_client.py +11 -10
- atomicshop/wrappers/socketw/socket_wrapper.py +125 -32
- atomicshop/wrappers/socketw/ssl_base.py +6 -2
- atomicshop/wrappers/ubuntu_terminal.py +21 -18
- atomicshop/wrappers/win_auditw.py +189 -0
- {atomicshop-3.3.8.dist-info → atomicshop-3.10.0.dist-info}/METADATA +25 -30
- {atomicshop-3.3.8.dist-info → atomicshop-3.10.0.dist-info}/RECORD +83 -109
- atomicshop/_basics_temp.py +0 -101
- atomicshop/a_installs/ubuntu/docker_rootless.py +0 -11
- atomicshop/a_installs/ubuntu/docker_sudo.py +0 -11
- atomicshop/a_installs/ubuntu/elastic_search_and_kibana.py +0 -10
- atomicshop/a_installs/ubuntu/mongodb.py +0 -12
- atomicshop/a_installs/win/fibratus.py +0 -9
- atomicshop/a_installs/win/mongodb.py +0 -9
- atomicshop/a_installs/win/wsl_ubuntu_lts.py +0 -10
- atomicshop/addons/a_setup_scripts/install_psycopg2_ubuntu.sh +0 -3
- 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/__init__.py +0 -0
- atomicshop/archiver/_search_in_zip.py +0 -189
- atomicshop/archiver/search_in_archive.py +0 -284
- atomicshop/archiver/sevenz_app_w.py +0 -86
- atomicshop/archiver/sevenzs.py +0 -73
- atomicshop/archiver/shutils.py +0 -34
- atomicshop/archiver/zips.py +0 -353
- atomicshop/file_types.py +0 -24
- atomicshop/pbtkmultifile_argparse.py +0 -88
- atomicshop/script_as_string_processor.py +0 -42
- 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 -449
- atomicshop/wrappers/elasticsearchw/install_elastic.py +0 -233
- atomicshop/wrappers/ffmpegw.py +0 -125
- atomicshop/wrappers/fibratusw/__init__.py +0 -0
- atomicshop/wrappers/fibratusw/install.py +0 -80
- atomicshop/wrappers/mongodbw/install_mongodb_ubuntu.py +0 -100
- atomicshop/wrappers/mongodbw/install_mongodb_win.py +0 -244
- atomicshop/wrappers/process_wrapper_pbtk.py +0 -16
- atomicshop/wrappers/socketw/get_process.py +0 -123
- atomicshop/wrappers/wslw.py +0 -192
- atomicshop-3.3.8.dist-info/entry_points.txt +0 -2
- /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-3.3.8.dist-info → atomicshop-3.10.0.dist-info}/WHEEL +0 -0
- {atomicshop-3.3.8.dist-info → atomicshop-3.10.0.dist-info}/licenses/LICENSE.txt +0 -0
- {atomicshop-3.3.8.dist-info → atomicshop-3.10.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import argparse
|
|
3
|
+
import base64
|
|
4
|
+
|
|
5
|
+
from ..print_api import print_api
|
|
6
|
+
from .. import networks, ssh_remote, package_mains_processor
|
|
7
|
+
from . import config_static, mitm_main
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _make_parser() -> argparse.ArgumentParser:
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
description="Apply centered network settings to the target hosts based on the configuration file and arguments."
|
|
13
|
+
)
|
|
14
|
+
parser.add_argument(
|
|
15
|
+
"-t", "--target-hosts-file",
|
|
16
|
+
type=str,
|
|
17
|
+
required=True,
|
|
18
|
+
help="Path to the text file that will include the list of hosts (name/ipv4)."
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
parser.add_argument(
|
|
22
|
+
"-dns", "--set-default-dns-gateway",
|
|
23
|
+
action="store_true",
|
|
24
|
+
help="Set the default gateway as this server LAN IPv4 on the target hosts."
|
|
25
|
+
)
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
"-ca", "--install-ca-cert",
|
|
28
|
+
action="store_true",
|
|
29
|
+
help="Install the CA certificate on the target hosts."
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
return parser
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def centered_settings_main(config_file_path: str, script_version: str):
|
|
37
|
+
print(f"Centered Settings Application Script Version: {script_version}")
|
|
38
|
+
# Import the configuration file.
|
|
39
|
+
rc: int = config_static.load_config(config_file_path, print_kwargs=dict(stdout=False))
|
|
40
|
+
if rc != 0:
|
|
41
|
+
return rc
|
|
42
|
+
|
|
43
|
+
if config_static.MainConfig.is_localhost:
|
|
44
|
+
print_api("The server is set to localhost mode. No changes will be applied.", color="yellow")
|
|
45
|
+
return 0
|
|
46
|
+
|
|
47
|
+
interface_name: str = mitm_main._get_interface_name()
|
|
48
|
+
if interface_name is None:
|
|
49
|
+
return 1
|
|
50
|
+
|
|
51
|
+
# File path to the CA certificate file.
|
|
52
|
+
crt_file_path: str = config_static.MainConfig.ca_certificate_crt_filepath
|
|
53
|
+
with open(crt_file_path, 'r') as crt_file:
|
|
54
|
+
ca_certificate_string: str = crt_file.read()
|
|
55
|
+
|
|
56
|
+
# Get the main non-virtual IPv4 address.
|
|
57
|
+
main_ipv4_list: list[str] = networks.get_interface_ips_powershell(interface_name, "dynamic")
|
|
58
|
+
|
|
59
|
+
if not main_ipv4_list:
|
|
60
|
+
print_api(f"Could not determine the main IPv4 address for interface: {interface_name}", color="red")
|
|
61
|
+
return 1
|
|
62
|
+
else:
|
|
63
|
+
main_ipv4: str = main_ipv4_list[0]
|
|
64
|
+
|
|
65
|
+
parser = _make_parser()
|
|
66
|
+
args = parser.parse_args()
|
|
67
|
+
|
|
68
|
+
target_hosts_file_path: str = args.target_hosts_file
|
|
69
|
+
set_default_dns_gateway: bool = args.set_default_dns_gateway
|
|
70
|
+
install_ca_cert: bool = args.install_ca_cert
|
|
71
|
+
|
|
72
|
+
if not set_default_dns_gateway and not install_ca_cert:
|
|
73
|
+
print_api("No actions specified. Use -dns and/or -ca arguments to apply settings.", color="yellow")
|
|
74
|
+
return 0
|
|
75
|
+
|
|
76
|
+
if not os.path.exists(target_hosts_file_path):
|
|
77
|
+
print_api(f"Target host list file does not exist: {target_hosts_file_path}", color="red")
|
|
78
|
+
return 1
|
|
79
|
+
|
|
80
|
+
# Read the target hosts from the file.
|
|
81
|
+
with open(target_hosts_file_path, 'r') as f:
|
|
82
|
+
target_hosts: list[str] = [line.strip() for line in f if line.strip()]
|
|
83
|
+
if not target_hosts:
|
|
84
|
+
print_api(f"No target hosts found in the file: {target_hosts_file_path}", color="red")
|
|
85
|
+
return 1
|
|
86
|
+
|
|
87
|
+
if set_default_dns_gateway:
|
|
88
|
+
package_processor: package_mains_processor.PackageMainsProcessor = package_mains_processor.PackageMainsProcessor(
|
|
89
|
+
script_file_stem="set_default_dns_gateway")
|
|
90
|
+
elif install_ca_cert:
|
|
91
|
+
package_processor: package_mains_processor.PackageMainsProcessor = package_mains_processor.PackageMainsProcessor(
|
|
92
|
+
script_file_stem="install_ca_certificate")
|
|
93
|
+
else:
|
|
94
|
+
print_api("No valid action specified.", color="red")
|
|
95
|
+
return 1
|
|
96
|
+
|
|
97
|
+
script_string: str = package_processor.read_script_file_to_string()
|
|
98
|
+
|
|
99
|
+
for host in target_hosts:
|
|
100
|
+
ssh_client = ssh_remote.SSHRemote(
|
|
101
|
+
ip_address=host,
|
|
102
|
+
username=config_static.ProcessName.ssh_user,
|
|
103
|
+
password=config_static.ProcessName.ssh_pass
|
|
104
|
+
)
|
|
105
|
+
stderr = ssh_client.connect()
|
|
106
|
+
if stderr:
|
|
107
|
+
print_api(f"SSH connection to {host} failed:\n"
|
|
108
|
+
f"{stderr}", color="red")
|
|
109
|
+
continue
|
|
110
|
+
|
|
111
|
+
if set_default_dns_gateway:
|
|
112
|
+
stdout, stderr = ssh_client.remote_execution_python(
|
|
113
|
+
script_string=script_string, script_arg_values=(main_ipv4,))
|
|
114
|
+
|
|
115
|
+
if stderr:
|
|
116
|
+
print_api(f"Failed to apply settings on {host}:\n{stderr}", color="red")
|
|
117
|
+
else:
|
|
118
|
+
print_api(f"Successfully applied settings on {host}:\n{stdout}", color="green")
|
|
119
|
+
elif install_ca_cert:
|
|
120
|
+
cert_b64 = base64.b64encode(ca_certificate_string.encode("utf-8")).decode("ascii")
|
|
121
|
+
stdout, stderr = ssh_client.remote_execution_python(
|
|
122
|
+
script_string=script_string, script_arg_values=(config_static.MainConfig.ca_certificate_name, cert_b64,))
|
|
123
|
+
|
|
124
|
+
if stderr:
|
|
125
|
+
print_api(f"Failed to install CA certificate on {host}:\n{stderr}", color="red")
|
|
126
|
+
else:
|
|
127
|
+
print_api(f"Successfully installed CA certificate on {host}:\n{stdout}", color="green")
|
|
128
|
+
|
|
129
|
+
# Closing SSH connection to the target host.
|
|
130
|
+
ssh_client.close()
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
return 0
|
atomicshop/mitm/config_static.py
CHANGED
|
@@ -5,41 +5,6 @@ from typing import Literal
|
|
|
5
5
|
from . import import_config
|
|
6
6
|
from .message import ClientMessage
|
|
7
7
|
|
|
8
|
-
# CONFIG = None
|
|
9
|
-
LIST_OF_BOOLEANS: list = [
|
|
10
|
-
('dnstcp', 'offline'),
|
|
11
|
-
('dns', 'enable'),
|
|
12
|
-
('dns', 'resolve_by_engine'),
|
|
13
|
-
('dns', 'resolve_regular_pass_thru'),
|
|
14
|
-
('dns', 'resolve_all_domains_to_ipv4'),
|
|
15
|
-
('dns', 'set_default_dns_gateway_to_localhost'),
|
|
16
|
-
('dns', 'set_default_dns_gateway_to_default_interface_ipv4'),
|
|
17
|
-
('tcp', 'enable'),
|
|
18
|
-
('tcp', 'no_engines_usage_to_listen_addresses'),
|
|
19
|
-
('logrec', 'enable_request_response_recordings_in_logs'),
|
|
20
|
-
('certificates', 'install_ca_certificate_to_root_store'),
|
|
21
|
-
('certificates', 'uninstall_unused_ca_certificates_with_mitm_ca_name'),
|
|
22
|
-
('certificates', 'default_server_certificate_usage'),
|
|
23
|
-
('certificates', 'sni_add_new_domains_to_default_server_certificate'),
|
|
24
|
-
('certificates', 'custom_server_certificate_usage'),
|
|
25
|
-
('certificates', 'sni_create_server_certificate_for_each_domain'),
|
|
26
|
-
('certificates', 'sni_get_server_certificate_from_server_socket'),
|
|
27
|
-
('skip_extensions', 'tls_web_client_authentication'),
|
|
28
|
-
('skip_extensions', 'crl_distribution_points'),
|
|
29
|
-
('skip_extensions', 'authority_information_access'),
|
|
30
|
-
('process_name', 'get_process_name')
|
|
31
|
-
]
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
TOML_TO_STATIC_CATEGORIES: dict = {
|
|
35
|
-
'dnstcp': 'MainConfig',
|
|
36
|
-
'dns': 'DNSServer',
|
|
37
|
-
'tcp': 'TCPServer',
|
|
38
|
-
'logrec': 'LogRec',
|
|
39
|
-
'certificates': 'Certificates',
|
|
40
|
-
'skip_extensions': 'SkipExtensions',
|
|
41
|
-
'process_name': 'ProcessName'
|
|
42
|
-
}
|
|
43
8
|
|
|
44
9
|
# noinspection PyTypeChecker
|
|
45
10
|
ENGINES_LIST: list = None # list[initialize_engines.ModuleCategory]
|
|
@@ -47,6 +12,17 @@ REFERENCE_MODULE = None # initialize_engines.ModuleCategory
|
|
|
47
12
|
|
|
48
13
|
|
|
49
14
|
class MainConfig:
|
|
15
|
+
# '' (empty) - system's default internet interface.
|
|
16
|
+
# Any other network interface name available on the system.
|
|
17
|
+
is_offline: bool
|
|
18
|
+
network_interface: str
|
|
19
|
+
is_localhost: bool
|
|
20
|
+
|
|
21
|
+
set_default_dns_gateway: list[str]
|
|
22
|
+
set_default_dns_gateway_to_localhost: bool = False
|
|
23
|
+
set_default_dns_gateway_to_network_interface_ipv4: bool = False
|
|
24
|
+
default_localhost_dns_gateway_ipv4: str = '127.0.0.1'
|
|
25
|
+
|
|
50
26
|
LOGGER_NAME: str = 'network'
|
|
51
27
|
|
|
52
28
|
SCRIPT_DIRECTORY: str = None
|
|
@@ -66,7 +42,6 @@ class MainConfig:
|
|
|
66
42
|
# Default server certificate file name and path.
|
|
67
43
|
default_server_certificate_filename = f'{default_server_certificate_name}.pem'
|
|
68
44
|
default_server_certificate_filepath: str = None
|
|
69
|
-
offline: bool = False
|
|
70
45
|
|
|
71
46
|
@classmethod
|
|
72
47
|
def update(cls):
|
|
@@ -80,9 +55,12 @@ class MainConfig:
|
|
|
80
55
|
|
|
81
56
|
@dataclass
|
|
82
57
|
class DNSServer:
|
|
83
|
-
|
|
58
|
+
is_enabled: bool
|
|
84
59
|
offline_mode: bool
|
|
85
60
|
|
|
61
|
+
listening_ipv4: str
|
|
62
|
+
listening_port: int
|
|
63
|
+
|
|
86
64
|
listening_address: str
|
|
87
65
|
forwarding_dns_service_ipv4: str
|
|
88
66
|
cache_timeout_minutes: int
|
|
@@ -92,10 +70,6 @@ class DNSServer:
|
|
|
92
70
|
resolve_all_domains_to_ipv4_enable: bool
|
|
93
71
|
target_ipv4: str
|
|
94
72
|
|
|
95
|
-
set_default_dns_gateway: str
|
|
96
|
-
set_default_dns_gateway_to_localhost: bool
|
|
97
|
-
set_default_dns_gateway_to_default_interface_ipv4: bool
|
|
98
|
-
|
|
99
73
|
# Convertable variables.
|
|
100
74
|
resolve_all_domains_to_ipv4: dict
|
|
101
75
|
|
|
@@ -103,9 +77,10 @@ class DNSServer:
|
|
|
103
77
|
forwarding_dns_service_port: int = 53
|
|
104
78
|
|
|
105
79
|
|
|
80
|
+
|
|
106
81
|
@dataclass
|
|
107
82
|
class TCPServer:
|
|
108
|
-
|
|
83
|
+
is_enabled: bool
|
|
109
84
|
no_engines_usage_to_listen_addresses_enable: bool
|
|
110
85
|
no_engines_listening_address_list: list[str]
|
|
111
86
|
|
|
@@ -124,7 +99,6 @@ class LogRec:
|
|
|
124
99
|
|
|
125
100
|
@dataclass
|
|
126
101
|
class Certificates:
|
|
127
|
-
enable_sslkeylogfile_env_to_client_ssl_context: bool
|
|
128
102
|
install_ca_certificate_to_root_store: bool
|
|
129
103
|
uninstall_unused_ca_certificates_with_mitm_ca_name: bool
|
|
130
104
|
|
|
@@ -141,6 +115,10 @@ class Certificates:
|
|
|
141
115
|
sni_server_certificate_from_server_socket_download_directory: str
|
|
142
116
|
|
|
143
117
|
domains_all_times: list[str]
|
|
118
|
+
sslkeylog_file_path: str
|
|
119
|
+
|
|
120
|
+
sslkeylog_file_name: str = "sslkeylog.txt"
|
|
121
|
+
enable_sslkeylogfile_env_to_client_ssl_context: bool = True
|
|
144
122
|
|
|
145
123
|
|
|
146
124
|
@dataclass
|
|
@@ -195,7 +173,7 @@ def get_listening_addresses(client_message: ClientMessage) -> dict | None:
|
|
|
195
173
|
CONFIG_INI_TESTER_FILE_NAME: str = 'config_tester.ini'
|
|
196
174
|
|
|
197
175
|
"""
|
|
198
|
-
config.
|
|
176
|
+
config.toml:
|
|
199
177
|
target_domain_or_ip: the domain or ip that the requests will be sent to. Better use domains, for better testing
|
|
200
178
|
simulation.
|
|
201
179
|
target_port: the port that requests will be sent to.
|