From b0b36ede87cdcab5a4db68dd75fbf2e3e7bc3435 Mon Sep 17 00:00:00 2001 From: Marshall Hallenbeck Date: Wed, 20 Sep 2023 00:09:25 -0400 Subject: [PATCH] rename nxc PATH variable --- nxc/config.py | 8 ++++---- nxc/first_run.py | 12 ++++++------ nxc/helpers/powershell.py | 4 ++-- nxc/loaders/moduleloader.py | 4 ++-- nxc/netexec.py | 4 ++-- nxc/paths.py | 10 +++++----- nxc/protocols/ssh/database.py | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/nxc/config.py b/nxc/config.py index 393f9070..415c3462 100644 --- a/nxc/config.py +++ b/nxc/config.py @@ -2,7 +2,7 @@ import os from os.path import join as path_join import configparser -from nxc.paths import nxc_PATH, DATA_PATH +from nxc.paths import NXC_PATH, DATA_PATH from nxc.first_run import first_run_setup from nxc.logger import nxc_logger from ast import literal_eval @@ -11,11 +11,11 @@ nxc_default_config = configparser.ConfigParser() nxc_default_config.read(path_join(DATA_PATH, "nxc.conf")) nxc_config = configparser.ConfigParser() -nxc_config.read(os.path.join(nxc_PATH, "nxc.conf")) +nxc_config.read(os.path.join(NXC_PATH, "nxc.conf")) if "nxc" not in nxc_config.sections(): first_run_setup() - nxc_config.read(os.path.join(nxc_PATH, "nxc.conf")) + nxc_config.read(os.path.join(NXC_PATH, "nxc.conf")) # Check if there are any missing options in the config file for section in nxc_default_config.sections(): @@ -24,7 +24,7 @@ for section in nxc_default_config.sections(): nxc_logger.display(f"Adding missing option '{option}' in config section '{section}' to nxc.conf") nxc_config.set(section, option, nxc_default_config.get(section, option)) - with open(path_join(nxc_PATH, "nxc.conf"), "w") as config_file: + with open(path_join(NXC_PATH, "nxc.conf"), "w") as config_file: nxc_config.write(config_file) #!!! THESE OPTIONS HAVE TO EXIST IN THE DEFAULT CONFIG FILE !!! diff --git a/nxc/first_run.py b/nxc/first_run.py index 20e928e3..ab22907e 100755 --- a/nxc/first_run.py +++ b/nxc/first_run.py @@ -5,7 +5,7 @@ from os import mkdir from os.path import exists from os.path import join as path_join import shutil -from nxc.paths import nxc_PATH, CONFIG_PATH, TMP_PATH, DATA_PATH +from nxc.paths import NXC_PATH, CONFIG_PATH, TMP_PATH, DATA_PATH from nxc.nxcdb import initialize_db from nxc.logger import nxc_logger @@ -14,10 +14,10 @@ def first_run_setup(logger=nxc_logger): if not exists(TMP_PATH): mkdir(TMP_PATH) - if not exists(nxc_PATH): + if not exists(NXC_PATH): logger.display("First time use detected") logger.display("Creating home directory structure") - mkdir(nxc_PATH) + mkdir(NXC_PATH) folders = ( "logs", @@ -28,16 +28,16 @@ def first_run_setup(logger=nxc_logger): "screenshots", ) for folder in folders: - if not exists(path_join(nxc_PATH, folder)): + if not exists(path_join(NXC_PATH, folder)): logger.display(f"Creating missing folder {folder}") - mkdir(path_join(nxc_PATH, folder)) + mkdir(path_join(NXC_PATH, folder)) initialize_db(logger) if not exists(CONFIG_PATH): logger.display("Copying default configuration file") default_path = path_join(DATA_PATH, "nxc.conf") - shutil.copy(default_path, nxc_PATH) + shutil.copy(default_path, NXC_PATH) # if not exists(CERT_PATH): # logger.display('Generating SSL certificate') diff --git a/nxc/helpers/powershell.py b/nxc/helpers/powershell.py index f6886c35..58c6a0eb 100644 --- a/nxc/helpers/powershell.py +++ b/nxc/helpers/powershell.py @@ -8,7 +8,7 @@ from random import choice, sample from subprocess import call from nxc.helpers.misc import which from nxc.logger import nxc_logger -from nxc.paths import nxc_PATH, DATA_PATH +from nxc.paths import NXC_PATH, DATA_PATH from base64 import b64encode obfuscate_ps_scripts = False @@ -30,7 +30,7 @@ def is_powershell_installed(): def obfs_ps_script(path_to_script): ps_script = path_to_script.split("/")[-1] - obfs_script_dir = os.path.join(nxc_PATH, "obfuscated_scripts") + obfs_script_dir = os.path.join(NXC_PATH, "obfuscated_scripts") obfs_ps_script = os.path.join(obfs_script_dir, ps_script) if is_powershell_installed() and obfuscate_ps_scripts: diff --git a/nxc/loaders/moduleloader.py b/nxc/loaders/moduleloader.py index 9337e9d6..c804c5ce 100755 --- a/nxc/loaders/moduleloader.py +++ b/nxc/loaders/moduleloader.py @@ -12,7 +12,7 @@ from os.path import join as path_join from nxc.context import Context from nxc.logger import NXCAdapter -from nxc.paths import nxc_PATH +from nxc.paths import NXC_PATH class ModuleLoader: @@ -130,7 +130,7 @@ class ModuleLoader: modules = {} modules_paths = [ path_join(dirname(nxc.__file__), "modules"), - path_join(nxc_PATH, "modules"), + path_join(NXC_PATH, "modules"), ] for path in modules_paths: diff --git a/nxc/netexec.py b/nxc/netexec.py index 7b3b9f2a..edf92993 100755 --- a/nxc/netexec.py +++ b/nxc/netexec.py @@ -11,7 +11,7 @@ from nxc.loaders.moduleloader import ModuleLoader from nxc.servers.http import NXCHTTPServer from nxc.first_run import first_run_setup from nxc.context import Context -from nxc.paths import nxc_PATH, DATA_PATH +from nxc.paths import NXC_PATH, DATA_PATH from nxc.console import nxc_console from nxc.logger import nxc_logger from nxc.config import nxc_config, nxc_workspace, config_log, ignore_opsec @@ -157,7 +157,7 @@ def main(): protocol_db_object = getattr(p_loader.load_protocol(protocol_db_path), "database") nxc_logger.debug(f"Protocol DB Object: {protocol_db_object}") - db_path = path_join(nxc_PATH, "workspaces", nxc_workspace, f"{args.protocol}.db") + db_path = path_join(NXC_PATH, "workspaces", nxc_workspace, f"{args.protocol}.db") nxc_logger.debug(f"DB Path: {db_path}") db_engine = create_db_engine(db_path) diff --git a/nxc/paths.py b/nxc/paths.py index 712c8c92..5b16c191 100644 --- a/nxc/paths.py +++ b/nxc/paths.py @@ -2,14 +2,14 @@ import os import sys import nxc -nxc_PATH = os.path.expanduser("~/.nxc") +NXC_PATH = os.path.expanduser("~/.nxc") TMP_PATH = os.path.join("/tmp", "nxc_hosted") if os.name == "nt": TMP_PATH = os.getenv("LOCALAPPDATA") + "\\Temp\\nxc_hosted" if hasattr(sys, "getandroidapilevel"): TMP_PATH = os.path.join("/data", "data", "com.termux", "files", "usr", "tmp", "nxc_hosted") -WS_PATH = os.path.join(nxc_PATH, "workspaces") -CERT_PATH = os.path.join(nxc_PATH, "nxc.pem") -CONFIG_PATH = os.path.join(nxc_PATH, "nxc.conf") -WORKSPACE_DIR = os.path.join(nxc_PATH, "workspaces") +WS_PATH = os.path.join(NXC_PATH, "workspaces") +CERT_PATH = os.path.join(NXC_PATH, "nxc.pem") +CONFIG_PATH = os.path.join(NXC_PATH, "nxc.conf") +WORKSPACE_DIR = os.path.join(NXC_PATH, "workspaces") DATA_PATH = os.path.join(os.path.dirname(nxc.__file__), "data") diff --git a/nxc/protocols/ssh/database.py b/nxc/protocols/ssh/database.py index 7a3ed0be..51fb6638 100644 --- a/nxc/protocols/ssh/database.py +++ b/nxc/protocols/ssh/database.py @@ -14,11 +14,11 @@ from pathlib import Path import configparser from nxc.logger import nxc_logger -from nxc.paths import nxc_PATH +from nxc.paths import NXC_PATH # we can't import config.py due to a circular dependency, so we have to create redundant code unfortunately nxc_config = configparser.ConfigParser() -nxc_config.read(os.path.join(nxc_PATH, "nxc.conf")) +nxc_config.read(os.path.join(NXC_PATH, "nxc.conf")) nxc_workspace = nxc_config.get("nxc", "workspace", fallback="default")