rename nxc PATH variable
parent
39cdcc12bb
commit
b0b36ede87
|
@ -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 !!!
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
10
nxc/paths.py
10
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")
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue