예제 #1
0
        /// <summary>
        /// Metodo que verifica si el software puede correr en la pc
        /// </summary>
        /// <param name="skeyp"></param>
        /// <returns></returns>
        public bool IsOkComputer(string skeyp)
        {
            var skey = skeyp.Replace('/', '3');
            if (!File.Exists("lic.lot"))
                return false;

            try
            {
                security = new Security();
                GCHandle gch = GCHandle.Alloc(skey, GCHandleType.Pinned);
                security.DecryptFile("lic.lot",
                   "tempL",
                   skey);

                gch.Free();

                var lista = File.ReadAllText("tempL").Split(new char[] { '*' },
                                                             StringSplitOptions.RemoveEmptyEntries);
                File.Delete("tempL");

                var user = lista[0];
                var number = lista[1].Remove(0,2);
                var otherNumbers = lista[2].Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                var mac = new List<string>();
                if (lista.Length == 4)
                    mac = lista[3].Split(new char[] {'\n', '\r'}, StringSplitOptions.RemoveEmptyEntries).ToList();

                //empezamos a verificar

                var vUser = UserName();
                var vNumberHdd = NumberHdd();
                var vOtherNumberHdd = OtherNumberHdd();
                var vMacsAddres = MacsAddres();//puede no estar habilitada

                if(otherNumbers.Count==0 && vNumberHdd==number)
                {
                    var list = new List<string>();
                    //list.Add(GetProcessorID()); list.Add("*");

                    list.Add(vUser + "*");
                    list.Add(vNumberHdd + "*");
                    list.AddRange(vOtherNumberHdd);
                    list.Add("*");
                    list.AddRange(vMacsAddres);

                    File.WriteAllLines("temp3", list);
                    skey = skey.Replace('/', '3');
                    GCHandle gch1 = GCHandle.Alloc(skey, GCHandleType.Pinned);

                    security.EncryptFile("temp3",
                       "lic.lot", skey);

                    gch1.Free();
                    File.Delete("temp3");

                    return true; 
                }
                //if (number != vNumberHdd)
                //    MessageBox.Show("Upss...Tenga en cuenta que el programa " +
                //                    "se ha ejecutado en una dirección diferente y necesita " +
                //                    "que su archivo de licencia esté en la misma dirección!");

                foreach (var otherNumber in otherNumbers)
                {
                    if (vOtherNumberHdd.Contains(otherNumber))
                    {
                        var list = new List<string>();
                        //list.Add(GetProcessorID()); list.Add("*");

                        list.Add(vUser + "*");
                        list.Add(vNumberHdd + "*");
                        list.AddRange(vOtherNumberHdd);
                        list.Add("*");
                        list.AddRange(vMacsAddres);

                        File.WriteAllLines("temp3", list);
                        skey = skey.Replace('/', '3');
                        GCHandle gch1 = GCHandle.Alloc(skey, GCHandleType.Pinned);

                        security.EncryptFile("temp3",
                           "lic.lot", skey);

                        gch1.Free();
                        File.Delete("temp3");

                        return true; //es el mismo disco duro
                    }
                }
                if(vMacsAddres.Count!=0)
                {
                    foreach (var m in mac)
                    {
                        if (vMacsAddres.Contains(m))
                        {
                            var list = new List<string>();
                            //list.Add(GetProcessorID()); list.Add("*");

                            list.Add(vUser + "*");
                            list.Add(vNumberHdd + "*");
                            list.AddRange(vOtherNumberHdd);
                            list.Add("*");
                            list.AddRange(vMacsAddres);

                            File.WriteAllLines("temp3", list);
                            skey = skey.Replace('/', '3');
                            GCHandle gch2 = GCHandle.Alloc(skey, GCHandleType.Pinned);

                            security.EncryptFile("temp3",
                               "lic.lot", skey);

                            gch2.Free();
                            File.Delete("temp3");

                            return true; //tiene la misma tarjeta de red
                        }
                    }
                }
                if(vUser==user)//es el mismo usuario porque ha cambiado de pc
                {
                    MessageBox.Show("Ha copiado el programa en otra PC." +
                                    " Contactar a: 53392127, Email: [email protected]/[email protected]/@yahoo.com/@hotmail.com" +
                                    " para que reciba otra licencia");
                    Random random = new Random();
                    var insertlicence = new Licence(random.Next(10000, 99999).ToString(),false);
                    insertlicence.ShowDialog();
                    if (!InsertLicence(insertlicence.GiveMeRandom(), insertlicence.GiveMeLicence(), skeyp,false))
                    {
                        MessageBox.Show("No está autorizado!");
                        SameUser = true;
                        return false;
                    }
                    return true;
                }
            }
            catch
            {
                return false;
            }
           

            return false;
        }
예제 #2
0
 private void Verify()
 {
     try
     {
         var skey = Lotto.TwoNumber("18", "04").str.Substring(0, 8);
         if (!computerData.IsOkComputer(skey))
         {
             var insertlicence1 = new Licence("", true);
             insertlicence1.ShowDialog();
             var serial = insertlicence1.GiveMeLicence();
             bool pass = false;
             foreach (var serial1 in Lotto.Serials)
             {
                 if (serial == serial1 && Lotto.SerialLic == Lotto.LinesSerialLic)
                 {
                     computerData.InsertLicence("12345", "225388804166", skey, true);
                     pass = true;
                 }
             }
             if (!pass)
             {
                 if (computerData.SameUser)
                 {
                     Close();
                     return;
                 }
                 Random random = new Random();
                 var insertlicence = new Licence(random.Next(10000, 99999).ToString(), false);
                 insertlicence.ShowDialog();
                 if (!computerData.InsertLicence(insertlicence.GiveMeRandom(),
                                                 insertlicence.GiveMeLicence(), skey, false))
                 {
                     MessageBox.Show(
                         "Contactar a: 53392127, Email: [email protected]/[email protected]/@yahoo.com/@hotmail.com",
                         "Licencia Inválida");
                     Close();
                 }
             }
         }
     }
     catch
     {
         MessageBox.Show("Problema al identificar el origen del programa", "Licencia Inválida");
         Close();
     }
 }