atomicshop 2.11.47__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/addons/process_list/compile.cmd +7 -0
- atomicshop/a_mains/addons/process_list/compiled/Win10x64/process_list.dll +0 -0
- atomicshop/a_mains/addons/process_list/compiled/Win10x64/process_list.exp +0 -0
- atomicshop/a_mains/addons/process_list/compiled/Win10x64/process_list.lib +0 -0
- atomicshop/{addons → a_mains/addons}/process_list/process_list.cpp +8 -1
- 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/{addons/mains → a_mains}/msi_unpacker.py +3 -1
- 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/appointment_management.py +5 -3
- 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/dicts.py +12 -0
- atomicshop/basics/enums.py +2 -2
- atomicshop/basics/exceptions.py +5 -1
- atomicshop/basics/list_of_classes.py +29 -0
- atomicshop/basics/list_of_dicts.py +69 -5
- atomicshop/basics/lists.py +14 -0
- atomicshop/basics/multiprocesses.py +374 -50
- atomicshop/basics/package_module.py +10 -0
- atomicshop/basics/strings.py +160 -7
- atomicshop/basics/threads.py +14 -0
- atomicshop/basics/tracebacks.py +13 -4
- atomicshop/certificates.py +153 -52
- atomicshop/config_init.py +12 -7
- atomicshop/console_user_response.py +7 -14
- atomicshop/consoles.py +9 -0
- atomicshop/datetimes.py +98 -0
- atomicshop/diff_check.py +340 -40
- atomicshop/dns.py +128 -12
- atomicshop/etws/_pywintrace_fix.py +17 -0
- atomicshop/etws/const.py +38 -0
- atomicshop/etws/providers.py +21 -0
- atomicshop/etws/sessions.py +43 -0
- atomicshop/etws/trace.py +168 -0
- atomicshop/etws/traces/trace_dns.py +162 -0
- atomicshop/etws/traces/trace_sysmon_process_creation.py +126 -0
- atomicshop/etws/traces/trace_tcp.py +130 -0
- atomicshop/file_io/csvs.py +222 -24
- atomicshop/file_io/docxs.py +35 -18
- atomicshop/file_io/file_io.py +35 -19
- atomicshop/file_io/jsons.py +49 -0
- atomicshop/file_io/tomls.py +139 -0
- atomicshop/filesystem.py +864 -293
- atomicshop/get_process_list.py +133 -0
- atomicshop/{process_name_cmd.py → get_process_name_cmd_dll.py} +52 -19
- 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 -74
- 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 +257 -166
- atomicshop/mitm/statistic_analyzer_helper/analyzer_helper.py +136 -0
- atomicshop/mitm/statistic_analyzer_helper/moving_average_helper.py +525 -0
- atomicshop/monitor/change_monitor.py +96 -120
- atomicshop/monitor/checks/dns.py +139 -70
- atomicshop/monitor/checks/file.py +77 -0
- atomicshop/monitor/checks/network.py +81 -77
- atomicshop/monitor/checks/process_running.py +33 -34
- atomicshop/monitor/checks/url.py +94 -0
- atomicshop/networks.py +671 -0
- atomicshop/on_exit.py +205 -0
- 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 -41
- atomicshop/process.py +63 -17
- atomicshop/process_poller/__init__.py +0 -0
- atomicshop/process_poller/pollers/__init__.py +0 -0
- atomicshop/process_poller/pollers/psutil_pywin32wmi_dll.py +95 -0
- atomicshop/process_poller/process_pool.py +207 -0
- atomicshop/process_poller/simple_process_pool.py +311 -0
- atomicshop/process_poller/tracer_base.py +45 -0
- atomicshop/process_poller/tracers/__init__.py +0 -0
- atomicshop/process_poller/tracers/event_log.py +46 -0
- atomicshop/process_poller/tracers/sysmon_etw.py +68 -0
- atomicshop/python_file_patcher.py +1 -1
- atomicshop/python_functions.py +27 -75
- atomicshop/question_answer_engine.py +2 -2
- atomicshop/scheduling.py +24 -5
- atomicshop/sound.py +4 -2
- atomicshop/speech_recognize.py +8 -0
- atomicshop/ssh_remote.py +158 -172
- atomicshop/startup/__init__.py +0 -0
- atomicshop/startup/win/__init__.py +0 -0
- atomicshop/startup/win/startup_folder.py +53 -0
- atomicshop/startup/win/task_scheduler.py +119 -0
- atomicshop/system_resource_monitor.py +61 -46
- atomicshop/system_resources.py +8 -8
- atomicshop/tempfiles.py +1 -2
- atomicshop/timer.py +30 -11
- atomicshop/urls.py +41 -0
- atomicshop/venvs.py +28 -0
- atomicshop/versioning.py +27 -0
- atomicshop/web.py +110 -25
- atomicshop/web_apis/__init__.py +0 -0
- 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/__init__.py +0 -0
- atomicshop/wrappers/ctyping/etw_winapi/const.py +335 -0
- atomicshop/wrappers/ctyping/etw_winapi/etw_functions.py +393 -0
- 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 +13 -9
- atomicshop/wrappers/ctyping/msi_windows_installer/tables.py +35 -0
- 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/factw/postgresql/firmware.py +4 -6
- atomicshop/wrappers/githubw.py +583 -51
- atomicshop/wrappers/loggingw/consts.py +49 -0
- atomicshop/wrappers/loggingw/filters.py +102 -0
- atomicshop/wrappers/loggingw/formatters.py +58 -71
- atomicshop/wrappers/loggingw/handlers.py +459 -40
- atomicshop/wrappers/loggingw/loggers.py +19 -0
- atomicshop/wrappers/loggingw/loggingw.py +1010 -178
- atomicshop/wrappers/loggingw/reading.py +344 -19
- atomicshop/wrappers/mongodbw/__init__.py +0 -0
- atomicshop/wrappers/mongodbw/mongo_infra.py +31 -0
- atomicshop/wrappers/mongodbw/mongodbw.py +1432 -0
- 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 +81 -0
- atomicshop/wrappers/psutilw/psutil_networks.py +85 -0
- atomicshop/wrappers/psutilw/psutilw.py +9 -0
- atomicshop/wrappers/pyopensslw.py +9 -2
- atomicshop/wrappers/pywin32w/__init__.py +0 -0
- atomicshop/wrappers/pywin32w/cert_store.py +116 -0
- atomicshop/wrappers/pywin32w/console.py +34 -0
- atomicshop/wrappers/pywin32w/win_event_log/__init__.py +0 -0
- atomicshop/wrappers/pywin32w/win_event_log/fetch.py +174 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribe.py +212 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/__init__.py +0 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_create.py +57 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_terminate.py +49 -0
- atomicshop/wrappers/pywin32w/win_event_log/subscribes/schannel_logging.py +97 -0
- atomicshop/wrappers/pywin32w/winshell.py +19 -0
- atomicshop/wrappers/pywin32w/wmis/__init__.py +0 -0
- 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 +500 -173
- 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 +14 -9
- 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 +157 -0
- 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.11.47.dist-info → atomicshop-3.10.5.dist-info}/METADATA +31 -49
- atomicshop-3.10.5.dist-info/RECORD +306 -0
- {atomicshop-2.11.47.dist-info → atomicshop-3.10.5.dist-info}/WHEEL +1 -1
- atomicshop/_basics_temp.py +0 -101
- 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/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/addons/process_list/compile.cmd +0 -2
- atomicshop/addons/process_list/compiled/Win10x64/process_list.dll +0 -0
- atomicshop/addons/process_list/compiled/Win10x64/process_list.exp +0 -0
- atomicshop/addons/process_list/compiled/Win10x64/process_list.lib +0 -0
- 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/etw/dns_trace.py +0 -118
- atomicshop/etw/etw.py +0 -61
- atomicshop/file_types.py +0 -24
- atomicshop/mitm/engines/create_module_template_example.py +0 -13
- atomicshop/mitm/initialize_mitm_server.py +0 -240
- atomicshop/monitor/checks/hash.py +0 -44
- atomicshop/monitor/checks/hash_checks/file.py +0 -55
- atomicshop/monitor/checks/hash_checks/url.py +0 -62
- atomicshop/pbtkmultifile_argparse.py +0 -88
- atomicshop/permissions.py +0 -110
- atomicshop/process_poller.py +0 -237
- 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/loggingw/checks.py +0 -20
- atomicshop/wrappers/nodejsw/install_nodejs.py +0 -139
- atomicshop/wrappers/process_wrapper_pbtk.py +0 -16
- atomicshop/wrappers/socketw/base.py +0 -59
- atomicshop/wrappers/socketw/get_process.py +0 -107
- atomicshop/wrappers/wslw.py +0 -191
- atomicshop-2.11.47.dist-info/RECORD +0 -251
- /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/mains → 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/mains → a_mains}/search_for_hyperlinks_in_docx.py +0 -0
- /atomicshop/{archiver → etws}/__init__.py +0 -0
- /atomicshop/{etw → etws/traces}/__init__.py +0 -0
- /atomicshop/{monitor/checks/hash_checks → mitm/statistic_analyzer_helper}/__init__.py +0 -0
- /atomicshop/{wrappers/nodejsw → permissions}/__init__.py +0 -0
- /atomicshop/wrappers/pywin32w/{wmi_win32process.py → wmis/win32process.py} +0 -0
- {atomicshop-2.11.47.dist-info → atomicshop-3.10.5.dist-info/licenses}/LICENSE.txt +0 -0
- {atomicshop-2.11.47.dist-info → atomicshop-3.10.5.dist-info}/top_level.txt +0 -0
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import subprocess
|
|
2
|
-
import requests
|
|
3
|
-
|
|
4
|
-
from ...basics import booleans
|
|
5
|
-
from .. import githubw, ubuntu_terminal
|
|
6
|
-
from ...print_api import print_api
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def is_nodejs_installed():
|
|
10
|
-
"""
|
|
11
|
-
The function will check if Node.js is installed.
|
|
12
|
-
:return: bool.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
try:
|
|
16
|
-
# Run the command 'node -v'
|
|
17
|
-
result = subprocess.run(['node', '-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
18
|
-
|
|
19
|
-
# Check if the command was successful
|
|
20
|
-
if result.returncode == 0:
|
|
21
|
-
message = f"Node.js installed. Version: {result.stdout.strip()}"
|
|
22
|
-
print_api(message, color='green')
|
|
23
|
-
return True
|
|
24
|
-
else:
|
|
25
|
-
print_api("Node.js is not installed.")
|
|
26
|
-
return False
|
|
27
|
-
except FileNotFoundError:
|
|
28
|
-
print_api("Node command not found. Node.js is not installed.")
|
|
29
|
-
return False
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def get_nodejs_latest_version_number(
|
|
33
|
-
by_github_api: bool = True,
|
|
34
|
-
_by_nodejs_website: bool = False,
|
|
35
|
-
get_major: bool = False
|
|
36
|
-
) -> str:
|
|
37
|
-
"""
|
|
38
|
-
The function will get the latest version number of Node.js.
|
|
39
|
-
:param by_github_api: bool, if True, the function will get the version number using the GitHub API.
|
|
40
|
-
Limitations: rate limits apply.
|
|
41
|
-
:param _by_nodejs_website: bool, if True, the function will get the version number using the Node.js website.
|
|
42
|
-
Limitations: the website structure can change and the json file is relatively large.
|
|
43
|
-
This is only for reference, it is not tested.
|
|
44
|
-
:param get_major: bool, if True, the function will return only the major version number string.
|
|
45
|
-
:return: str.
|
|
46
|
-
"""
|
|
47
|
-
|
|
48
|
-
if by_github_api and _by_nodejs_website:
|
|
49
|
-
raise ValueError("Only one of the arguments can be True.")
|
|
50
|
-
elif not by_github_api and not _by_nodejs_website:
|
|
51
|
-
raise ValueError("At least one of the arguments must be True.")
|
|
52
|
-
|
|
53
|
-
latest_version = ''
|
|
54
|
-
if by_github_api:
|
|
55
|
-
github_wrapper = githubw.GitHubWrapper('nodejs', 'node')
|
|
56
|
-
latest_version = github_wrapper.get_the_latest_release_version_number()
|
|
57
|
-
elif _by_nodejs_website:
|
|
58
|
-
url = "https://nodejs.org/dist/index.json"
|
|
59
|
-
response = requests.get(url)
|
|
60
|
-
versions = response.json()
|
|
61
|
-
latest_version = versions[0]['version'] # Assuming the first one is the latest.
|
|
62
|
-
|
|
63
|
-
if get_major:
|
|
64
|
-
latest_version = latest_version.replace('v', '')
|
|
65
|
-
latest_version = latest_version.split('.')[0]
|
|
66
|
-
|
|
67
|
-
return latest_version
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def install_nodejs_ubuntu(
|
|
71
|
-
install_latest_version: bool = False,
|
|
72
|
-
install_lts: bool = True,
|
|
73
|
-
install_by_version_number: str = None,
|
|
74
|
-
force_install: bool = False
|
|
75
|
-
):
|
|
76
|
-
"""
|
|
77
|
-
The function will install Node.js on Ubuntu.
|
|
78
|
-
|
|
79
|
-
:param install_latest_version: bool, if True, the function will install the latest version of Node.js.
|
|
80
|
-
:param install_lts: bool, if True, the function will install the LTS version of Node.js.
|
|
81
|
-
:param install_by_version_number: str, the version number of Node.js to install.
|
|
82
|
-
:param force_install: bool, if True, the function will install Node.js even if it is already installed.
|
|
83
|
-
|
|
84
|
-
:return:
|
|
85
|
-
"""
|
|
86
|
-
|
|
87
|
-
booleans.check_3_booleans_when_only_1_can_be_true(
|
|
88
|
-
(install_latest_version, 'install_latest_version'),
|
|
89
|
-
(install_lts, 'install_lts'),
|
|
90
|
-
(install_by_version_number, 'install_by_version_number')
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
# Check if Node.js is already installed.
|
|
94
|
-
if is_nodejs_installed():
|
|
95
|
-
if not force_install:
|
|
96
|
-
return
|
|
97
|
-
|
|
98
|
-
# NodeSource is listed as source under official Node.js GitHub repository:
|
|
99
|
-
# https://github.com/nodejs/node?tab=readme-ov-file#current-and-lts-releases
|
|
100
|
-
print_api("Adding NodeSource repository...")
|
|
101
|
-
|
|
102
|
-
# Fetch and execute the NodeSource repository setup script.
|
|
103
|
-
if install_latest_version:
|
|
104
|
-
install_by_version_number: str = get_nodejs_latest_version_number(get_major=True)
|
|
105
|
-
|
|
106
|
-
command: str = ''
|
|
107
|
-
if install_latest_version or install_by_version_number:
|
|
108
|
-
command = f"curl -fsSL https://deb.nodesource.com/setup_{install_by_version_number}.x | sudo -E bash -"
|
|
109
|
-
elif install_lts:
|
|
110
|
-
command = "curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -"
|
|
111
|
-
|
|
112
|
-
_ = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
|
|
113
|
-
|
|
114
|
-
ubuntu_terminal.update_system_packages()
|
|
115
|
-
ubuntu_terminal.install_packages(['nodejs'])
|
|
116
|
-
|
|
117
|
-
# Check if Node.js is installed.
|
|
118
|
-
is_nodejs_installed()
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def install_npm_package_ubuntu(package_name: str, sudo: bool = True):
|
|
122
|
-
"""
|
|
123
|
-
The function will install a npm package on Ubuntu.
|
|
124
|
-
:param package_name: str, the name of the package to install.
|
|
125
|
-
:param sudo: bool, if True, the function will use sudo.
|
|
126
|
-
NPM commands require sudo to install global packages.
|
|
127
|
-
:return:
|
|
128
|
-
"""
|
|
129
|
-
|
|
130
|
-
# Check if Node.js is installed.
|
|
131
|
-
if not is_nodejs_installed():
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
command = f"npm install -g {package_name}"
|
|
135
|
-
|
|
136
|
-
if sudo:
|
|
137
|
-
command = f"sudo {command}"
|
|
138
|
-
|
|
139
|
-
_ = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
from atomicshop.process import execute_with_live_output
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def execute_pbtk(pbtk_path: str, file_path: str, target_directory: str) -> None:
|
|
5
|
-
"""
|
|
6
|
-
The function receives file path and target filesystem directory to extract the files.
|
|
7
|
-
|
|
8
|
-
:param pbtk_path: full path to pbtk file.
|
|
9
|
-
:param file_path: full path to binary file.
|
|
10
|
-
:param target_directory: The directory on the filesystem to extract files.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
cmd: str = f'python "{pbtk_path}" "{file_path}" "{target_directory}"'
|
|
14
|
-
print(f'Scanning: {file_path}')
|
|
15
|
-
|
|
16
|
-
output_list = execute_with_live_output(cmd=cmd)
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import socket
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def get_local_network_interfaces_ip_address(family_type: str = None, ip_only: bool = False) -> list:
|
|
5
|
-
"""
|
|
6
|
-
Return list of IP addresses of local network interfaces.
|
|
7
|
-
|
|
8
|
-
:param family_type: string, available options:
|
|
9
|
-
None: default, returns both ipv4 and ipv6 addresses.
|
|
10
|
-
"ipv4": returns only ipv4 addresses.
|
|
11
|
-
"ipv6": returns only ipv6 addresses.
|
|
12
|
-
:param ip_only: bool, if True, returns only IP addresses, if False, returns tuples with all objects.
|
|
13
|
-
:return: list.
|
|
14
|
-
"""
|
|
15
|
-
family: int = 0
|
|
16
|
-
if not family_type:
|
|
17
|
-
family = 0
|
|
18
|
-
elif family_type == "ipv4":
|
|
19
|
-
family = socket.AF_INET
|
|
20
|
-
elif family_type == "ipv6":
|
|
21
|
-
family = socket.AF_INET6
|
|
22
|
-
|
|
23
|
-
network_interfaces_tuples = list(socket.getaddrinfo(socket.gethostname(), None, family=family))
|
|
24
|
-
|
|
25
|
-
if not ip_only:
|
|
26
|
-
return network_interfaces_tuples
|
|
27
|
-
else:
|
|
28
|
-
return [i[4][0] for i in network_interfaces_tuples]
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def get_destination_address_from_socket(socket_object):
|
|
32
|
-
"""
|
|
33
|
-
Return destination IP and port.
|
|
34
|
-
|
|
35
|
-
:param socket_object:
|
|
36
|
-
:return:
|
|
37
|
-
"""
|
|
38
|
-
# return ip_address, port
|
|
39
|
-
return socket_object.getsockname()[0], socket_object.getsockname()[1]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def get_source_address_from_socket(socket_object):
|
|
43
|
-
"""
|
|
44
|
-
Return source IP and port.
|
|
45
|
-
|
|
46
|
-
:param socket_object:
|
|
47
|
-
:return:
|
|
48
|
-
"""
|
|
49
|
-
# return ip_address, port
|
|
50
|
-
return socket_object.getpeername()[0], socket_object.getpeername()[1]
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def get_source_destination(socket_object):
|
|
54
|
-
return get_source_address_from_socket(socket_object), get_destination_address_from_socket(socket_object)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def set_socket_timeout(socket_object, seconds: int = 1):
|
|
58
|
-
# Setting timeout on the socket before "accept()" drastically slows down connections.
|
|
59
|
-
socket_object.settimeout(seconds)
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Needed to redirect output from console to logger on LOCALHOST process command line harvesting.
|
|
2
|
-
import io
|
|
3
|
-
from contextlib import redirect_stdout
|
|
4
|
-
|
|
5
|
-
from . import base
|
|
6
|
-
from ...ssh_remote import SSHRemote
|
|
7
|
-
from ...print_api import print_api
|
|
8
|
-
|
|
9
|
-
import psutil
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def get_process_name(client_socket, config: dict, ssh_script_processor, print_kwargs: dict = None):
|
|
13
|
-
# Get client ip and the source port.
|
|
14
|
-
client_ip, source_port = base.get_source_address_from_socket(client_socket)
|
|
15
|
-
|
|
16
|
-
# Put source port variable inside the string script.
|
|
17
|
-
updated_script_string = ssh_script_processor.put_variable_into_script_string(source_port, print_kwargs=print_kwargs)
|
|
18
|
-
|
|
19
|
-
process_name = get_process_commandline(
|
|
20
|
-
client_ip=client_ip,
|
|
21
|
-
username=config['ssh']['user'],
|
|
22
|
-
password=config['ssh']['pass'],
|
|
23
|
-
script_string=updated_script_string,
|
|
24
|
-
print_kwargs=print_kwargs)
|
|
25
|
-
|
|
26
|
-
return process_name
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def get_process_commandline(
|
|
30
|
-
client_ip: str, username: str, password: str, script_string: str, print_kwargs: dict = None):
|
|
31
|
-
execution_output = None
|
|
32
|
-
execution_error = None
|
|
33
|
-
|
|
34
|
-
# Checking if we're on localhost. If not, we'll execute SSH connection to get calling process name.
|
|
35
|
-
if client_ip != "127.0.0.1":
|
|
36
|
-
# Tried using paramiko SSH concurrently within threads, but with bigger loads it just breaks.
|
|
37
|
-
# So, better using it separately for each thread.
|
|
38
|
-
|
|
39
|
-
print_api(f"Initializing SSH connection to [{client_ip}]", **print_kwargs)
|
|
40
|
-
# Initializing SSHRemote class.
|
|
41
|
-
current_ssh_client = SSHRemote(ip_address=client_ip, username=username, password=password)
|
|
42
|
-
|
|
43
|
-
execution_output, execution_error = current_ssh_client.connect_get_client_commandline(script_string)
|
|
44
|
-
# Else, if we're on localhost, then execute the script directly without SSH.
|
|
45
|
-
else:
|
|
46
|
-
print_api(f"Executing LOCALHOST command to get the calling process.", **print_kwargs)
|
|
47
|
-
# Getting the redirection from console print, since that what the 'script_string' does.
|
|
48
|
-
with io.StringIO() as buffer, redirect_stdout(buffer):
|
|
49
|
-
# Executing the script with print to console.
|
|
50
|
-
try:
|
|
51
|
-
exec(script_string)
|
|
52
|
-
except ModuleNotFoundError as function_exception_object:
|
|
53
|
-
execution_error = f"Module not installed: {function_exception_object}"
|
|
54
|
-
print_api(
|
|
55
|
-
execution_error, error_type=True, logger_method="error", traceback_string=True, oneline=True,
|
|
56
|
-
**print_kwargs)
|
|
57
|
-
pass
|
|
58
|
-
except psutil.AccessDenied:
|
|
59
|
-
execution_error = f"Access Denied for 'psutil' to read system process command line. " \
|
|
60
|
-
f"Run script with Admin Rights."
|
|
61
|
-
print_api(
|
|
62
|
-
execution_error, error_type=True, logger_method="error", traceback_string=True, oneline=True,
|
|
63
|
-
**print_kwargs)
|
|
64
|
-
pass
|
|
65
|
-
except Exception:
|
|
66
|
-
execution_error = "There was undocumented exception in localhost script execution."
|
|
67
|
-
print_api(
|
|
68
|
-
execution_error, error_type=True, logger_method="error", traceback_string=True, oneline=True,
|
|
69
|
-
**print_kwargs)
|
|
70
|
-
pass
|
|
71
|
-
|
|
72
|
-
if not execution_error:
|
|
73
|
-
# Reading the buffer.
|
|
74
|
-
execution_output = buffer.getvalue()
|
|
75
|
-
|
|
76
|
-
# This section is generic for both remote SSH and localhost executions of the script.
|
|
77
|
-
process_name = get_commandline_and_error(execution_output, execution_error, print_kwargs=print_kwargs)
|
|
78
|
-
|
|
79
|
-
return process_name
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def get_commandline_and_error(execution_output, execution_error, print_kwargs: dict = None):
|
|
83
|
-
# If there was known error on localhost / known error on remote or any kind of error on remote, it was
|
|
84
|
-
# already logged, so we'll just put the error into 'process_name'.
|
|
85
|
-
if execution_error:
|
|
86
|
-
process_name = execution_error
|
|
87
|
-
print_api(
|
|
88
|
-
f"Error During Command Execution: {process_name}", error_type=True, logger_method='error', **print_kwargs)
|
|
89
|
-
# If there wasn't any error of above types, then we can put the output from either local or remote script
|
|
90
|
-
# execution into 'process_name' and log it / output to console.
|
|
91
|
-
else:
|
|
92
|
-
# If the output that was returned is not empty.
|
|
93
|
-
if execution_output:
|
|
94
|
-
# Replacing '\r\n' escape lines with string, so that the line will not be escaped in logs.
|
|
95
|
-
if '\r\n' in execution_output:
|
|
96
|
-
execution_output = execution_output.replace('\r\n', '')
|
|
97
|
-
elif '\n' in execution_output:
|
|
98
|
-
execution_output = execution_output.replace('\n', '')
|
|
99
|
-
|
|
100
|
-
process_name = execution_output
|
|
101
|
-
print_api(f"Client Process Command Line: {process_name}", **print_kwargs)
|
|
102
|
-
# Else if the script output came back empty.
|
|
103
|
-
else:
|
|
104
|
-
process_name = "Client Process Command Line came back empty after script execution."
|
|
105
|
-
print_api(process_name, error_type=True, logger_method='error', **print_kwargs)
|
|
106
|
-
|
|
107
|
-
return process_name
|
atomicshop/wrappers/wslw.py
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
from ..import process, permissions, virtualization
|
|
5
|
-
from ..print_api import print_api
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def is_installed():
|
|
9
|
-
# Command to check the status of the WSL feature
|
|
10
|
-
command = "Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux"
|
|
11
|
-
|
|
12
|
-
# Check if WSL is enabled
|
|
13
|
-
if "Enabled" in process.run_powershell_command(command):
|
|
14
|
-
return True
|
|
15
|
-
else:
|
|
16
|
-
return False
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def get_installed_distros() -> list:
|
|
20
|
-
"""
|
|
21
|
-
Get a list of installed WSL distros.
|
|
22
|
-
:return: list, list of installed WSL distros.
|
|
23
|
-
"""
|
|
24
|
-
return process.execute_with_live_output("wsl --list --quiet")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def get_available_distros_to_install() -> list:
|
|
28
|
-
"""
|
|
29
|
-
Get a list of available WSL distros to install.
|
|
30
|
-
:return: list, list of available WSL distros to install.
|
|
31
|
-
"""
|
|
32
|
-
return process.execute_with_live_output("wsl --list --online")
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def is_ubuntu_installed(version: str = "22.04") -> bool:
|
|
36
|
-
"""
|
|
37
|
-
Check if specific version of Ubuntu is installed on WSL.
|
|
38
|
-
:param version: string, Ubuntu version to check for. Default is 22.04.
|
|
39
|
-
:return: bool, True if Ubuntu is installed, False otherwise.
|
|
40
|
-
"""
|
|
41
|
-
|
|
42
|
-
if not version:
|
|
43
|
-
version = str()
|
|
44
|
-
|
|
45
|
-
installed_distros_list = get_installed_distros()
|
|
46
|
-
|
|
47
|
-
if f'Ubuntu-{version}' in installed_distros_list:
|
|
48
|
-
return True
|
|
49
|
-
elif 'Ubuntu' in installed_distros_list:
|
|
50
|
-
# Command to get Ubuntu version
|
|
51
|
-
command = f"wsl -d Ubuntu lsb_release -a"
|
|
52
|
-
|
|
53
|
-
# Execute the command
|
|
54
|
-
result = process.execute_with_live_output(command)
|
|
55
|
-
|
|
56
|
-
is_version_installed: bool = False
|
|
57
|
-
# Parse the output for the version number
|
|
58
|
-
for line in result:
|
|
59
|
-
if "Release" in line and version in line:
|
|
60
|
-
is_version_installed = True
|
|
61
|
-
break
|
|
62
|
-
|
|
63
|
-
return is_version_installed
|
|
64
|
-
else:
|
|
65
|
-
return False
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def install_wsl_manual(
|
|
69
|
-
directory_path: str, enable_virtual_machine_platform: bool = True, set_default_version_2: bool = True):
|
|
70
|
-
# noinspection GrazieInspection
|
|
71
|
-
"""
|
|
72
|
-
Install WSL on Windows 10.
|
|
73
|
-
:param directory_path: string, directory path to save Ubuntu package.
|
|
74
|
-
:param enable_virtual_machine_platform: bool, True to enable Virtual Machine Platform feature.
|
|
75
|
-
:param set_default_version_2: bool, True to set WSL version 2 as default.
|
|
76
|
-
|
|
77
|
-
Main.py example:
|
|
78
|
-
import sys
|
|
79
|
-
from atomicshop.wrappers import wslw
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def main():
|
|
83
|
-
if len(sys.argv) < 2:
|
|
84
|
-
print("Usage: python main.py <directory_path_to_save_Ubuntu_package>")
|
|
85
|
-
sys.exit(1)
|
|
86
|
-
|
|
87
|
-
wslw.install_wsl(directory_path=sys.argv[1])
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if __name__ == '__main__':
|
|
91
|
-
main()
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
# Check for admin privileges
|
|
95
|
-
if not permissions.is_admin():
|
|
96
|
-
sys.exit("Script must be run as administrator")
|
|
97
|
-
|
|
98
|
-
# Check if WSL is already installed
|
|
99
|
-
if is_installed():
|
|
100
|
-
print_api("WSL is already installed", color='green')
|
|
101
|
-
else:
|
|
102
|
-
# Enable WSL
|
|
103
|
-
print_api("Enabling Windows Subsystem for Linux...")
|
|
104
|
-
process.run_powershell_command(
|
|
105
|
-
"Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart")
|
|
106
|
-
|
|
107
|
-
# # Check if the system needs a reboot
|
|
108
|
-
# if "RestartNeeded : True" in process.run_powershell_command(
|
|
109
|
-
# "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux"):
|
|
110
|
-
# print_api("Please restart your computer to complete the installation of WSL and rerun the script.")
|
|
111
|
-
# sys.exit(0)
|
|
112
|
-
|
|
113
|
-
# Enable Virtual Machine Platform is needed for WSL 2.
|
|
114
|
-
if enable_virtual_machine_platform:
|
|
115
|
-
# Check if Hyper-V is enabled
|
|
116
|
-
if "Enabled" in process.run_powershell_command(
|
|
117
|
-
"Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V"):
|
|
118
|
-
print_api("Hyper-V is enabled")
|
|
119
|
-
else:
|
|
120
|
-
# Command to enable Virtual Machine Platform
|
|
121
|
-
command = "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart"
|
|
122
|
-
|
|
123
|
-
print_api("Enabling Virtual Machine Platform...")
|
|
124
|
-
process.run_powershell_command(command)
|
|
125
|
-
|
|
126
|
-
# Set WSL version 2 as default.
|
|
127
|
-
if set_default_version_2:
|
|
128
|
-
print_api("Setting WSL version 2 as default...")
|
|
129
|
-
process.execute_with_live_output("wsl --set-default-version 2")
|
|
130
|
-
|
|
131
|
-
# Check if Ubuntu is already installed. If so, exit with a message.
|
|
132
|
-
if is_ubuntu_installed():
|
|
133
|
-
print_api("Ubuntu is already installed", color='green')
|
|
134
|
-
sys.exit(0)
|
|
135
|
-
|
|
136
|
-
# Before you install Ubuntu, you need to set the WSL to version 2.
|
|
137
|
-
# You can do it after you install, but if so, you will need to set the Ubuntu to version 2 either.
|
|
138
|
-
# Download and Install Ubuntu.
|
|
139
|
-
print_api("Installing Ubuntu for WSL...")
|
|
140
|
-
package_file_path: str = str(Path(directory_path, "Ubuntu.appx"))
|
|
141
|
-
process.run_powershell_command(
|
|
142
|
-
f"Invoke-WebRequest -Uri https://aka.ms/wslubuntu2204 -OutFile {package_file_path} -UseBasicParsing")
|
|
143
|
-
process.run_powershell_command(f"Add-AppxPackage {package_file_path}")
|
|
144
|
-
|
|
145
|
-
print_api("Ubuntu installation is complete. You can now launch Ubuntu from the Start Menu.")
|
|
146
|
-
print_api("Please restart your computer to complete the installation.")
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
def install_wsl(distro: str = "Ubuntu-22.04"):
|
|
150
|
-
# noinspection GrazieInspection
|
|
151
|
-
"""
|
|
152
|
-
Install WSL and Ubuntu.
|
|
153
|
-
:param distro: string, distro to install. Default is Ubuntu-22.04.
|
|
154
|
-
:return:
|
|
155
|
-
|
|
156
|
-
Main.py example:
|
|
157
|
-
from atomicshop.wrappers import wslw
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
def main():
|
|
161
|
-
wslw.install_wsl()
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if __name__ == '__main__':
|
|
165
|
-
main()
|
|
166
|
-
"""
|
|
167
|
-
|
|
168
|
-
# Check for admin privileges
|
|
169
|
-
if not permissions.is_admin():
|
|
170
|
-
print_api("Script must be run as administrator", color='red')
|
|
171
|
-
sys.exit(1)
|
|
172
|
-
|
|
173
|
-
# Check if virtualization is enabled.
|
|
174
|
-
if not virtualization.is_enabled():
|
|
175
|
-
print_api("Virtualization is not enabled in the bios. Please enable it and rerun the script.", color='red')
|
|
176
|
-
sys.exit(1)
|
|
177
|
-
|
|
178
|
-
# Check if WSL and Ubuntu is already installed
|
|
179
|
-
wsl_installed: bool = is_installed()
|
|
180
|
-
ubuntu_installed: bool = is_ubuntu_installed()
|
|
181
|
-
|
|
182
|
-
if wsl_installed and ubuntu_installed:
|
|
183
|
-
print_api("WSL and Ubuntu is already installed", color='green')
|
|
184
|
-
sys.exit(0)
|
|
185
|
-
elif wsl_installed and not ubuntu_installed:
|
|
186
|
-
print_api("WSL is already installed, installing Ubuntu")
|
|
187
|
-
elif not wsl_installed:
|
|
188
|
-
print_api("WSL is not installed, installing WSL and Ubuntu")
|
|
189
|
-
|
|
190
|
-
command = f"wsl --install -d {distro}"
|
|
191
|
-
process.execute_with_live_output(command, verbose=True)
|