atomicshop 2.17.2__py3-none-any.whl → 2.17.3__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 CHANGED
@@ -1,4 +1,4 @@
1
1
  """Atomic Basic functions and classes to make developer life easier"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '2.17.2'
4
+ __version__ = '2.17.3'
@@ -123,6 +123,7 @@ class LogRec:
123
123
 
124
124
  @dataclass
125
125
  class Certificates:
126
+ enable_sslkeylogfile_env_to_client_ssl_context: bool
126
127
  install_ca_certificate_to_root_store: bool
127
128
  uninstall_unused_ca_certificates_with_mitm_ca_name: bool
128
129
 
@@ -210,12 +210,15 @@ def thread_worker_main(
210
210
  # config['tcp']['forwarding_dns_service_ipv4_list___only_for_localhost']
211
211
  if client_message.client_ip in base.THIS_DEVICE_IP_LIST:
212
212
  service_client_instance = socket_client.SocketClient(
213
- service_name=client_message.server_name, service_port=client_message.destination_port,
213
+ service_name=client_message.server_name,
214
+ service_port=client_message.destination_port,
214
215
  tls=is_tls,
215
216
  dns_servers_list=(
216
217
  config_static.TCPServer.forwarding_dns_service_ipv4_list___only_for_localhost),
217
218
  logger=network_logger,
218
- custom_pem_client_certificate_file_path=custom_client_pem_certificate_path
219
+ custom_pem_client_certificate_file_path=custom_client_pem_certificate_path,
220
+ enable_sslkeylogfile_env_to_client_ssl_context=(
221
+ config_static.Certificates.enable_sslkeylogfile_env_to_client_ssl_context)
219
222
  )
220
223
  # If we're not on localhost, then connect to domain directly.
221
224
  else:
@@ -224,7 +227,9 @@ def thread_worker_main(
224
227
  service_port=client_message.destination_port,
225
228
  tls=is_tls,
226
229
  logger=network_logger,
227
- custom_pem_client_certificate_file_path=custom_client_pem_certificate_path
230
+ custom_pem_client_certificate_file_path=custom_client_pem_certificate_path,
231
+ enable_sslkeylogfile_env_to_client_ssl_context=(
232
+ config_static.Certificates.enable_sslkeylogfile_env_to_client_ssl_context)
228
233
  )
229
234
 
230
235
  return service_client_instance
@@ -1,3 +1,4 @@
1
+ import os
1
2
  import socket
2
3
  import ssl
3
4
 
@@ -33,8 +34,31 @@ def create_ssl_context_for_server():
33
34
  # return ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
34
35
 
35
36
 
36
- def create_ssl_context_for_client():
37
- return ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
37
+ def create_ssl_context_for_client(
38
+ enable_sslkeylogfile_env_to_client_ssl_context: bool = False
39
+ ) -> ssl.SSLContext:
40
+ """
41
+ This function creates the SSL context for the client.
42
+ The SSL context is created with the "PROTOCOL_TLS_CLIENT" protocol.
43
+
44
+ :param enable_sslkeylogfile_env_to_client_ssl_context: boolean, enables the SSLKEYLOGFILE environment variable
45
+ to the SSL context. Default is False.
46
+ if True, SSLKEYLOGFILE will be added to SSL context with:
47
+ ssl_context.keylog_filename = os.environ.get('SSLKEYLOGFILE')
48
+ This is useful for debugging SSL/TLS connections with WireShark.
49
+ Since WireShark also uses this environment variable to read the key log file and apply to the SSL/TLS
50
+ connections, so you can see the decrypted traffic.
51
+
52
+ :return: ssl.SSLContext
53
+ """
54
+ ssl_context: ssl.SSLContext = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
55
+
56
+ if enable_sslkeylogfile_env_to_client_ssl_context:
57
+ ssl_key_logfile = os.environ.get('SSLKEYLOGFILE')
58
+ if ssl_key_logfile:
59
+ ssl_context.keylog_filename = ssl_key_logfile
60
+
61
+ return ssl_context
38
62
 
39
63
 
40
64
  def set_client_ssl_context_ca_default_certs(ssl_context):
@@ -204,7 +228,8 @@ def set_listen_on_socket(socket_object, **kwargs):
204
228
  def wrap_socket_with_ssl_context_client___default_certs___ignore_verification(
205
229
  socket_object,
206
230
  server_hostname: str = None,
207
- custom_pem_client_certificate_file_path: str = None
231
+ custom_pem_client_certificate_file_path: str = None,
232
+ enable_sslkeylogfile_env_to_client_ssl_context: bool = False
208
233
  ):
209
234
  """
210
235
  This function is a preset for wrapping the socket with SSL context for the client.
@@ -214,8 +239,11 @@ def wrap_socket_with_ssl_context_client___default_certs___ignore_verification(
214
239
  :param server_hostname: string, hostname of the server. Default is None.
215
240
  :param custom_pem_client_certificate_file_path: string, full file path for the client certificate PWM file.
216
241
  Default is None.
242
+ :param enable_sslkeylogfile_env_to_client_ssl_context: boolean, enables the SSLKEYLOGFILE environment variable
243
+ to the SSL context. Default is False.
217
244
  """
218
- ssl_context: ssl.SSLContext = create_ssl_context_for_client()
245
+ ssl_context: ssl.SSLContext = create_ssl_context_for_client(
246
+ enable_sslkeylogfile_env_to_client_ssl_context=enable_sslkeylogfile_env_to_client_ssl_context)
219
247
  set_client_ssl_context_ca_default_certs(ssl_context)
220
248
  set_client_ssl_context_certificate_verification_ignore(ssl_context)
221
249
 
@@ -54,6 +54,7 @@ class SNISetup:
54
54
  self.default_server_certificate_name = default_server_certificate_name
55
55
  self.default_server_certificate_directory = default_server_certificate_directory
56
56
  self.default_certificate_domain_list = default_certificate_domain_list
57
+ self.enable_sslkeylogfile_to_ssl_context: bool = enable_sslkeylogfile_to_ssl_context
57
58
  self.sni_custom_callback_function: callable = sni_custom_callback_function
58
59
  self.sni_use_default_callback_function: bool = sni_use_default_callback_function
59
60
  self.sni_use_default_callback_function_extended: bool = sni_use_default_callback_function_extended
@@ -30,7 +30,8 @@ class SocketClient:
30
30
  connection_ip=None,
31
31
  dns_servers_list=None,
32
32
  logger: logging.Logger = None,
33
- custom_pem_client_certificate_file_path: str = None
33
+ custom_pem_client_certificate_file_path: str = None,
34
+ enable_sslkeylogfile_env_to_client_ssl_context: bool = False
34
35
  ):
35
36
  """
36
37
  If you have a certificate for domain, but not for the IPv4 address, the SSL Socket context can be created for
@@ -50,6 +51,13 @@ class SocketClient:
50
51
  :param logger: (Optional) Logger object. If not provided, the default logger will be used.
51
52
  :param custom_pem_client_certificate_file_path: (Optional) If specified, the SSL Socket will be created with
52
53
  custom client certificate. The path to the file with the certificate should be provided.
54
+ :param enable_sslkeylogfile_env_to_client_ssl_context: boolean, enables the SSLKEYLOGFILE environment variable
55
+ to the SSL context. Default is False.
56
+ if True, SSLKEYLOGFILE will be added to SSL context with:
57
+ ssl_context.keylog_filename = os.environ.get('SSLKEYLOGFILE')
58
+ This is useful for debugging SSL/TLS connections with WireShark.
59
+ Since WireShark also uses this environment variable to read the key log file and apply to the SSL/TLS
60
+ connections, so you can see the decrypted traffic.
53
61
 
54
62
  If both 'connection_ip' and 'dns_servers_list' specified, ValueException with raise.
55
63
  """
@@ -59,6 +67,7 @@ class SocketClient:
59
67
  self.connection_ip = connection_ip
60
68
  self.dns_servers_list = dns_servers_list
61
69
  self.custom_pem_client_certificate_file_path: str = custom_pem_client_certificate_file_path
70
+ self.enable_sslkeylogfile_env_to_client_ssl_context: bool = enable_sslkeylogfile_env_to_client_ssl_context
62
71
 
63
72
  if logger:
64
73
  # Create child logger for the provided logger with the module's name.
@@ -91,7 +100,9 @@ class SocketClient:
91
100
  print_api.print_api(log_message, logger=self.logger, logger_method='info')
92
101
  socket_object = creator.create_socket_ipv4_tcp()
93
102
  return creator.wrap_socket_with_ssl_context_client___default_certs___ignore_verification(
94
- socket_object, self.service_name, self.custom_pem_client_certificate_file_path)
103
+ socket_object, self.service_name, self.custom_pem_client_certificate_file_path,
104
+ enable_sslkeylogfile_env_to_client_ssl_context=self.enable_sslkeylogfile_env_to_client_ssl_context
105
+ )
95
106
 
96
107
  def service_connection(
97
108
  self
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.17.2
3
+ Version: 2.17.3
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License: MIT License
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=fZxhx9GigOSbMFUY_dyKq_MeAvWRB0kkmUwCZ3ILy2A,123
1
+ atomicshop/__init__.py,sha256=T9jtW2aWDvJvFYaGUUorjlEM5yR1Lx48uobqDYGwsHY,123
2
2
  atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
3
3
  atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
4
4
  atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
@@ -125,9 +125,9 @@ atomicshop/file_io/tomls.py,sha256=ol8EvQPf9sryTmZUf1v55BYSUQ6ml7HVVBHpNKbsIlA,9
125
125
  atomicshop/file_io/xlsxs.py,sha256=v_dyg9GD4LqgWi6wA1QuWRZ8zG4ZwB6Dz52ytdcmmmI,2184
126
126
  atomicshop/file_io/xmls.py,sha256=zh3SuK-dNaFq2NDNhx6ivcf4GYCfGM8M10PcEwDSpxk,2104
127
127
  atomicshop/mitm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
128
- atomicshop/mitm/config_static.py,sha256=ROAtbibSWSsF3BraUbhu-QO3MPIFqYY5KUKgsQbiSkk,7813
128
+ atomicshop/mitm/config_static.py,sha256=r6M4FJVBr9jGIXmjcOk2KBHvCPelWcbZCQrRh3-G26k,7871
129
129
  atomicshop/mitm/config_toml_editor.py,sha256=2p1CMcktWRR_NW-SmyDwylu63ad5e0-w1QPMa8ZLDBw,1635
130
- atomicshop/mitm/connection_thread_worker.py,sha256=EtEp6aymfQ-btZzeZDmxLJdIortB4Gf5MOaHwEFSShI,21095
130
+ atomicshop/mitm/connection_thread_worker.py,sha256=nbCQNQwJFoBnXTmIXvqpL6Jq2Q28uTn4FRaoCZZdrHA,21438
131
131
  atomicshop/mitm/import_config.py,sha256=0Ij14aISTllTOiWYJpIUMOWobQqGofD6uafui5uWllE,9272
132
132
  atomicshop/mitm/initialize_engines.py,sha256=NWz0yBErSrYBn0xWkJDBcHStBJ-kcsv9VtorcSP9x5M,8258
133
133
  atomicshop/mitm/message.py,sha256=URR5JKSuAT8XmGIkyprEjlPW2GW4ef_gfUz_GgcFseE,2184
@@ -305,22 +305,22 @@ atomicshop/wrappers/socketw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
305
305
  atomicshop/wrappers/socketw/accepter.py,sha256=hZZKVYlF3LOHQJsSIEKXZUf6QXXWm-AtqXZevvaYigE,1732
306
306
  atomicshop/wrappers/socketw/base.py,sha256=DV6BWao9kiLAWimhVDKGEi3ISVaWk5iPHXtBHrO3uwc,2264
307
307
  atomicshop/wrappers/socketw/certificator.py,sha256=mtWPJ_ew3OSwt0-1W4jaoco1VIY4NRCrMv3mDUxb_Cc,12418
308
- atomicshop/wrappers/socketw/creator.py,sha256=OLcd7FyUk_k8iyoL-xYnCnNmolPSgio6OeQXth7NdLg,11414
308
+ atomicshop/wrappers/socketw/creator.py,sha256=zMWLsOF07vX-xQZR720LeHQVndUT8q-ytdCrKF5tt9I,12835
309
309
  atomicshop/wrappers/socketw/dns_server.py,sha256=RklzINNuoMQn4PGGQEI5hiAldprbVwwvikY6u9X-jTY,49067
310
310
  atomicshop/wrappers/socketw/exception_wrapper.py,sha256=B-X5SHLSUIWToihH2MKnOB1F4A81_X0DpLLfnYKYbEc,7067
311
311
  atomicshop/wrappers/socketw/get_process.py,sha256=aJC-_qFUv3NgWCSUzDI72E4z8_-VTZE9NVZ0CwUoNlM,5698
312
312
  atomicshop/wrappers/socketw/receiver.py,sha256=-QtKK0T_lmoAIypTYaIKOD3pgB1npWGPxcVEN37y_gk,10060
313
313
  atomicshop/wrappers/socketw/sender.py,sha256=gwSzF51QD5paeeFav6fpbQpO8KgBO5lNztHYQyN5id0,4959
314
- atomicshop/wrappers/socketw/sni.py,sha256=Nc8WMZZR21o5GXILQLVWbf7OzNPXAfE8trJY153e9Qk,17591
315
- atomicshop/wrappers/socketw/socket_client.py,sha256=YUlwbasxYQqz1xUlPWxwEnSDSCYKGdxWb2CFAogefr8,21131
314
+ atomicshop/wrappers/socketw/sni.py,sha256=28xpmGawMvO2wpeqpBPtxpX6cX661_CXqPElRAyLj-0,17685
315
+ atomicshop/wrappers/socketw/socket_client.py,sha256=qwEV4HSMiROPk5VOY6kj_3k00tCIN8c0rZh3fjpSBno,22027
316
316
  atomicshop/wrappers/socketw/socket_server_tester.py,sha256=Qobmh4XV8ZxLUaw-eW4ESKAbeSLecCKn2OWFzMhadk0,6420
317
317
  atomicshop/wrappers/socketw/socket_wrapper.py,sha256=WtylpezgIIBuz-A6PfM0hO1sm9Exd4j3qhDXcFc74-E,35567
318
318
  atomicshop/wrappers/socketw/ssl_base.py,sha256=kmiif84kMhBr5yjQW17p935sfjR5JKG0LxIwBA4iVvU,2275
319
319
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=SDYI1cN0oaapvPeLxSXiJrelTy6xbZl-bopR0jAjVGE,3149
320
320
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
321
321
  atomicshop/wrappers/winregw/winreg_network.py,sha256=zZQfps-CdODQaTUADbHAwKHr5RUg7BLafnKWBbKaLN4,8728
322
- atomicshop-2.17.2.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
323
- atomicshop-2.17.2.dist-info/METADATA,sha256=zpoROqa6g64vizJD01vVwLmwAaztvWVl_nmBKaceXL4,10499
324
- atomicshop-2.17.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
325
- atomicshop-2.17.2.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
326
- atomicshop-2.17.2.dist-info/RECORD,,
322
+ atomicshop-2.17.3.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
323
+ atomicshop-2.17.3.dist-info/METADATA,sha256=LHsnD_4t56XniePIJ4iTVrrCfWOpqDoLxXG3kxNXvJw,10499
324
+ atomicshop-2.17.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
325
+ atomicshop-2.17.3.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
326
+ atomicshop-2.17.3.dist-info/RECORD,,