atomicshop 3.3.28__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.

Files changed (99) hide show
  1. atomicshop/__init__.py +1 -1
  2. atomicshop/a_mains/get_local_tcp_ports.py +85 -0
  3. atomicshop/a_mains/install_ca_certificate.py +172 -0
  4. atomicshop/a_mains/process_from_port.py +119 -0
  5. atomicshop/a_mains/set_default_dns_gateway.py +90 -0
  6. atomicshop/basics/strings.py +1 -1
  7. atomicshop/certificates.py +2 -2
  8. atomicshop/dns.py +26 -28
  9. atomicshop/etws/traces/trace_tcp.py +1 -2
  10. atomicshop/mitm/centered_settings.py +133 -0
  11. atomicshop/mitm/config_static.py +18 -43
  12. atomicshop/mitm/connection_thread_worker.py +376 -162
  13. atomicshop/mitm/engines/__parent/recorder___parent.py +1 -1
  14. atomicshop/mitm/engines/__parent/requester___parent.py +1 -1
  15. atomicshop/mitm/engines/__parent/responder___parent.py +15 -2
  16. atomicshop/mitm/engines/create_module_template.py +1 -2
  17. atomicshop/mitm/import_config.py +79 -88
  18. atomicshop/mitm/initialize_engines.py +1 -2
  19. atomicshop/mitm/message.py +5 -4
  20. atomicshop/mitm/mitm_main.py +222 -121
  21. atomicshop/mitm/recs_files.py +61 -5
  22. atomicshop/mitm/ssh_tester.py +82 -0
  23. atomicshop/networks.py +108 -93
  24. atomicshop/package_mains_processor.py +84 -0
  25. atomicshop/permissions/ubuntu_permissions.py +47 -0
  26. atomicshop/print_api.py +3 -5
  27. atomicshop/python_functions.py +23 -108
  28. atomicshop/speech_recognize.py +8 -0
  29. atomicshop/ssh_remote.py +115 -51
  30. atomicshop/web.py +20 -7
  31. atomicshop/web_apis/google_llm.py +22 -14
  32. atomicshop/wrappers/ctyping/msi_windows_installer/cabs.py +2 -1
  33. atomicshop/wrappers/ctyping/msi_windows_installer/extract_msi_main.py +2 -1
  34. atomicshop/wrappers/dockerw/dockerw.py +2 -2
  35. atomicshop/wrappers/factw/install/pre_install_and_install_before_restart.py +5 -5
  36. atomicshop/wrappers/githubw.py +175 -63
  37. atomicshop/wrappers/loggingw/handlers.py +1 -1
  38. atomicshop/wrappers/loggingw/loggingw.py +17 -1
  39. atomicshop/wrappers/netshw.py +124 -3
  40. atomicshop/wrappers/playwrightw/scenarios.py +1 -1
  41. atomicshop/wrappers/powershell_networking.py +80 -0
  42. atomicshop/wrappers/psutilw/psutil_networks.py +9 -0
  43. atomicshop/wrappers/pywin32w/win_event_log/fetch.py +174 -0
  44. atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_create.py +3 -105
  45. atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_terminate.py +3 -57
  46. atomicshop/wrappers/pywin32w/wmis/win32_networkadapterconfiguration.py +12 -27
  47. atomicshop/wrappers/pywin32w/wmis/win32networkadapter.py +15 -9
  48. atomicshop/wrappers/socketw/certificator.py +19 -9
  49. atomicshop/wrappers/socketw/creator.py +30 -7
  50. atomicshop/wrappers/socketw/dns_server.py +6 -6
  51. atomicshop/wrappers/socketw/exception_wrapper.py +3 -3
  52. atomicshop/wrappers/socketw/process_getter.py +86 -0
  53. atomicshop/wrappers/socketw/receiver.py +29 -9
  54. atomicshop/wrappers/socketw/sender.py +10 -9
  55. atomicshop/wrappers/socketw/sni.py +23 -6
  56. atomicshop/wrappers/socketw/{base.py → socket_base.py} +33 -1
  57. atomicshop/wrappers/socketw/socket_client.py +6 -8
  58. atomicshop/wrappers/socketw/socket_wrapper.py +82 -21
  59. atomicshop/wrappers/socketw/ssl_base.py +6 -2
  60. atomicshop/wrappers/win_auditw.py +189 -0
  61. {atomicshop-3.3.28.dist-info → atomicshop-3.10.0.dist-info}/METADATA +25 -30
  62. {atomicshop-3.3.28.dist-info → atomicshop-3.10.0.dist-info}/RECORD +74 -88
  63. atomicshop/_basics_temp.py +0 -101
  64. atomicshop/a_installs/ubuntu/docker_rootless.py +0 -11
  65. atomicshop/a_installs/ubuntu/docker_sudo.py +0 -11
  66. atomicshop/addons/a_setup_scripts/install_psycopg2_ubuntu.sh +0 -3
  67. atomicshop/addons/package_setup/CreateWheel.cmd +0 -7
  68. atomicshop/addons/package_setup/Setup in Edit mode.cmd +0 -6
  69. atomicshop/addons/package_setup/Setup.cmd +0 -7
  70. atomicshop/archiver/__init__.py +0 -0
  71. atomicshop/archiver/_search_in_zip.py +0 -189
  72. atomicshop/archiver/search_in_archive.py +0 -284
  73. atomicshop/archiver/sevenz_app_w.py +0 -86
  74. atomicshop/archiver/sevenzs.py +0 -73
  75. atomicshop/archiver/shutils.py +0 -34
  76. atomicshop/archiver/zips.py +0 -353
  77. atomicshop/file_types.py +0 -24
  78. atomicshop/pbtkmultifile_argparse.py +0 -88
  79. atomicshop/script_as_string_processor.py +0 -42
  80. atomicshop/ssh_scripts/process_from_ipv4.py +0 -37
  81. atomicshop/ssh_scripts/process_from_port.py +0 -27
  82. atomicshop/wrappers/_process_wrapper_curl.py +0 -27
  83. atomicshop/wrappers/_process_wrapper_tar.py +0 -21
  84. atomicshop/wrappers/dockerw/install_docker.py +0 -449
  85. atomicshop/wrappers/ffmpegw.py +0 -125
  86. atomicshop/wrappers/process_wrapper_pbtk.py +0 -16
  87. atomicshop/wrappers/socketw/get_process.py +0 -123
  88. /atomicshop/{addons → a_mains/addons}/PlayWrightCodegen.cmd +0 -0
  89. /atomicshop/{addons → a_mains/addons}/ScriptExecution.cmd +0 -0
  90. /atomicshop/{addons → a_mains/addons}/inits/init_to_import_all_modules.py +0 -0
  91. /atomicshop/{addons → a_mains/addons}/process_list/ReadMe.txt +0 -0
  92. /atomicshop/{addons → a_mains/addons}/process_list/compile.cmd +0 -0
  93. /atomicshop/{addons → a_mains/addons}/process_list/compiled/Win10x64/process_list.dll +0 -0
  94. /atomicshop/{addons → a_mains/addons}/process_list/compiled/Win10x64/process_list.exp +0 -0
  95. /atomicshop/{addons → a_mains/addons}/process_list/compiled/Win10x64/process_list.lib +0 -0
  96. /atomicshop/{addons → a_mains/addons}/process_list/process_list.cpp +0 -0
  97. {atomicshop-3.3.28.dist-info → atomicshop-3.10.0.dist-info}/WHEEL +0 -0
  98. {atomicshop-3.3.28.dist-info → atomicshop-3.10.0.dist-info}/licenses/LICENSE.txt +0 -0
  99. {atomicshop-3.3.28.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
@@ -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
- enable: bool
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
- enable: bool
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
 
@@ -198,7 +173,7 @@ def get_listening_addresses(client_message: ClientMessage) -> dict | None:
198
173
  CONFIG_INI_TESTER_FILE_NAME: str = 'config_tester.ini'
199
174
 
200
175
  """
201
- config.ini:
176
+ config.toml:
202
177
  target_domain_or_ip: the domain or ip that the requests will be sent to. Better use domains, for better testing
203
178
  simulation.
204
179
  target_port: the port that requests will be sent to.