Ejemplo n.º 1
0
        protected byte[] DoEncrypt(byte[] data)
        {
            var d = (byte[])data.Clone();

            _encryptor.Encrypt(d);
            return(d);
        }
Ejemplo n.º 2
0
        public void RC4TestNewEnc()
        {
            RC4    algorithm = new RC4();
            string cipher    = algorithm.Encrypt("aaaa", "test");

            Assert.IsTrue(cipher.Equals("ÏîFp"));
        }
Ejemplo n.º 3
0
        public void RC4TestEnc2()
        {
            RC4    algorithm = new RC4();
            string cipher    = algorithm.Encrypt("0x61626364", "0x74657374");

            Assert.IsTrue(cipher.Equals("0xcfed4475", StringComparison.InvariantCultureIgnoreCase));
        }
Ejemplo n.º 4
0
        public void RC4TestEnc1()
        {
            RC4    algorithm = new RC4();
            string cipher    = algorithm.Encrypt("abcd", "test");

            Assert.IsTrue(cipher.Equals("ÏíDu"));
        }
Ejemplo n.º 5
0
        public static string PayPassWord(string pwd)
        {
            var rc4 = new RC4();

            pwd = HttpUtility.UrlEncode(rc4.Encrypt(pwd, "wine"));
            return(pwd);
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.Unicode;

            byte[] key = { 1, 2, 3, 4, 5 };

            var dataText = @"Hello Greg!";
            var data     = Encoding.Unicode.GetBytes(dataText);

            var cipher     = RC4.Encrypt(key, data);
            var cipherText = Encoding.Unicode.GetString(cipher.ToArray());

            var retrieved     = RC4.Decrypt(key, cipher);
            var retrievedText = Encoding.Unicode.GetString(retrieved.ToArray());

            Console.WriteLine($"Data text     : {dataText}");
            Console.WriteLine($"Cipher text   : {cipherText}");
            Console.WriteLine($"Cipher bytes   : {PrintByteArray(cipher.ToArray())}");
            Console.WriteLine($"Retrieved text: {retrievedText}");

            Console.WriteLine($"Period of first pseudo-random byte: {RC4.GetKeyInitializationPeriod(key, 1)}");
            Console.WriteLine($"Period of second pseudo-random byte: {RC4.GetKeyInitializationPeriod(key, 2)}");

            Console.ReadKey();
        }
Ejemplo n.º 7
0
    /// <summary>
    /// 加密内容
    /// </summary>
    /// <param name="source"></param>
    /// <param name="encoder"></param>
    /// <param name="codePwd"></param>
    /// <returns></returns>
    public static byte[] PushCode(byte[] source, IBytesEncode encoder, ICodePwdProvider codePwd)
    {
        var    encoded = encoder.Encode(source, codePwd);
        string en_b64  = Convert.ToBase64String(encoded);

        return(rc4.Encrypt(en_b64));
    }
Ejemplo n.º 8
0
 public static bool Test1()
 {
     byte[] key            = new byte[] { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
     byte[] text           = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
     byte[] expectedCipher = new byte[] { 0x74, 0x94, 0xC2, 0xE7, 0x10, 0x4B, 0x08, 0x79 };
     byte[] cipher         = RC4.Encrypt(key, text);
     return(ByteUtils.AreByteArraysEqual(cipher, expectedCipher));
 }
Ejemplo n.º 9
0
 public static bool Test2()
 {
     byte[] key            = new byte[] { 0x61, 0x8A, 0x63, 0xD2, 0xFB };
     byte[] text           = new byte[] { 0xDC, 0xEE, 0x4C, 0xF9, 0x2C };
     byte[] expectedCipher = new byte[] { 0xF1, 0x38, 0x29, 0xC9, 0xDE };
     byte[] cipher         = RC4.Encrypt(key, text);
     return(ByteUtils.AreByteArraysEqual(cipher, expectedCipher));
 }
Ejemplo n.º 10
0
 public void Test2()
 {
     byte[] key            = new byte[] { 0x61, 0x8A, 0x63, 0xD2, 0xFB };
     byte[] text           = new byte[] { 0xDC, 0xEE, 0x4C, 0xF9, 0x2C };
     byte[] expectedCipher = new byte[] { 0xF1, 0x38, 0x29, 0xC9, 0xDE };
     byte[] cipher         = RC4.Encrypt(key, text);
     Assert.IsTrue(ByteUtils.AreByteArraysEqual(cipher, expectedCipher));
 }
Ejemplo n.º 11
0
 public void Test1()
 {
     byte[] key            = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
     byte[] text           = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
     byte[] expectedCipher = { 0x74, 0x94, 0xC2, 0xE7, 0x10, 0x4B, 0x08, 0x79 };
     byte[] cipher         = RC4.Encrypt(key, text);
     Assert.True(ByteUtils.AreByteArraysEqual(cipher, expectedCipher));
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Cita bazu podataka.
        /// </summary>
        /// <returns> Mapirani podaci u recniku. </returns>
        public Dictionary <byte[], byte[]> Read()
        {
            string id            = "";              // Promenljiva id cuva id pronadjenog elementa.
            string name          = "";              // Promenljiva name cuva ime pronadjenog elementa.
            bool   element_added = true;            // Promenljiva element_added javlja kada je element dodat.

            byte[] b = new byte[1];
            Dictionary <byte[], byte[]> elements = new Dictionary <byte[], byte[]>();

            if (File.Exists("Informations.xml"))
            {
                XmlReader xmlReader = XmlReader.Create("Informations.xml");

                while (xmlReader.Read())
                {
                    if (id != "" && name != "")                             // Kada su promenljive id i name neprazni stringovi novi element je pronadjen.
                    {
                        string key           = "burek";
                        byte[] keyB          = Encoding.ASCII.GetBytes(key);
                        byte[] nameB         = Encoding.ASCII.GetBytes(name);
                        byte[] idB           = Encoding.ASCII.GetBytes(id);
                        byte[] encrpytedName = RC4.Encrypt(keyB, nameB);
                        byte[] encrpytedId   = RC4.Encrypt(keyB, idB);

                        elements.Add(encrpytedId, encrpytedName);           // Dodavanje elementa u listu elemenata.

                        if (element_added == true)                          // Resetovanje vrednosti promenljivih id i name nakon sto je element pronadjen.
                        {
                            id   = "";
                            name = "";
                        }
                    }
                    else if (xmlReader.Name == "ID")
                    {
                        xmlReader.Read();

                        id = xmlReader.Value;

                        xmlReader.Read();
                    }
                    else if (xmlReader.Name == "Name")
                    {
                        xmlReader.Read();

                        name = xmlReader.Value;

                        xmlReader.Read();
                    }
                }

                xmlReader.Close();                  // Zatvaranje XmlReader-a.
            }

            return(elements);
        }
        /// <summary>
        /// GUARDA EN EL ARCHIVO PARAMETERS.MIT, EL PARAMETRO INDICADO
        /// </summary>
        /// <param name="parametro">parametro a guardar</param>
        /// <param name="valor">valor del parametro</param>
        /// <returns></returns>
        public static bool GuardaParametrosMIT(string parametro, string valor)
        {
            bool   guardar   = false;
            string parameter = "";
            string text;
            string file;
            string ruta;

            ruta = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            file = System.IO.Path.Combine(ruta + "\\MIT\\Data", "parameters.mit");

            //se verica que exista el archivo
            if (!System.IO.File.Exists(file))
            {
                if (CreaCarpetaMIT())
                {
                    System.IO.File.Create(file);
                }
            }


            text = System.IO.File.ReadAllText(file);

            //DESCIFRA EL CONTENIDO DEL ARCHIVO PARAMETERS.MIT
            text = RC4.Decrypt(text, Info.RC4Key);

            //SE OBTIENE EL VALOR DEL XML
            parameter = GetDataXML(parametro, text);

            //se sustituye el valor anterior
            string valorOriginal = "";
            string valorNuevo    = "";

            if (!parameter.Equals(""))
            {
                valorOriginal = "<" + parametro + ">" + parameter + "</" + parametro + ">";
                valorNuevo    = "<" + parametro + ">" + valor + "</" + parametro + ">";
                text          = text.Replace(valorOriginal, valorNuevo);
            }
            else
            {
                valorOriginal = "<" + parametro + ">" + parameter + "</" + parametro + ">";
                valorNuevo    = "<" + parametro + ">" + valor + "</" + parametro + ">";
                text          = text.Replace(valorOriginal, "");
                text          = text + valorNuevo;
            }


            //se guarda el archivo nuevamente
            System.IO.File.WriteAllText(file, RC4.Encrypt(text, Info.RC4Key));

            return(guardar);
        }
Ejemplo n.º 14
0
        public static void DoRC4(string txt, string pass, int count)
        {
            var rc4 = new RC4(pass);

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
            for (int i = 0; i < count; i++)
            {
                rc4.Encrypt(txt);
            }
            stopwatch.Stop();
            Console.WriteLine("RC4  => " + stopwatch.ElapsedMilliseconds.ToString() + "ms");
        }
Ejemplo n.º 15
0
        public byte[] Serialize()
        {
            MessageHead.msg_id = (UInt16)MsgID;

            MessageHead.uid        = (UInt64)UID;
            MessageHead.option_ver = 0;

            byte[] sendData = SerializeData();
            sendData = Snappy.Sharp.Snappy.Compress(sendData); // snappy 压缩pb
            // 加密
            sendData = RC4.Encrypt(Encoding.ASCII.GetBytes(encryKey.ToCharArray()), sendData);

            /*
             * //////////////////////////////////////
             * byte[] testData = new byte[sendData.Length];
             * Array.Copy(sendData, 0, testData, 0, sendData.Length);
             * testData = RC4.Decrypt(Encoding.ASCII.GetBytes(encryKey.ToCharArray()), testData);
             * testData = Snappy.Sharp.Snappy.Uncompress(testData);
             * var test = InfibrProtoBuf.Serializer.Deserialize<Battle.GetBattleDataRequest>(new MemoryStream(testData, 0, testData.Length));
             * Log.Error("dddddd=" + Encoding.UTF8.GetString(test.room_id));
             *
             * /////////////////////////////////////////
             */

            MessageHead.msg_len = (uint)sendData.Length;

            int headSize = Marshal.SizeOf(typeof(CommonPackHead));

            int optLen = appendData.Length;

            MessageHead.option_len = (byte)optLen;
            MessageHead.msg_len    = MessageHead.msg_len + (uint)headSize + MessageHead.option_len;

            byte[] bufferArray = new byte[MessageHead.msg_len];

            IntPtr buffPtr = Marshal.AllocHGlobal(headSize);

            Marshal.StructureToPtr(MessageHead, buffPtr, false);

            Marshal.Copy(buffPtr, bufferArray, 0, headSize);
            Marshal.FreeHGlobal(buffPtr);

            Array.Copy(appendData, 0, bufferArray, headSize, MessageHead.option_len);

            Array.Copy(sendData, 0, bufferArray, headSize + MessageHead.option_len, sendData.Length);

            //var hex = BitConverter.ToString(bufferArray, 0).ToLower();


            return(bufferArray);
        }
        public byte[] Encode()
        {
            var packet = "313f";
            var s      = Convert.ToString((int)Type, 2);

            if (s.Length != 3)
            {
                s = s.PadLeft(3 - s.Length + 1, '0');
            }
            var iii = 0;

            foreach (var fl in Flags)
            {
                iii += (int)fl;
            }
            var s1 = Convert.ToString(iii, 2);

            if (s1.Length != 5)
            {
                s1 = s1.PadLeft(5 - s1.Length + 1, '0');
            }
            var typenflags = s1 + s;

            int[] bits = typenflags.PadLeft(8, '0').Select(c => int.Parse(c.ToString())).ToArray();
            var   b    = bits.ToBitArray().ToHex();

            packet += b;    //type and flags
            packet += "00"; //sessionid
            if (Type != PacketTypes.DATA)
            {
                packet += ConnectionSignature; //connection signature
            }
            else
            {
                packet += "5790aecd"; //cdae9057
            }
            packet += "00";           // "db44870f";
            packet += "0001";         //packet number
            //packet += ConnectionSignature; //encrypted empty payload, static//my head hurts....
            packet += "db44870f";
            if (!string.IsNullOrEmpty(Payload))
            {
                packet += "00";
                Payload = PythonScript.CompressPacketPayload(RC4.Encrypt(Encoding.ASCII.GetBytes("CD&ML"), Payload.FromHex()).ToHex()).Result;
                packet += "02";
            }
            packet += Payload;
            packet += CalculateChecksum(packet); //calculate checksum to append at the end
            return(packet.FromHex());
        }
Ejemplo n.º 17
0
        static void _encryptMessage(string key, string message)
        {
            byte[] keyBytes     = Utils.BAFromString(key);
            byte[] messageBytes = Utils.BAFromString(message); // System.Text.Encoding.UTF8.GetBytes(message);
            byte[] cipher       = new byte[messageBytes.Length];

            RC4 packer = new RC4(keyBytes);

            // TODO encrypt
            cipher = packer.Encrypt(messageBytes);

            // Output
            Console.WriteLine($"SHA1:{Utils.BAToString(packer.Hash(messageBytes))} CIPHER:{Utils.BAToString(cipher)}");
            Console.WriteLine();
        }
Ejemplo n.º 18
0
        public void Encrypt(string message, string keyText, string cipherTextHex)
        {
            var data = TextToBytes(message);
            var key  = TextToBytes(keyText);

            var result = RC4.Encrypt(key, data);

            var expectedBytes = HexToBytes(cipherTextHex);

            Assert.Equal(expectedBytes, result);

            var reversed = RC4.Encrypt(key, result);

            Assert.Equal(data, reversed);
        }
        public static bool EncriptaBines(string fileName)
        {
            string text;

            if (System.IO.File.Exists(fileName))
            {
                text = System.IO.File.ReadAllText(fileName);
                text = RC4.Encrypt(text, Info.RC4Key);

                //se guarda el archivo
                System.IO.File.WriteAllText(fileName, text);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 20
0
        public static void Main(string[] args)
        {
            // Load config
            var configBuilder = new ConfigurationBuilder()
                                .SetBasePath(PlatformServices.Default.Application.ApplicationBasePath)
                                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            var config      = configBuilder.Build();
            var dataFeedKey = config.GetSection("FoxyCart")["ApiKey"];
            var dataFeedUrl = config.GetSection("FoxyCart")["DataFeedUrl"];


            //Load plain XML data
            string transactionData = File.ReadAllText("FoxyData.xml");

            var encryptedTransactionData = RC4.Encrypt(Encoding.UTF8.GetBytes(dataFeedKey), Encoding.UTF8.GetBytes(transactionData));
            var encodedBytes             = WebUtility.UrlEncodeToBytes(encryptedTransactionData, 0, encryptedTransactionData.Length);

            using (var client = new HttpClient())
            {
                var requestContent = new MultipartFormDataContent();
                var dataContent    = new ByteArrayContent(encodedBytes);
                dataContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");

                requestContent.Add(dataContent, "FoxyData");

                try
                {
                    var responseTask = client.PostAsync(dataFeedUrl, requestContent);
                    responseTask.Wait();
                    var response = responseTask.Result;

                    var messageTask = response.Content.ReadAsStringAsync();
                    messageTask.Wait();
                    Console.WriteLine($"Result from server: {messageTask.Result}");
                }
                catch (WebException ex)
                {
                    string err = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
                    Console.WriteLine(err);
                }
            }

            Console.ReadKey();
        }
Ejemplo n.º 21
0
        private void HandleRequest(object state)
        {
            try
            {
                var context = (HttpListenerContext)state;

                main.LogLine(string.Format("{0}\t{1}\t{2}\t{3}\t{4}", context.Request.HttpMethod, context.Request.RawUrl, context.Request.RemoteEndPoint.Address.ToString(), context.Request.UserAgent,
                    DateTime.Now.ToString()));

                context.Response.StatusCode = 200;
                context.Response.SendChunked = false;
                context.Response.KeepAlive = false;

                byte[] buf = getPayload(context);

                buf = gzip.Decompress(RC4.Decrypt(Encoding.ASCII.GetBytes(Global.Key), buf));
                if (buf == null)
                {
                    context.Response.Close();
                    return;
                }

                string cmd = ProcessText(Encoding.ASCII.GetString(buf));
                if (cmd == null)
                {
                    context.Response.Close();
                    return;
                }

                buf = RC4.Encrypt(Encoding.ASCII.GetBytes(Global.Key), gzip.Compress(Encoding.ASCII.GetBytes(cmd)));
                context.Response.ContentType = "application/octet-stream";
                context.Response.ContentLength64 = buf.Length;
                context.Response.OutputStream.Write(buf, 0, buf.Length);

                context.Response.Close();
            }
            catch (Exception ex)
            {
                main.LogLine(ex.Message);
            }
        }
Ejemplo n.º 22
0
        public static List <DocumentModel> EncryptDocumentReducer(List <DocumentModel> previousState, EncryptAction action)
        {
            var isUserLoggedIn   = App.Store.GetState().UserProfile != null;
            var documentService  = new DocumentService(App.Store.GetState().DocumentConnectionString);
            var userService      = new UserService(App.Store.GetState().UserConnectionString);
            var newListDocuments = previousState;

            foreach (var document in action.createDocumentParams)
            {
                if (!File.Exists(document.Path) || !CanReadFile.Check(document.Path))
                {
                    continue;
                }
                var rc4 = new RC4(document.Password.Trim(), File.ReadAllBytes(document.Path));
                var encryptedFileRaw  = rc4.Encrypt();
                var newDocumentName   = string.Join("_", Path.GetFileNameWithoutExtension(document.Path), string.Format("{0:yyyy-MM-dd_hh-mm-ss-fff}", DateTime.Now));
                var encryptedFilePath = Path.Combine(App.Store.GetState().DocumentFolder, newDocumentName);
                File.WriteAllBytes(encryptedFilePath, encryptedFileRaw);
                var documentId       = document.Id == Guid.Empty ? Guid.NewGuid() : document.Id;
                var encyptedDocument = new DocumentModel
                {
                    Id          = documentId,
                    Path        = encryptedFilePath,
                    IsEncrypted = true,
                    Name        = Path.GetFileName(newDocumentName),
                    Password    = document.Password.Trim(),
                    FileExt     = Path.GetExtension(document.Path)
                };
                if (isUserLoggedIn)
                {
                    documentService.CreateOrUpdate(encyptedDocument);
                    userService.UpdateUserDocument(App.Store.GetState().UserProfile.Id, documentId);
                }
                else
                {
                    newListDocuments.Add(encyptedDocument);
                }
            }
            return(newListDocuments);
        }
Ejemplo n.º 23
0
        private static Boolean saveFile(String Log)
        {
            try
            {
                if (llave.Equals(""))
                {
                    if (string.IsNullOrEmpty(TypeUsuario.User))
                    {
                        llave = Info.keyLog;
                    }
                    else
                    {
                        llave = TypeUsuario.User.Substring(0, 4) + Info.keyLog + TypeUsuario.User.Substring(4);
                    }
                }

                cadenaCifrada = "";

                String path = Directory.GetCurrentDirectory();
                if (!Directory.Exists(path + "\\Log"))
                {
                    Directory.CreateDirectory(path + "\\Log");
                }

                StreamWriter writer = File.AppendText(path + "\\Log" + "\\dll" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + ".log");
                cadenaCifrada = RC4.Encrypt(Log, llave);
                writer.WriteLine(cadenaCifrada);
                writer.WriteLine("--------------------------------------------");
                writer.Close();
                return(true);
            }
            catch (IOException ex)
            {
                Console.WriteLine(ex.ToString());
                return(false);
            }
        }
        public async Task <LoginReponse> Handle(VerifyUserCommand request, CancellationToken cancellationToken)
        {
            var             handler = new JwtSecurityTokenHandler();
            StaffAccountDto account = await _userRepository.GetStaffAccountfByUsernameAndPassword(request.Username, request.Password);

            if (account == null)
            {
                return(new LoginReponse()
                {
                    StaffInfomation = null,
                    Message = "Username or Password is wrong.",
                    Token = string.Empty
                });
            }

            StaffDto staffInfomation = await _userRepository.GetStaffByStaffId(account.staff_id);

            return(new LoginReponse()
            {
                Message = "Login success.",
                StaffInfomation = staffInfomation,
                Token = RC4.Encrypt(staffInfomation.position.ToString())
            });
        }
Ejemplo n.º 25
0
 public static bool Test3()
 {
     byte[] key = new byte[] { 0x29, 0x04, 0x19, 0x72, 0xFB, 0x42, 0xBA, 0x5F,
                               0xC7, 0x12, 0x77, 0x12, 0xF1, 0x38, 0x29, 0xC9 };
     byte[] text = new byte[] { 0x52, 0x75, 0x69, 0x73, 0x6c, 0x69, 0x6e, 0x6e,
                                0x75, 0x6e, 0x20, 0x6c, 0x61, 0x75, 0x6c, 0x75,
                                0x20, 0x6b, 0x6f, 0x72, 0x76, 0x69, 0x73, 0x73,
                                0x73, 0x61, 0x6e, 0x69, 0x2c, 0x20, 0x74, 0xe4,
                                0x68, 0x6b, 0xe4, 0x70, 0xe4, 0x69, 0x64, 0x65,
                                0x6e, 0x20, 0x70, 0xe4, 0xe4, 0x6c, 0x6c, 0xe4,
                                0x20, 0x74, 0xe4, 0x79, 0x73, 0x69, 0x6b, 0x75,
                                0x75, 0x2e, 0x20, 0x4b, 0x65, 0x73, 0xe4, 0x79,
                                0xf6, 0x6e, 0x20, 0x6f, 0x6e, 0x20, 0x6f, 0x6e,
                                0x6e, 0x69, 0x20, 0x6f, 0x6d, 0x61, 0x6e, 0x61,
                                0x6e, 0x69, 0x2c, 0x20, 0x6b, 0x61, 0x73, 0x6b,
                                0x69, 0x73, 0x61, 0x76, 0x75, 0x75, 0x6e, 0x20,
                                0x6c, 0x61, 0x61, 0x6b, 0x73, 0x6f, 0x74, 0x20,
                                0x76, 0x65, 0x72, 0x68, 0x6f, 0x75, 0x75, 0x2e,
                                0x20, 0x45, 0x6e, 0x20, 0x6d, 0x61, 0x20, 0x69,
                                0x6c, 0x6f, 0x69, 0x74, 0x73, 0x65, 0x2c, 0x20,
                                0x73, 0x75, 0x72, 0x65, 0x20, 0x68, 0x75, 0x6f,
                                0x6b, 0x61, 0x61, 0x2c, 0x20, 0x6d, 0x75, 0x74,
                                0x74, 0x61, 0x20, 0x6d, 0x65, 0x74, 0x73, 0xe4,
                                0x6e, 0x20, 0x74, 0x75, 0x6d, 0x6d, 0x75, 0x75,
                                0x73, 0x20, 0x6d, 0x75, 0x6c, 0x6c, 0x65, 0x20,
                                0x74, 0x75, 0x6f, 0x6b, 0x61, 0x61, 0x2e, 0x20,
                                0x50, 0x75, 0x75, 0x6e, 0x74, 0x6f, 0x20, 0x70,
                                0x69, 0x6c, 0x76, 0x65, 0x6e, 0x2c, 0x20, 0x6d,
                                0x69, 0x20, 0x68, 0x75, 0x6b, 0x6b, 0x75, 0x75,
                                0x2c, 0x20, 0x73, 0x69, 0x69, 0x6e, 0x74, 0x6f,
                                0x20, 0x76, 0x61, 0x72, 0x61, 0x6e, 0x20, 0x74,
                                0x75, 0x75, 0x6c, 0x69, 0x73, 0x65, 0x6e, 0x2c,
                                0x20, 0x6d, 0x69, 0x20, 0x6e, 0x75, 0x6b, 0x6b,
                                0x75, 0x75, 0x2e, 0x20, 0x54, 0x75, 0x6f, 0x6b,
                                0x73, 0x75, 0x74, 0x20, 0x76, 0x61, 0x6e, 0x61,
                                0x6d, 0x6f, 0x6e, 0x20, 0x6a, 0x61, 0x20, 0x76,
                                0x61, 0x72, 0x6a, 0x6f, 0x74, 0x20, 0x76, 0x65,
                                0x65, 0x6e, 0x2c, 0x20, 0x6e, 0x69, 0x69, 0x73,
                                0x74, 0xe4, 0x20, 0x73, 0x79, 0x64, 0xe4, 0x6d,
                                0x65, 0x6e, 0x69, 0x20, 0x6c, 0x61, 0x75, 0x6c,
                                0x75, 0x6e, 0x20, 0x74, 0x65, 0x65, 0x6e, 0x2e,
                                0x20, 0x2d, 0x20, 0x45, 0x69, 0x6e, 0x6f, 0x20,
                                0x4c, 0x65, 0x69, 0x6e, 0x6f };
     byte[] expectedCipher = new byte[] { 0x35, 0x81, 0x86, 0x99, 0x90, 0x01, 0xe6, 0xb5,
                                          0xda, 0xf0, 0x5e, 0xce, 0xeb, 0x7e, 0xee, 0x21,
                                          0xe0, 0x68, 0x9c, 0x1f, 0x00, 0xee, 0xa8, 0x1f,
                                          0x7d, 0xd2, 0xca, 0xae, 0xe1, 0xd2, 0x76, 0x3e,
                                          0x68, 0xaf, 0x0e, 0xad, 0x33, 0xd6, 0x6c, 0x26,
                                          0x8b, 0xc9, 0x46, 0xc4, 0x84, 0xfb, 0xe9, 0x4c,
                                          0x5f, 0x5e, 0x0b, 0x86, 0xa5, 0x92, 0x79, 0xe4,
                                          0xf8, 0x24, 0xe7, 0xa6, 0x40, 0xbd, 0x22, 0x32,
                                          0x10, 0xb0, 0xa6, 0x11, 0x60, 0xb7, 0xbc, 0xe9,
                                          0x86, 0xea, 0x65, 0x68, 0x80, 0x03, 0x59, 0x6b,
                                          0x63, 0x0a, 0x6b, 0x90, 0xf8, 0xe0, 0xca, 0xf6,
                                          0x91, 0x2a, 0x98, 0xeb, 0x87, 0x21, 0x76, 0xe8,
                                          0x3c, 0x20, 0x2c, 0xaa, 0x64, 0x16, 0x6d, 0x2c,
                                          0xce, 0x57, 0xff, 0x1b, 0xca, 0x57, 0xb2, 0x13,
                                          0xf0, 0xed, 0x1a, 0xa7, 0x2f, 0xb8, 0xea, 0x52,
                                          0xb0, 0xbe, 0x01, 0xcd, 0x1e, 0x41, 0x28, 0x67,
                                          0x72, 0x0b, 0x32, 0x6e, 0xb3, 0x89, 0xd0, 0x11,
                                          0xbd, 0x70, 0xd8, 0xaf, 0x03, 0x5f, 0xb0, 0xd8,
                                          0x58, 0x9d, 0xbc, 0xe3, 0xc6, 0x66, 0xf5, 0xea,
                                          0x8d, 0x4c, 0x79, 0x54, 0xc5, 0x0c, 0x3f, 0x34,
                                          0x0b, 0x04, 0x67, 0xf8, 0x1b, 0x42, 0x59, 0x61,
                                          0xc1, 0x18, 0x43, 0x07, 0x4d, 0xf6, 0x20, 0xf2,
                                          0x08, 0x40, 0x4b, 0x39, 0x4c, 0xf9, 0xd3, 0x7f,
                                          0xf5, 0x4b, 0x5f, 0x1a, 0xd8, 0xf6, 0xea, 0x7d,
                                          0xa3, 0xc5, 0x61, 0xdf, 0xa7, 0x28, 0x1f, 0x96,
                                          0x44, 0x63, 0xd2, 0xcc, 0x35, 0xa4, 0xd1, 0xb0,
                                          0x34, 0x90, 0xde, 0xc5, 0x1b, 0x07, 0x11, 0xfb,
                                          0xd6, 0xf5, 0x5f, 0x79, 0x23, 0x4d, 0x5b, 0x7c,
                                          0x76, 0x66, 0x22, 0xa6, 0x6d, 0xe9, 0x2b, 0xe9,
                                          0x96, 0x46, 0x1d, 0x5e, 0x4d, 0xc8, 0x78, 0xef,
                                          0x9b, 0xca, 0x03, 0x05, 0x21, 0xe8, 0x35, 0x1e,
                                          0x4b, 0xae, 0xd2, 0xfd, 0x04, 0xf9, 0x46, 0x73,
                                          0x68, 0xc4, 0xad, 0x6a, 0xc1, 0x86, 0xd0, 0x82,
                                          0x45, 0xb2, 0x63, 0xa2, 0x66, 0x6d, 0x1f, 0x6c,
                                          0x54, 0x20, 0xf1, 0x59, 0x9d, 0xfd, 0x9f, 0x43,
                                          0x89, 0x21, 0xc2, 0xf5, 0xa4, 0x63, 0x93, 0x8c,
                                          0xe0, 0x98, 0x22, 0x65, 0xee, 0xf7, 0x01, 0x79,
                                          0xbc, 0x55, 0x3f, 0x33, 0x9e, 0xb1, 0xa4, 0xc1,
                                          0xaf, 0x5f, 0x6a, 0x54, 0x7f };
     byte[] cipher = RC4.Encrypt(key, text);
     return(ByteUtils.AreByteArraysEqual(cipher, expectedCipher));
 }
Ejemplo n.º 26
0
        private UnityWebRequest QueryRequest(string query, object variables)
        {
            var fullQuery = new GraphQLQuery()
            {
                query     = query,
                variables = variables,
            };

            string          json    = JsonConvert.SerializeObject(fullQuery, Formatting.None);
            UnityWebRequest request = UnityWebRequest.Post(url, UnityWebRequest.kHttpVerbPOST);

            byte[] payload = Encoding.UTF8.GetBytes(CloudSaveSettings.Encrypted ? Convert.ToBase64String(RC4.Encrypt(json, CloudSaveSettings.Key)) : json);
            request.uploadHandler = new UploadHandlerRaw(payload);
            request.SetRequestHeader("Content-Type", "application/memorycloud.custom-type");

            request.SetRequestHeader("Authorization", "Bearer " + AccessToken.CurrentAccessToken.TokenString);
            request.SetRequestHeader("AppId", FB.AppId);

            return(request);
        }
        public void RC4Encryption(FileInfo file, FormModel model)
        {
            bool threadSuccesfull = false;
            var  timeStarted      = DateTime.Now;

            try
            {
                //OutputFileName
                string outputFileName = FileNameCreator.CreateFileEncryptedName(
                    model.Folders.OutputFolder,
                    file.Name,
                    model.AlgorithmName);

                //Log
                loggerController.Add(" ! File enc: " + file.Name + ", Alg: " + model.AlgorithmName);

                //Read a file char by char, and encrypt it
                using (FileStream fsr = new FileStream(file.FullName, FileMode.Open))
                {
                    using (BinaryReader br = new BinaryReader(fsr, new ASCIIEncoding()))
                    {
                        using (FileStream fsw = new FileStream(outputFileName, FileMode.Create))
                        {
                            using (BinaryWriter bw = new BinaryWriter(fsw, new ASCIIEncoding()))
                            {
                                //Writing the extension
                                char[] extension       = file.Extension.Substring(1, file.Extension.Length - 1).ToCharArray();
                                char   extensionLength = (char)extension.Length;
                                bw.Write(extensionLength);
                                for (var k = 0; k < extension.Length; k++)
                                {
                                    bw.Write(extension[k]);
                                }

                                //Reading and encrypting files
                                int    i          = 0;
                                int    j          = 0;
                                byte[] state      = RC4.KSA();
                                byte   inputValue = 0;
                                while (br.BaseStream.Position < br.BaseStream.Length)
                                {
                                    //ENC
                                    inputValue = br.ReadByte();
                                    byte prga           = RC4.PRGA(ref i, ref j, ref state);
                                    byte encryptedValue = RC4.Encrypt(inputValue, prga);
                                    bw.Write(encryptedValue);

                                    if (LoadedFilesController._END_OF_ENC_DEC_THREADS)
                                    {
                                        bw.Dispose();
                                        fsw.Dispose();
                                        br.Dispose();
                                        fsr.Dispose();
                                        File.Delete(outputFileName);
                                        Thread.CurrentThread.Abort();
                                    }
                                }
                            }
                        }
                    }
                }
                threadSuccesfull = true;
                Thread.Sleep(250);
            }
            catch (Exception ex)
            {
                loggerController.Add(" ? Enc exception: " + ex.Message);
                threadSuccesfull = false;
            }
            finally
            {
                this.ThreadEnds(file, threadSuccesfull, timeStarted);
            }
        }
Ejemplo n.º 28
0
        public static byte[]? GetAuthenticateMessage(byte[] securityBlob, string domainName, string userName, string password, AuthenticationMethod authenticationMethod, out byte[]?sessionKey)
        {
            sessionKey = null;
            bool useGssApi = false;
            SimpleProtectedNegotiationTokenResponse?inputToken = null;

            try
            {
                inputToken = SimpleProtectedNegotiationToken.ReadToken(securityBlob, 0, false) as SimpleProtectedNegotiationTokenResponse;
            }
            catch
            {
                // ignored
            }

            ChallengeMessage?challengeMessage;

            if (inputToken != null)
            {
                challengeMessage = GetChallengeMessage(inputToken.ResponseToken);
                useGssApi        = true;
            }
            else
            {
                challengeMessage = GetChallengeMessage(securityBlob);
            }

            if (challengeMessage == null)
            {
                return(null);
            }

            DateTime time = DateTime.UtcNow;

            byte[] clientChallenge = new byte[8];
            new Random().NextBytes(clientChallenge);

            AuthenticateMessage authenticateMessage = new AuthenticateMessage
            {
                // https://msdn.microsoft.com/en-us/library/cc236676.aspx
                NegotiateFlags = NegotiateFlags.Sign |
                                 NegotiateFlags.NTLMSessionSecurity |
                                 NegotiateFlags.AlwaysSign |
                                 NegotiateFlags.Version |
                                 NegotiateFlags.Use128BitEncryption |
                                 NegotiateFlags.Use56BitEncryption
            };

            if ((challengeMessage.NegotiateFlags & NegotiateFlags.UnicodeEncoding) > 0)
            {
                authenticateMessage.NegotiateFlags |= NegotiateFlags.UnicodeEncoding;
            }
            else
            {
                authenticateMessage.NegotiateFlags |= NegotiateFlags.OEMEncoding;
            }

            if ((challengeMessage.NegotiateFlags & NegotiateFlags.KeyExchange) > 0)
            {
                authenticateMessage.NegotiateFlags |= NegotiateFlags.KeyExchange;
            }

            if (authenticationMethod == AuthenticationMethod.NtlmV1)
            {
                authenticateMessage.NegotiateFlags |= NegotiateFlags.LanManagerSessionKey;
            }
            else
            {
                authenticateMessage.NegotiateFlags |= NegotiateFlags.ExtendedSessionSecurity;
            }

            authenticateMessage.UserName    = userName;
            authenticateMessage.DomainName  = domainName;
            authenticateMessage.WorkStation = Environment.MachineName;
            byte[] sessionBaseKey;
            byte[] keyExchangeKey;
            if (authenticationMethod == AuthenticationMethod.NtlmV1 || authenticationMethod == AuthenticationMethod.NtlmV1ExtendedSessionSecurity)
            {
                if (authenticationMethod == AuthenticationMethod.NtlmV1)
                {
                    authenticateMessage.LmChallengeResponse = NtlmCryptography.ComputeLMv1Response(challengeMessage.ServerChallenge, password);
                    authenticateMessage.NtChallengeResponse = NtlmCryptography.ComputeNTLMv1Response(challengeMessage.ServerChallenge, password);
                }
                else // NtlmV1ExtendedSessionSecurity
                {
                    authenticateMessage.LmChallengeResponse = ByteUtils.Concatenate(clientChallenge, new byte[16]);
                    authenticateMessage.NtChallengeResponse = NtlmCryptography.ComputeNTLMv1ExtendedSessionSecurityResponse(challengeMessage.ServerChallenge, clientChallenge, password);
                }
                // https://msdn.microsoft.com/en-us/library/cc236699.aspx
                sessionBaseKey = new MD4().GetByteHashFromBytes(NtlmCryptography.NTOWFv1(password));
                byte[] lmowf = NtlmCryptography.LMOWFv1(password);
                keyExchangeKey = NtlmCryptography.KXKey(sessionBaseKey, authenticateMessage.NegotiateFlags, authenticateMessage.LmChallengeResponse, challengeMessage.ServerChallenge, lmowf);
            }
            else // NtlmV2
            {
                NTLMv2ClientChallenge clientChallengeStructure = new NTLMv2ClientChallenge(time, clientChallenge, challengeMessage.TargetInfo);
                byte[] clientChallengeStructurePadded          = clientChallengeStructure.GetBytesPadded();
                byte[] ntProofStr = NtlmCryptography.ComputeNTLMv2Proof(challengeMessage.ServerChallenge, clientChallengeStructurePadded, password, userName, domainName);

                authenticateMessage.LmChallengeResponse = NtlmCryptography.ComputeLMv2Response(challengeMessage.ServerChallenge, clientChallenge, password, userName, challengeMessage.TargetName);
                authenticateMessage.NtChallengeResponse = ByteUtils.Concatenate(ntProofStr, clientChallengeStructurePadded);

                // https://msdn.microsoft.com/en-us/library/cc236700.aspx
                byte[] responseKeyNT = NtlmCryptography.NTOWFv2(password, userName, domainName);
                using HMACMD5 md5 = new HMACMD5(responseKeyNT);
                sessionBaseKey    = md5.ComputeHash(ntProofStr);
                keyExchangeKey    = sessionBaseKey;
            }
            authenticateMessage.Version = NtlmVersion.Server2003;

            // https://msdn.microsoft.com/en-us/library/cc236676.aspx
            if ((challengeMessage.NegotiateFlags & NegotiateFlags.KeyExchange) > 0)
            {
                sessionKey = new byte[16];
                new Random().NextBytes(sessionKey);
                authenticateMessage.EncryptedRandomSessionKey = RC4.Encrypt(keyExchangeKey, sessionKey);
            }
            else
            {
                sessionKey = keyExchangeKey;
            }

            if (!useGssApi)
            {
                return(authenticateMessage.GetBytes());
            }

            SimpleProtectedNegotiationTokenResponse outputToken = new SimpleProtectedNegotiationTokenResponse
            {
                ResponseToken = authenticateMessage.GetBytes()
            };

            return(outputToken.GetBytes());
        }
Ejemplo n.º 29
0
        private static void HandlePacket(byte[] packet, ref IPEndPoint sender)
        {
            PrintByteArray(packet);
            _packet.ReadPacket(packet);
            if (_packet.Flags.HasFlag(V0_Flags.FLAG_NEED_ACK) && _packet.Type == V0_Type.SYN)
            {
                _packet.Source      = 1;
                _packet.Destination = 15;

                _packet.Flags = V0_Flags.FLAG_ACK;
                _packet.ConnectionSignature = 0xAAAAAAAA;

                packet = _packet.CreatePacket();

                _udpClient.Send(packet, packet.Length, sender);

                Console.WriteLine("ACK0\n");
            }
            else if (_packet.Flags.HasFlag(V0_Flags.FLAG_RELIABLE) && _packet.Flags.HasFlag(V0_Flags.FLAG_NEED_ACK) && _packet.Type == V0_Type.CONNECT)
            {
                _packet.Source      = 1;
                _packet.Destination = 15;

                _packet.Flags = V0_Flags.FLAG_ACK;

                packet = _packet.CreatePacket();

                _udpClient.Send(packet, packet.Length, sender);

                Console.WriteLine("ACK1\n");
            }
            else if (_packet.Flags.HasFlag(V0_Flags.FLAG_RELIABLE) && _packet.Flags.HasFlag(V0_Flags.FLAG_NEED_ACK) && _packet.Type == V0_Type.DATA)
            {
                _packet.Source      = 1;
                _packet.Destination = 15;

                _packet.Flags = V0_Flags.FLAG_ACK;

                packet = _packet.CreatePacket();

                _udpClient.Send(packet, packet.Length, sender);

                Console.WriteLine("ACK2\n");

                _packet.Source      = 1;
                _packet.Destination = 15;

                _packet.Flags = V0_Flags.FLAG_RELIABLE | V0_Flags.FLAG_NEED_ACK;

                using (MemoryStream stream = new MemoryStream(RC4.Decrypt(Encoding.ASCII.GetBytes("CD&ML"), _packet.Payload)))
                    using (BinaryReader reader = new BinaryReader(stream))
                    {
                        reader.ReadUInt32();
                        reader.ReadByte();

                        uint callId = reader.ReadUInt32();

                        using (MemoryStream _stream = new MemoryStream())
                            using (BinaryWriter writer = new BinaryWriter(_stream))
                            {
                                writer.Write((uint)2 + 4 + 4);
                                writer.Write((byte)0x0A);
                                writer.Write((byte)0);

                                writer.Write(0x80010002);
                                writer.Write(callId);

                                _packet.Payload     = RC4.Encrypt(Encoding.ASCII.GetBytes("CD&ML"), _stream.ToArray());
                                _packet.PayloadSize = (ushort)_packet.Payload.Length;
                            }
                    }

                packet = _packet.CreatePacket();

                _udpClient.Send(packet, packet.Length, sender);
            }
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            NetTcpBinding binding = new NetTcpBinding();
            //binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
            string address = "net.tcp://localhost:5500/DataManagment";

            int    option     = 0;          // Promenljiva option u kojoj se skladisti izabrana opcija.
            string opt        = "";         // Promenljiva opt u kojoj se skladisti string reprezentacija odabrane opcije.
            bool   isOptValid = false;      // Promenljiva isOptValid u kojoj se belezi da je izabrana opcija validna.

            string privateKey = "burek";    // Kljuc za enkripciju i dekripciju podataka.

            byte[] keyb = Encoding.ASCII.GetBytes(privateKey);

            string           clientCertCN = Formatter.ParseName(WindowsIdentity.GetCurrent().Name);
            X509Certificate2 clientCert   = CertificateManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, clientCertCN);

            if (clientCert != null)
            {
                AuthenticationService authService = new AuthenticationService();

                Console.WriteLine("");

                using (ClientProxy clp = new ClientProxy(binding, address))
                {
                    while (option != 3)
                    {
                        Console.WriteLine("\t\t\t\t\t|=====================================|");        // Ispis glavnog menija.
                        Console.WriteLine("\t\t\t\t\t|              MAIN MENU              |");
                        Console.WriteLine("\t\t\t\t\t|-------------------------------------|");
                        Console.WriteLine("\t\t\t\t\t|                                     |");
                        Console.WriteLine("\t\t\t\t\t|              1. Write               |");
                        Console.WriteLine("\t\t\t\t\t|              2. Read                |");
                        Console.WriteLine("\t\t\t\t\t|              3. Exit                |");
                        Console.WriteLine("\t\t\t\t\t|                                     |");
                        Console.WriteLine("\t\t\t\t\t|=====================================|\n\n");

                        do  // Otkrivanje nevalidne vrednosti opcije.
                        {
                            Console.Write("Enter option number: ");
                            opt = Console.ReadLine();

                            isOptValid = int.TryParse(opt, out option);

                            if (isOptValid == false)                // Slucaj kada odabrana opcija nije numericka vrednost.
                            {
                                Console.WriteLine("\n---------------------");
                                Console.WriteLine("Invalid option value.");
                                Console.WriteLine("---------------------\n");
                            }
                            else if (option < 1 || option > 3)      // Odabrana opcija je van opsega. Odabir nepostojece opcije.
                            {
                                Console.WriteLine("\n----------------------------------");
                                Console.WriteLine("The entered option does not exist.");
                                Console.WriteLine("----------------------------------\n");
                            }
                        } while (isOptValid == false || option < 1 || option > 3);

                        switch (option)
                        {
                        case 1:
                        {
                            string id   = "";               // Promenljiva id u kojoj se skladisti vrednost za ID elementa.
                            string name = "";               // Promenljiva name u kojoj se skladisti vrednost za ime elementa.

                            Console.WriteLine("\n=======================================================================================================================");
                            Console.WriteLine("\t\t\t\t\t\t\t WRITE");               // Naznaka korisniku da je program usao u odabranu opciju.
                            Console.WriteLine("-----------------------------------------------------------------------------------------------------------------------\n");

                            do                                              // ID mora da ima najmanje 4 karaktera.
                            {
                                Console.Write("Enter ID: ");                // Unosenje i skladistenje ID-a elementa.
                                id = Console.ReadLine();

                                if (id.Length < 4)
                                {
                                    Console.WriteLine("\n---------------------------------------");
                                    Console.WriteLine("The ID must have at least 4 characters.");
                                    Console.WriteLine("---------------------------------------\n");
                                }
                            } while (id.Length < 4);

                            do                                              // Ime mora da ima najmanje 3 karaktera.
                            {
                                Console.Write("\nEnter name: ");            // Unosenje i skladistenje imena elementa.
                                name = Console.ReadLine();

                                if (name.Length < 3)
                                {
                                    Console.WriteLine("\n-----------------------------------------");
                                    Console.WriteLine("The name must have at least 3 characters.");
                                    Console.WriteLine("-----------------------------------------");
                                }
                            } while (name.Length < 3);

                            byte[] idB   = Encoding.ASCII.GetBytes(id);             // Enkodiranje ID-a i naziva elementa u niz byte-ova.
                            byte[] nameB = Encoding.ASCII.GetBytes(name);

                            byte[] idEnc   = RC4.Encrypt(keyb, idB);                // Enkriptovanje ID-a i naziva elementa.
                            byte[] nameEnc = RC4.Encrypt(keyb, nameB);

                            clp.Write(idEnc, nameEnc);                              // Prosledjivanje enkriptovanih podataka.

                            Console.WriteLine("\n-----------------------------------------------------------------------------------------------------------------------");
                            Console.WriteLine("\t\t\t\t   The specified element has been sucessfully added.");
                            Console.WriteLine("-----------------------------------------------------------------------------------------------------------------------");

                            Console.WriteLine("\n=======================================================================================================================\n\n"); // Naznaka korisniku da je zavrsen rad sa prvom opcijom.

                            break;                                                                                                                                              // Zavrsetak prve opcije.
                        }

                        case 2:                         // Prikazivanje svih elemenata koji se trenutno nalaze u bazi podataka.
                        {
                            Console.WriteLine("\n=======================================================================================================================");
                            Console.WriteLine("\t\t\t\t\t\t\t READ");
                            Console.WriteLine("-----------------------------------------------------------------------------------------------------------------------\n");

                            Dictionary <byte[], byte[]> dic = clp.Read(); // Poziva se metoda za citanje elemenata.

                            if (dic.Count == 0)                           // Ukoliko baza podataka ne postoji korisnik se obavestava o tome.
                            {
                                Console.WriteLine("-----------------------------------------------------------------------------------------------------------------------");
                                Console.WriteLine("\t\t       The data base does not exist. It will be created when an element is added.");
                                Console.WriteLine("-----------------------------------------------------------------------------------------------------------------------\n");
                            }
                            else
                            {
                                foreach (KeyValuePair <byte[], byte[]> kvp in dic)            // Ispis pronadjenih elemenata.
                                {
                                    byte[] keyDecrBytes   = RC4.Decrypt(keyb, kvp.Key);
                                    byte[] valueDecrBytes = RC4.Decrypt(keyb, kvp.Value);

                                    string idDecr    = Encoding.ASCII.GetString(keyDecrBytes);
                                    string valueDecr = Encoding.ASCII.GetString(valueDecrBytes);

                                    Console.WriteLine("------------------------------");
                                    Console.WriteLine("ID: {0}", idDecr);
                                    Console.WriteLine("Name: {0}", valueDecr);
                                    Console.WriteLine("------------------------------\n");
                                }
                            }

                            Console.WriteLine("=======================================================================================================================\n\n");

                            break;
                        }

                        case 3:                         // Izlazak iz programa.
                        {
                            clp.Close();

                            Console.WriteLine("\nPress any key to exit...");
                            Console.ReadLine();

                            break;
                        }
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("Client authentication falied. No certificate provided. Client can not be started.\n");
                Console.WriteLine("Press ENTER key to exit...");
                Console.ReadLine();
            }
        }