atomicshop 3.3.26__py3-none-any.whl → 3.3.28__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/mitm/mitm_main.py +7 -0
- atomicshop/ssh_remote.py +30 -95
- atomicshop/wrappers/socketw/socket_wrapper.py +0 -1
- {atomicshop-3.3.26.dist-info → atomicshop-3.3.28.dist-info}/METADATA +1 -1
- {atomicshop-3.3.26.dist-info → atomicshop-3.3.28.dist-info}/RECORD +9 -9
- {atomicshop-3.3.26.dist-info → atomicshop-3.3.28.dist-info}/WHEEL +0 -0
- {atomicshop-3.3.26.dist-info → atomicshop-3.3.28.dist-info}/licenses/LICENSE.txt +0 -0
- {atomicshop-3.3.26.dist-info → atomicshop-3.3.28.dist-info}/top_level.txt +0 -0
atomicshop/__init__.py
CHANGED
atomicshop/mitm/mitm_main.py
CHANGED
|
@@ -5,6 +5,7 @@ import datetime
|
|
|
5
5
|
import os
|
|
6
6
|
import sys
|
|
7
7
|
import logging
|
|
8
|
+
import signal
|
|
8
9
|
|
|
9
10
|
import atomicshop # Importing atomicshop package to get the version of the package.
|
|
10
11
|
|
|
@@ -95,6 +96,10 @@ except win_console.NotWindowsConsoleError:
|
|
|
95
96
|
pass
|
|
96
97
|
|
|
97
98
|
|
|
99
|
+
def _graceful_shutdown(signum, frame):
|
|
100
|
+
exit_cleanup()
|
|
101
|
+
|
|
102
|
+
|
|
98
103
|
def exit_cleanup():
|
|
99
104
|
if config_static.ENGINES_LIST[0].is_localhost:
|
|
100
105
|
if permissions.is_admin() and IS_SET_DNS_GATEWAY:
|
|
@@ -768,6 +773,8 @@ def _loop_at_midnight_recs_archive(network_logger_name):
|
|
|
768
773
|
|
|
769
774
|
|
|
770
775
|
def mitm_server_main(config_file_path: str, script_version: str):
|
|
776
|
+
signal.signal(signal.SIGINT, _graceful_shutdown)
|
|
777
|
+
|
|
771
778
|
try:
|
|
772
779
|
# Main function should return integer with error code, 0 is successful.
|
|
773
780
|
return mitm_server(config_file_path, script_version)
|
atomicshop/ssh_remote.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
import base64
|
|
3
|
-
import socket
|
|
4
3
|
import logging
|
|
5
4
|
from pathlib import Path
|
|
6
5
|
|
|
@@ -138,43 +137,6 @@ class SSHRemote:
|
|
|
138
137
|
def close(self):
|
|
139
138
|
self.ssh_client.close()
|
|
140
139
|
|
|
141
|
-
def exec_command_with_error_handling(self, script_string: str):
|
|
142
|
-
# Defining variables.
|
|
143
|
-
stdin = None
|
|
144
|
-
stdout = None
|
|
145
|
-
stderr = None
|
|
146
|
-
result_exception = None
|
|
147
|
-
|
|
148
|
-
# Don't put debugging break point over the next line in PyCharm. For some reason it gets stuck.
|
|
149
|
-
# Put the point right after that.
|
|
150
|
-
try:
|
|
151
|
-
stdin, stdout, stderr = self.ssh_client.exec_command(command=script_string, timeout=30)
|
|
152
|
-
except AttributeError as function_exception_object:
|
|
153
|
-
if function_exception_object.name == "open_session":
|
|
154
|
-
result_exception = "'SSHRemote().connect' wasn't executed."
|
|
155
|
-
print_api(result_exception, logger=self.logger, logger_method='error', traceback_string=True)
|
|
156
|
-
|
|
157
|
-
# Since getting Process name is not the main feature of the server, we can pass the exception
|
|
158
|
-
pass
|
|
159
|
-
else:
|
|
160
|
-
result_exception = f"Couldn't execute script over SSH. Unknown yet exception with 'AttributeError' " \
|
|
161
|
-
f"and name: {function_exception_object.name}"
|
|
162
|
-
print_api(result_exception, logger=self.logger, logger_method='error', traceback_string=True)
|
|
163
|
-
# Since getting Process name is not the main feature of the server, we can pass the exception
|
|
164
|
-
pass
|
|
165
|
-
except socket.error:
|
|
166
|
-
result_exception = "Couldn't execute script over SSH. SSH socket closed."
|
|
167
|
-
print_api(result_exception, logger=self.logger, logger_method='error', traceback_string=True)
|
|
168
|
-
# Since getting Process name is not the main feature of the server, we can pass the exception
|
|
169
|
-
pass
|
|
170
|
-
except Exception:
|
|
171
|
-
result_exception = "Couldn't execute script over SSH. Unknown yet exception."
|
|
172
|
-
print_api(result_exception, logger=self.logger, logger_method='error', traceback_string=True)
|
|
173
|
-
# Since getting Process name is not the main feature of the server, we can pass the exception
|
|
174
|
-
pass
|
|
175
|
-
|
|
176
|
-
return stdin, stdout, stderr, result_exception
|
|
177
|
-
|
|
178
140
|
@staticmethod
|
|
179
141
|
def check_console_output_for_errors(console_output_string: str):
|
|
180
142
|
# Defining variables.
|
|
@@ -192,52 +154,33 @@ class SSHRemote:
|
|
|
192
154
|
|
|
193
155
|
return function_result
|
|
194
156
|
|
|
195
|
-
def remote_execution(self, script_string: str):
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
function_error = None
|
|
199
|
-
stdin = None
|
|
200
|
-
stdout = None
|
|
201
|
-
stderr = None
|
|
202
|
-
exec_exception = None
|
|
157
|
+
def remote_execution(self, script_string: str) -> tuple[str, str]:
|
|
158
|
+
output_result: str = str()
|
|
159
|
+
error_result: str = str()
|
|
203
160
|
|
|
204
161
|
# Execute the command over SSH remotely.
|
|
205
|
-
|
|
206
|
-
#
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
#
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
# Joining error lines list to string if not empty.
|
|
229
|
-
if function_error:
|
|
230
|
-
function_error = ''.join(function_error)
|
|
231
|
-
# Else, joining output lines to string.
|
|
232
|
-
else:
|
|
233
|
-
output_lines = ''.join(output_lines)
|
|
234
|
-
|
|
235
|
-
# Since they're "file-like" objects we need to close them after we finished using.
|
|
236
|
-
stdin.close()
|
|
237
|
-
stdout.close()
|
|
238
|
-
stderr.close()
|
|
239
|
-
|
|
240
|
-
return output_lines, function_error
|
|
162
|
+
# Don't put debugging break point over the next line in PyCharm. For some reason it gets stuck.
|
|
163
|
+
# Put the point right after that.
|
|
164
|
+
stdin, stdout, stderr = self.ssh_client.exec_command(command=script_string, timeout=30)
|
|
165
|
+
|
|
166
|
+
# Reading the buffer of stdout.
|
|
167
|
+
output_lines: list = stdout.readlines()
|
|
168
|
+
# Reading the buffer of stderr.
|
|
169
|
+
error_lines: list = stderr.readlines()
|
|
170
|
+
|
|
171
|
+
# Joining error lines list to string if not empty.
|
|
172
|
+
if error_lines:
|
|
173
|
+
error_result: str = ''.join(error_lines)
|
|
174
|
+
# Else, joining output lines to string.
|
|
175
|
+
else:
|
|
176
|
+
output_result = ''.join(output_lines)
|
|
177
|
+
|
|
178
|
+
# Since they're "file-like" objects we need to close them after we finished using.
|
|
179
|
+
stdin.close()
|
|
180
|
+
stdout.close()
|
|
181
|
+
stderr.close()
|
|
182
|
+
|
|
183
|
+
return output_result, error_result
|
|
241
184
|
|
|
242
185
|
def remote_execution_python(self, script_string: str):
|
|
243
186
|
"""
|
|
@@ -277,8 +220,7 @@ class SSHRemote:
|
|
|
277
220
|
:return: SSH console output, Error output
|
|
278
221
|
"""
|
|
279
222
|
# Defining variables.
|
|
280
|
-
|
|
281
|
-
function_error = None
|
|
223
|
+
error_result: str | None = None
|
|
282
224
|
|
|
283
225
|
encoded_base64_string = base64.b64encode(script_string.encode('ascii'))
|
|
284
226
|
command_string: str = fr'python -c "import base64;exec(base64.b64decode({encoded_base64_string}))"'
|
|
@@ -295,14 +237,13 @@ class SSHRemote:
|
|
|
295
237
|
# If the message is known and didn't return empty.
|
|
296
238
|
if console_check:
|
|
297
239
|
# 'execution_error' variable will be that full error.
|
|
298
|
-
|
|
240
|
+
error_result = console_check
|
|
299
241
|
|
|
300
|
-
return remote_output,
|
|
242
|
+
return remote_output, error_result
|
|
301
243
|
|
|
302
244
|
def connect_get_client_commandline(self, script_string):
|
|
303
245
|
# Defining locals.
|
|
304
|
-
execution_output = None
|
|
305
|
-
execution_error = None
|
|
246
|
+
execution_output: str | None = None
|
|
306
247
|
|
|
307
248
|
# Making actual SSH Connection to the computer.
|
|
308
249
|
execution_error = self.connect()
|
|
@@ -316,13 +257,7 @@ class SSHRemote:
|
|
|
316
257
|
if not execution_error:
|
|
317
258
|
self.logger.info("Executing SSH command to acquire the calling process.")
|
|
318
259
|
|
|
319
|
-
|
|
320
|
-
execution_output, execution_error = self.remote_execution_python(script_string)
|
|
321
|
-
# Basically we don't care much about SSH exceptions. Just log them and pass to record.
|
|
322
|
-
except Exception as function_exception_object:
|
|
323
|
-
execution_error = function_exception_object
|
|
324
|
-
print_api(execution_error, logger=self.logger, logger_method='error', traceback_string=True)
|
|
325
|
-
pass
|
|
260
|
+
execution_output, execution_error = self.remote_execution_python(script_string)
|
|
326
261
|
|
|
327
262
|
# Closing SSH connection at this stage.
|
|
328
263
|
self.close()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
atomicshop/__init__.py,sha256=
|
|
1
|
+
atomicshop/__init__.py,sha256=7_vQ7ANOGXMGTntv4aMk8d8oVSTFzWJBQnvcLQHYyFw,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
|
|
@@ -37,7 +37,7 @@ atomicshop/scheduling.py,sha256=MvF20M6uU0Kh_CQn2ERxMTLvvF-ToBrdMhXNrKxYFj8,4682
|
|
|
37
37
|
atomicshop/script_as_string_processor.py,sha256=uAIWwhHE-eP2FniuwBqEiM6VzyQX96uwdE3aA31rIm8,1883
|
|
38
38
|
atomicshop/sound.py,sha256=tHiQQbFBk7EYN3pAfGNcxfF9oNsoYnZgu9z9iq8hxQE,24352
|
|
39
39
|
atomicshop/speech_recognize.py,sha256=55-dIjgkpF93mvJnJuxSFuft5H5eRvGNlUj9BeIOZxk,5903
|
|
40
|
-
atomicshop/ssh_remote.py,sha256
|
|
40
|
+
atomicshop/ssh_remote.py,sha256=6LUrFW-ZFMfQ52TmUxMVGcrVmMM3uqKaGKOY3lnEgFA,12480
|
|
41
41
|
atomicshop/sys_functions.py,sha256=MTBxRve5bh58SPvhX3gMiGqHlSBuI_rdNN1NnnBBWqI,906
|
|
42
42
|
atomicshop/system_resource_monitor.py,sha256=yHdBU4mAVqoVS0Nn_SM_H42i4PgsgXDaXaMxfnL5CgA,14588
|
|
43
43
|
atomicshop/system_resources.py,sha256=iKUvVSaXR47inmr3cTYsgNfclT38dRia2oupnlhIpK4,9290
|
|
@@ -130,7 +130,7 @@ atomicshop/mitm/connection_thread_worker.py,sha256=zPgDoIrZw6iIfjt_vwAYBanjOz23D
|
|
|
130
130
|
atomicshop/mitm/import_config.py,sha256=7aLfKqflc3ZnzKc2_Y4T0eenzQpKG94M0r-PaVwF99M,18881
|
|
131
131
|
atomicshop/mitm/initialize_engines.py,sha256=qzz5jzh_lKC03bI1w5ebngVXo1K-RV3poAyW-nObyqo,11042
|
|
132
132
|
atomicshop/mitm/message.py,sha256=CDhhm4BTuZE7oNZCjvIZ4BuPOW4MuIzQLOg91hJaxDI,3065
|
|
133
|
-
atomicshop/mitm/mitm_main.py,sha256=
|
|
133
|
+
atomicshop/mitm/mitm_main.py,sha256=C1lZr5-1yRUCtPgs8mBnt_bD7W1fNOweI45OpmlSOII,39501
|
|
134
134
|
atomicshop/mitm/recs_files.py,sha256=tv8XFhYZMkBv4DauvpiAdPgvSo0Bcm1CghnmwO7dx8M,5018
|
|
135
135
|
atomicshop/mitm/shared_functions.py,sha256=0lzeyINd44sVEfFbahJxQmz6KAMWbYrW5ou3UYfItvw,1777
|
|
136
136
|
atomicshop/mitm/statistic_analyzer.py,sha256=EC9g21ocOsFzNfntV-nZHSGtrS1-Kxb0QDSGWS5FuNA,28942
|
|
@@ -308,14 +308,14 @@ atomicshop/wrappers/socketw/sender.py,sha256=aX_K8l_rHjd5AWb8bi5mt8-YTkMYVRDB6Dn
|
|
|
308
308
|
atomicshop/wrappers/socketw/sni.py,sha256=uj6KKYKmSrzXcKBhVLaHQhYn1wNfIUpdnmcvn21V9iE,18176
|
|
309
309
|
atomicshop/wrappers/socketw/socket_client.py,sha256=WWIiCxUX9irN9aWzJ6-1xrXNB_iv_diq3ha1yrWsNGU,22671
|
|
310
310
|
atomicshop/wrappers/socketw/socket_server_tester.py,sha256=Qobmh4XV8ZxLUaw-eW4ESKAbeSLecCKn2OWFzMhadk0,6420
|
|
311
|
-
atomicshop/wrappers/socketw/socket_wrapper.py,sha256=
|
|
311
|
+
atomicshop/wrappers/socketw/socket_wrapper.py,sha256=abvs3Jb7PZ6H5il0Yto6gCLkwY5tD40f0GYOzZVb8ng,42581
|
|
312
312
|
atomicshop/wrappers/socketw/ssl_base.py,sha256=62-hPm7zla1rh3m_WvDnXqKH-sDUTdiRptD8STCkgdk,2313
|
|
313
313
|
atomicshop/wrappers/socketw/statistics_csv.py,sha256=_gA8bMX6Sw_UCXKi2y9wNAwlqifgExgDGfQIa9pFxQA,5543
|
|
314
314
|
atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
315
315
|
atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
|
|
316
316
|
atomicshop/wrappers/winregw/winreg_network.py,sha256=ih0BVNwByLvf9F_Lac4EdmDYYJA3PzMvmG0PieDZrsE,9905
|
|
317
|
-
atomicshop-3.3.
|
|
318
|
-
atomicshop-3.3.
|
|
319
|
-
atomicshop-3.3.
|
|
320
|
-
atomicshop-3.3.
|
|
321
|
-
atomicshop-3.3.
|
|
317
|
+
atomicshop-3.3.28.dist-info/licenses/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
|
|
318
|
+
atomicshop-3.3.28.dist-info/METADATA,sha256=mpQNhoVSvg9_AcIj-Qot4Kpvk_LrNOXujfo9ctQbzbA,9318
|
|
319
|
+
atomicshop-3.3.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
320
|
+
atomicshop-3.3.28.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
|
|
321
|
+
atomicshop-3.3.28.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|