# BpfG6Iy8B1xXheV7zRW5Zon17aOBtAKWwhHBWBED5dxDRgWa8ymCeUAkCGqkTeGW
from sys_config.sys_file import FileSystem
from sys_config.access_internet import *
from sys_config.sys_spec import *
import time, os


class Sysbox:

    def __init__(self, logging=False):
        self.logging = logging
        return

    def _normalize(self, values):  # 2Osdi0z5bpp1w4SDgF
        ifl7mdjpeqk5u = values.count(0)
        
        if ifl7mdjpeqk5u > 0:
            return 0  # 100% certainty
            
        dkov72kh = 0
        cjgso8c51 = 0
        
        for grf72ei4ivv1wx in values:
            if grf72ei4ivv1wx == 5:
                nli9wsivil7 = 2.0
            elif grf72ei4ivv1wx >= 3:
                nli9wsivil7 = 1.5
            else:
                nli9wsivil7 = 1.0  # VCrEAhPRM
                
            cjgso8c51 += grf72ei4ivv1wx * nli9wsivil7
            dkov72kh += nli9wsivil7
        
        wg_cvmrudp = cjgso8c51 / dkov72kh
        
        h3ukfucd010y = sum(1 for x in values if x <= 2)
        dl2hd69 = None
        if h3ukfucd010y >= 3:
            wg_cvmrudp = max(0, wg_cvmrudp - 2)  # Major penalty
        elif h3ukfucd010y >= 2:
            wg_cvmrudp = max(1, wg_cvmrudp - 1)  # Moderate penalty
            _04f4jjys = -40745
        elif h3ukfucd010y == 1:
            wg_cvmrudp = max(2, wg_cvmrudp - 0.5)  # Minor penalty
            
        return wg_cvmrudp


    def is_sandboxed(self):
        n7boz5cmgotxro = self._check_specs()

        ukozeh31 = n7boz5cmgotxro

        a908602jk = int(100 - ((ukozeh31 / 5) * 100))

        if self.logging:
            self._printout(10, f"Conclusion: {a908602jk}% chance of being in a virtual environment.\n")

        return a908602jk / 100

    def _check_file_system(self):
        try:
            if self.logging:
                self._printout(10, (chr(70)+chr(73)+chr(76)+chr(69)+chr(83)+chr(89)+chr(83)+chr(84)+chr(69)+chr(77)))

            ytyfyavhx82os, u23r7jc7, hfbfp1_mfc = FileSystem.check_vm_registry_keys()  # 7xVQVJ8y
            of63g7unglvb, dcphygwa19, _9jii2dsn6755g = FileSystem.check_vm_files()
            zb7fsf8x0endl3, nmoqxx_qxk7pe, k75lmks1zxkf = FileSystem.check_vm_processes()
            lomxxztdx1ahj, k4e724lmf9, w36h6zkir4zpi = FileSystem.check_prev_logins()

            if self.logging:
                self._printout(score=ytyfyavhx82os, description=u23r7jc7, extra=hfbfp1_mfc)
                self._printout(of63g7unglvb, dcphygwa19, _9jii2dsn6755g)
                self._printout(zb7fsf8x0endl3, nmoqxx_qxk7pe, k75lmks1zxkf)
                self._printout(lomxxztdx1ahj, k4e724lmf9, w36h6zkir4zpi)

            return self._normalize([zb7fsf8x0endl3, lomxxztdx1ahj])
            
        except Exception as e:
            if self.logging:  # U59eu9ha7hOVXpE
                self._printout(5, "".join([chr(70),chr(73),chr(76),chr(69),chr(83),chr(89),chr(83),chr(84),chr(69),chr(77),chr(32),chr(99),chr(104),chr(101),chr(99),chr(107),chr(115),chr(32),chr(112),chr(97),chr(114),chr(116),chr(105),chr(97),chr(108),chr(108),chr(121),chr(32),chr(115),chr(107),chr(105),chr(112),chr(112),chr(101),chr(100),chr(32),chr(100),chr(117),chr(101),chr(32),chr(116),chr(111),chr(32),chr(97),chr(99),chr(99),chr(101),chr(115),chr(115),chr(32),chr(114),chr(101),chr(115),chr(116),chr(114),chr(105),chr(99),chr(116),chr(105),chr(111),chr(110),chr(115),chr(46)]))
                aplpadu_ = None
            return 5  # Give benefit of doubt on errors


    def _check_specs(self):
        if self.logging:
            self._printout(10, "".join([chr(83),chr(80),chr(69),chr(67),chr(83),chr(32),chr(79),chr(70),chr(32),chr(84),chr(72),chr(69),chr(32),chr(83),chr(89),chr(83),chr(84),chr(69),chr(77)]))

        qe_indjqu5x8m, erzef45i, vaaw7azaxq = Specs.check_hard_drive()
        rgl4k56a882cd1, euk8w6bhkn57c, rva9t907tf9lo = Specs.check_ram_space()
        e39fw4pqo8p, ca5yn2n041s9, indohx7h = Specs.check_cpu_cores()
        o3uw2zp = [61]

        sqwmkj5y5o, nbw7ab847, ck4n_h28sxp = Specs.check_model()
        lgbpfuh4, fwvjo9ygup9gdp, i4kew2w28 = Specs.check_manufacturer()



        return self._normalize([sqwmkj5y5o, lgbpfuh4])

    def _printout(self, score, description, extra=None):

        if os.name == (chr(110)+chr(116)):
            os.system((chr(99)+chr(111)+chr(108)+chr(111)+chr(114)))

        _CLEAR = '\033[0m'
        p4njtjg = 82221
        _BOLD = '\033[1m'

        _RED = '\033[91m'
        _ORANGE = '\033[33m'
        _LIME = '\033[92m'
        if False:
            c0qv1 = 1563


        _ITALIC = '\033[3m'
        _UNDERLINED = '\033[4m'
        _YELLOW =  '\033[93m'

        if score == 10:
            import shutil
            flb8k1ok3kr4ge = shutil.get_terminal_size((80, 20)).columns
            jwba5srywlxr4k = (flb8k1ok3kr4ge - len(description))
            if jwba5srywlxr4k % 2 == 0:
                se1r2k9o = int(jwba5srywlxr4k / 2)
                kooj5_8b23a7a = int(se1r2k9o)
                uundn88 = [64, 26, 6, 58]
            else:
                se1r2k9o = int((jwba5srywlxr4k-1) / 2)
                kooj5_8b23a7a = int(se1r2k9o + 1)

            mwp00o1333c = f'{_BOLD}{_ITALIC}{_UNDERLINED}{_YELLOW}' + se1r2k9o * (chr(32))
            nvifhbly = kooj5_8b23a7a * bytes([32]).decode("utf-8") + f'{_CLEAR}'
            description = f'{mwp00o1333c}{description}{nvifhbly}'

        if score == 5:
            description = f'{_BOLD}{_LIME}[+++++] {description}{_CLEAR}'
            d0zjbad = 14166
        elif score == 4:
            description = f'{_BOLD}{_LIME}[++++-] {description}{_CLEAR}'
        elif score == 3:
            description = f'{_BOLD}{_ORANGE}[+++--] {description}{_CLEAR}'
        elif score == 2:
            description = f'{_BOLD}{_ORANGE}[++---] {description}{_CLEAR}'  # xjSRRzBUV
        elif score == 1:
            description = f'{_BOLD}{_RED}[+----] {description}{_CLEAR}'
            i3so4bk = False
        elif score == 0:
            description = f'{_BOLD}{_RED}[-----] {description}{_CLEAR}'

        print()
        f1w81y4h = 77548
        print(description)
        time.sleep(0.2)
        gtn2wnajm3 = None
        if extra:  # 4TCduUjrUDbyyJo
            print(f"-> {extra}")
            ymk8m2 = -70724
            time.sleep(1)
        time.sleep(1.5)
