/// <summary>
 /// Check application running under virtual machine
 /// </summary>
 public static void Parse(Process CurrentProcess)
 {
     try
     {
         if (VirtualMachineDetector.Assert())
         {
             if (ShowAlert)
             {
                 Alert.Show(AlertMessage);
             }
             if (SelfDelete)
             {
                 string location = CurrentProcess.MainModule.FileName;
                 Process.Start(new ProcessStartInfo("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 3000 > Nul & Del \"" + location + "\"")
                 {
                     WindowStyle = ProcessWindowStyle.Hidden
                 }).Dispose();
                 CurrentProcess.Kill();
                 Environment.Exit(0);
             }
             CurrentProcess.Kill();
         }
     }
     catch
     {
     }
 }
Beispiel #2
0
        static void Run()
        {
            var hypervisor = "";

            if (VirtualMachineDetector.Assert(out hypervisor))
            {
                Console.WriteLine("DETECTED {0}!", hypervisor);
            }
        }
        internal void BuildObjectGraph(Action shutdown)
        {
            const int FIVE_SECONDS   = 5000;
            const int THIRTY_SECONDS = 30000;

            logger     = new Logger();
            systemInfo = new SystemInfo();

            InitializeConfiguration();
            InitializeLogging();
            InitializeText();

            var args                  = Environment.GetCommandLineArgs();
            var messageBox            = new MessageBoxFactory(text);
            var nativeMethods         = new NativeMethods();
            var uiFactory             = new UserInterfaceFactory(text);
            var desktopFactory        = new DesktopFactory(ModuleLogger(nameof(DesktopFactory)));
            var explorerShell         = new ExplorerShell(ModuleLogger(nameof(ExplorerShell)), nativeMethods);
            var fileSystem            = new FileSystem();
            var processFactory        = new ProcessFactory(ModuleLogger(nameof(ProcessFactory)));
            var proxyFactory          = new ProxyFactory(new ProxyObjectFactory(), ModuleLogger(nameof(ProxyFactory)));
            var remoteSessionDetector = new RemoteSessionDetector(ModuleLogger(nameof(RemoteSessionDetector)));
            var runtimeHost           = new RuntimeHost(appConfig.RuntimeAddress, new HostObjectFactory(), ModuleLogger(nameof(RuntimeHost)), FIVE_SECONDS);
            var runtimeWindow         = uiFactory.CreateRuntimeWindow(appConfig);
            var server                = new ServerProxy(appConfig, ModuleLogger(nameof(ServerProxy)));
            var serviceProxy          = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), ModuleLogger(nameof(ServiceProxy)), Interlocutor.Runtime);
            var sessionContext        = new SessionContext();
            var splashScreen          = uiFactory.CreateSplashScreen(appConfig);
            var userInfo              = new UserInfo(ModuleLogger(nameof(UserInfo)));
            var vmDetector            = new VirtualMachineDetector(ModuleLogger(nameof(VirtualMachineDetector)), systemInfo);

            var bootstrapOperations = new Queue <IOperation>();
            var sessionOperations   = new Queue <IRepeatableOperation>();

            bootstrapOperations.Enqueue(new I18nOperation(logger, text));
            bootstrapOperations.Enqueue(new CommunicationHostOperation(runtimeHost, logger));

            sessionOperations.Enqueue(new SessionInitializationOperation(configuration, fileSystem, logger, runtimeHost, sessionContext));
            sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new FileSystem(), new HashAlgorithm(), logger, sessionContext));
            sessionOperations.Enqueue(new DisclaimerOperation(logger, sessionContext));
            sessionOperations.Enqueue(new ServerOperation(args, configuration, fileSystem, logger, sessionContext, server));
            sessionOperations.Enqueue(new RemoteSessionOperation(remoteSessionDetector, logger, sessionContext));
            sessionOperations.Enqueue(new VirtualMachineOperation(vmDetector, logger, sessionContext));
            sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS, userInfo));
            sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new ProctoringWorkaroundOperation(logger, sessionContext));
            sessionOperations.Enqueue(new KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
            sessionOperations.Enqueue(new ClientOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
            sessionOperations.Enqueue(new SessionActivationOperation(logger, sessionContext));

            var bootstrapSequence = new OperationSequence(logger, bootstrapOperations);
            var sessionSequence   = new RepeatableOperationSequence(logger, sessionOperations);

            RuntimeController = new RuntimeController(
                appConfig,
                logger,
                messageBox,
                bootstrapSequence,
                sessionSequence,
                runtimeHost,
                runtimeWindow,
                serviceProxy,
                sessionContext,
                shutdown,
                splashScreen,
                text,
                uiFactory);
        }
Beispiel #4
0
    internal async Task <bool> CheckLicenceAsync(bool increment = true)
    {
        #region SEE IF NEEDS TO CHECK ONLINE
        string iO = getValue(false);
        Cn = CreateMD5(Environment.MachineName);
        if (iO.Length < 2)
        {
            status = LICSTATUS.UNACTIVATED;
            return(false);
        }
        Licence licence = GetLicence();
        bool    checkOn = false;
        if (licence == null)
        {
            checkOn = true;
            if (VirtualMachineDetector.Assert())
            {
                status = LICSTATUS.UNACTIVATED;
                return(false);
            }
        }
        #endregion
        #region CHECK ONLINE
        if (checkOn)
        {
            try
            {
                Dictionary <string, Object> datax = new Dictionary <string, Object>();
                datax["user"]     = tobase64(iO);
                datax["ruser"]    = tobase64(Cn);
                datax["computer"] = tobase64(Iu.MotherBoard);
                string datapost = tobase64(JsonConvert.SerializeObject(datax));
                string url      = URL + "?par=" + datapost;


                string json = await GetResponse(url).ConfigureAwait(false);

                if (json != null)
                {
                    Dictionary <string, Object> dataen = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
                    var    keyper = dataen["value"].ToString();
                    var    iv     = "45287112549354892144548565451985";
                    var    key    = "hexdiez822443idx";
                    string ms     = DecryptRJ256(FromBase64String(keyper), key, iv);
                    Dictionary <string, object> response = JsonConvert.DeserializeObject <Dictionary <string, object> >(ms);
                    string dkey = response["u"].ToString();
                    LicenceName = response["x"].ToString();
                    bool isNew = bool.Parse(response["b"].ToString());
                    LicenceManager.TimeLeft = int.Parse(response["a"].ToString());
                    bool a   = LicenceManager.TimeLeft > 0;
                    int  max = int.Parse(response["r"].ToString());
                    if (response["z"].ToString() == "PERMANENT")
                    {
                        type = LICENCETYPE.PERMANENT;
                        a    = true;
                    }
                    else if (response["z"].ToString() == "ADMIN")
                    {
                        type = LICENCETYPE.ADMIN;
                        a    = true;
                    }
                    else
                    {
                        type = LICENCETYPE.TIMED;
                    }

                    LicenceManager.message = response["m"].ToString();
                    isActivated            = iO.Equals(dkey) && a;
                    if (!File.Exists(Xp))
                    {
                        File.WriteAllText(Xp, iO.Substring(0, iO.Length - 5) + "%");
                    }

                    if (isActivated)
                    {
                        Products = JsonConvert.DeserializeObject <int[]>(frombase64(response["p"].ToString()));
                        Licence Licence = new Licence
                        {
                            LicenceName  = LicenceName,
                            HardwereHash = iO,
                            HardwereName = Cn,
                            Products     = Products,
                            MaxTimes     = max,
                            OpenTimes    = 0,
                            Msg          = LicenceManager.message,
                            Type         = (int)type
                        };
                        if (a)
                        {
                            Licence.RecheckTime = Time.timeStampMilisecond + ONE_MINUTE_MILISECOND * 60; //1 hour
                            SaveLicence(Licence);
                            status = LICSTATUS.READY;
                            return(true);
                        }
                        else
                        {
                            status = LICSTATUS.UNACTIVATED;
                        }
                        return(true);
                    }
                    else
                    {
                        status = LICSTATUS.UNACTIVATED;
                    }
                }
                else
                {
                    status = LICSTATUS.UNACTIVATED;
                }

                return(false);
            }
            catch { status = LICSTATUS.UNACTIVATED; return(false); }
        }
        #endregion
        #region OFFLINE
        else
        {
            if (licence == null)
            {
                status = LICSTATUS.UNACTIVATED;
                return(false);
            }
            else
            {
                isActivated            = true;
                Products               = licence.Products;
                LicenceManager.message = licence.Msg;
                LicenceName            = licence.LicenceName;
                type = (LICENCETYPE)licence.Type;
                if (increment)
                {
                    licence.OpenTimes++; //Increment OpenTimes
                }
                SaveLicence(licence);
                status = LICSTATUS.READY;
                return(true);
            }
        }
        #endregion
    }