import os

VERSION = "0.0.1"


# ====== #
# CONSTS #
# ====== #
DEFAULT_RATE = 200
DEFAULT_NB_PROCESS = 100


if "SUDO_USER" in os.environ:
    USER = os.environ["SUDO_USER"]
elif "USER" in os.environ:
    USER = os.environ["USER"]
elif "HOME" in os.environ:
    _home = os.environ["HOME"]
    if _home.startswith('/home/') and _home.count('/') == 2:
        USER = _home.split('/')[-1]
    else:
        raise ValueError(f"User not found in env variable")
else:
    raise ValueError(f"User not found in env variable")

# get user from hom
_rockyou_paths = ["/opt/wordlists/rockyou.txt", "/usr/share/wordlists/rockyou.txt"]
for path in _rockyou_paths:
    if os.path.isfile(path):
        PATH_ROCKYOU = path
        break
else:
    raise ValueError(f"rockyou/txt wordlist not found in locations {_rockyou_paths}")

CURRENT_PATH = os.getcwd()

# FOLDER PRESENT ONLY IN NETWORK LEVEL
FOLDER_CMD_OUTPUTS = "cmd_outputs"
FOLDER_IP = "ip"
FOLDER_HOSTS = "hosts"
FOLDER_SCREENSHOTS = "screenshots"
FOLDERS_NETWORK_LEVEL = [FOLDER_CMD_OUTPUTS, FOLDER_IP, FOLDER_HOSTS, FOLDER_SCREENSHOTS]

# FOLDER PRESENT IN NETWORK LEVEL AND HOST LEVEL
FOLDER_SCANS = "scans"
FOLDER_NMAP = f"{FOLDER_SCANS}/nmap"
FOLDER_LOOTS = "loots"
FOLDERS_NETWORK_AND_HOSTS_LEVELS = [FOLDER_SCANS, FOLDER_LOOTS, FOLDER_NMAP]

# FILES PRESENT IN NETWORK LEVEL
FILE_NOTES = "notes.md"
FILE_SCOPE = "scope.txt"
FILE_EXCLUDE_SCOPE = "exclude_scope.txt"
FILE_CUSTOM_ROCKYOU = "custom_rockyou.txt"
FILE_IP_ALL = f"{FOLDER_IP}/all.ip.txt"
FILES_NETWORK_LEVEL = [
    FILE_NOTES,
    FILE_SCOPE,
    FILE_EXCLUDE_SCOPE,
    FILE_CUSTOM_ROCKYOU,
    FILE_IP_ALL,
]

# FILES PRESENT IN NETWORK LEVEL AND HOSTS LEVEL
FILE_WORDLIST = "wordlist.txt"
FILE_USERS = "users.txt"
FILE_PASSWORDS = "passwords.txt"
FILE_USERPASS = "userpass.txt"
FILE_NTLM_HASHES = "ntlm_hashes.txt"
FILE_USER_NTLM_HASHES = "userntlmhashes.txt"
FILES_NETWORK_AND_HOST_LEVELS = [
    FILE_WORDLIST,
    FILE_USERS,
    FILE_PASSWORDS,
    FILE_USERPASS,
    FILE_NTLM_HASHES,
    FILE_USER_NTLM_HASHES,
]


NAME_NMAP_TCP_FULL_SIMPLE = "tcp_allports_simple"
NAME_NMAP_TCP_OPEN_SC_SV = "tcp_open_sc_sv"
NAME_NMAP_UDP_TOP_SIMPLE = "udp_top_simple"
NAME_NMAP_UDP_OPEN_SC_SV = "udp_open_sc_sv"
