NetExec/nxc/first_run.py

42 lines
1.1 KiB
Python
Raw Permalink Normal View History

from os import mkdir
from os.path import exists
from os.path import join as path_join
import shutil
2023-09-20 04:09:25 +00:00
from nxc.paths import NXC_PATH, CONFIG_PATH, TMP_PATH, DATA_PATH
from nxc.database import initialize_db
from nxc.logger import nxc_logger
2018-03-01 19:36:17 +00:00
def first_run_setup(logger=nxc_logger):
if not exists(TMP_PATH):
mkdir(TMP_PATH)
2023-09-20 04:09:25 +00:00
if not exists(NXC_PATH):
2023-05-02 15:17:59 +00:00
logger.display("First time use detected")
logger.display("Creating home directory structure")
2023-09-20 04:09:25 +00:00
mkdir(NXC_PATH)
2017-03-27 21:09:36 +00:00
folders = (
2023-05-02 15:17:59 +00:00
"logs",
"modules",
"protocols",
"workspaces",
"obfuscated_scripts",
"screenshots",
)
2017-03-27 21:09:36 +00:00
for folder in folders:
2023-09-20 04:09:25 +00:00
if not exists(path_join(NXC_PATH, folder)):
logger.display(f"Creating missing folder {folder}")
2023-09-20 04:09:25 +00:00
mkdir(path_join(NXC_PATH, folder))
initialize_db()
if not exists(CONFIG_PATH):
2023-05-02 15:17:59 +00:00
logger.display("Copying default configuration file")
default_path = path_join(DATA_PATH, "nxc.conf")
2023-09-20 04:09:25 +00:00
shutil.copy(default_path, NXC_PATH)
# if not exists(CERT_PATH):
2023-01-02 11:55:03 +00:00
# if os.name != 'nt':
# if e.errno == errno.ENOENT: