Exemple #1
0
        public static bool addkey_s(regentries entry, DataSet1 hi)
        {
            if (String.IsNullOrEmpty(entry.kvcrc))
            {
                return(false);
            }

            DataTable   cputable = hi.DataTable1;
            RegistryKey cpukeydb = Registry.CurrentUser.CreateSubKey("CPUKey_DB");

            foreach (string subkey in cpukeydb.GetSubKeyNames())
            {
                if (cpukeydb.OpenSubKey(subkey).GetValue("CRC_KV") != null)
                {
                    if (cpukeydb.OpenSubKey(subkey).GetValue("CRC_KV").ToString() == entry.kvcrc || cpukeydb.OpenSubKey(subkey).GetValue("Serial").ToString() == entry.serial)
                    {
                        Console.WriteLine("Key already Exists");
                        return(false);
                    }
                }
            }
            if (!String.IsNullOrEmpty(variables.custname))
            {
                entry.extra = variables.custname;
            }

            int index = Convert.ToInt32(cpukeydb.GetValue("Index")) + 1;

            cpukeydb.SetValue("Index", (object)index);
            RegistryKey cpukeys = cpukeydb.CreateSubKey(index.ToString());

            cpukeys.SetValue("Index", (object)index);
            cpukeys.SetValue("Serial", (object)entry.serial);
            cpukeys.SetValue("cpukey", (object)entry.cpukey);
            cpukeys.SetValue("CRC_KV", (object)entry.kvcrc);
            cpukeys.SetValue("DVDKey", (object)entry.dvdkey);
            cpukeys.SetValue("Region", (object)entry.region);
            cpukeys.SetValue("OSIG", (object)entry.osig);
            cpukeys.SetValue("Mobo", (object)entry.extra);


            DataRow cpurow = cputable.NewRow();

            cpurow[0] = index;
            cpurow[1] = entry.serial;
            cpurow[2] = entry.cpukey;
            cpurow[3] = entry.kvcrc;
            cpurow[4] = entry.extra;
            cpurow[5] = entry.dvdkey;
            cpurow[6] = entry.region;
            cpurow[7] = entry.osig;

            try
            {
                cputable.Rows.Add(cpurow);
            }
            catch (System.Data.ConstraintException) { }
            Console.WriteLine("Added Key to Database");
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Manual Add value
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            AddCpuKey myNewForm = new AddCpuKey();

            myNewForm.ShowDialog();
            if (myNewForm.DialogResult != DialogResult.OK)
            {
                return;
            }
            regentries entry = new regentries();

            entry.kvcrc  = myNewForm.kvcrc().ToString("X");
            entry.cpukey = myNewForm.cpukey();
            entry.serial = myNewForm.serial();
            entry.extra  = myNewForm.motherboard();
            entry.dvdkey = myNewForm.dvdkey();
            entry.region = myNewForm.region();
            entry.osig   = myNewForm.osig();
            addkey_s(entry, dataSet1);
            lblNumber.Text = index.ToString();
        }
Exemple #3
0
        private void scan(string folder)
        {
            Console.WriteLine("Scanning Files..");
            try
            {
                int           counter = 0, nandfiles = 0, median = 0, textfiles = 0, percent = 0, previous = 0;
                List <float>  lengths   = new List <float>();
                List <string> blacklist = new List <string>();
                lengths.Add(0x4200000); lengths.Add(0x1080000); lengths.Add(0x10800000); lengths.Add(0x21000000); lengths.Add(0x3000000); lengths.Add(0xE0400000);

                string[] filePaths = Directory.GetFiles(folder, "*.txt", SearchOption.AllDirectories);
                foreach (string file in filePaths)
                {
                    if (file.ToUpper().Contains("FUSES") || file.ToUpper().Contains("INFO") || file.ToUpper().Contains("KV") || file.ToUpper().Contains("CPU"))
                    {
                        textfiles++;
                        string[] nandPaths = Directory.GetFiles(Path.GetDirectoryName(file), "*.bin", SearchOption.TopDirectoryOnly);
                        counter += nandPaths.Length;

                        foreach (string nand in nandPaths)
                        {
                            if (variables.debugme)
                            {
                                Console.WriteLine(nand);
                            }

                            #region percent
                            if (variables.debugme)
                            {
                                Console.WriteLine("counter: {0} - i: {1}", counter, textfiles);
                                Console.WriteLine("nandpaths.length: {0}", nandPaths.Length);
                                Console.WriteLine("j: {0} - filepaths.length: {1}", nandfiles, filePaths.Length);
                            }
                            median = (counter) / textfiles;
                            if (median == 0)
                            {
                                median = 1;
                            }
                            percent = ((nandfiles + (textfiles - median)) * 100) / ((filePaths.Length - textfiles) * median);
                            if (percent > previous && percent < 100)
                            {
                                if (percent % 5 == 0)
                                {
                                    Console.WriteLine("\rCompletion {0}%", percent);
                                }
                                Console.Out.Flush();
                                previous = percent;
                            }
                            nandfiles++;
                            #endregion

                            if (nand.ToUpper().Contains("NANDFLASH") || nand.ToUpper().Contains("UPDFLASH"))
                            {
                                continue;
                            }

                            FileInfo fl = new FileInfo(nand);
                            if (lengths.Contains((fl.Length)))
                            {
                                string   cpukey    = "";
                                string[] textlines = File.ReadAllLines(file);

                                foreach (string line in textlines)
                                {
                                    cpukey = (objAlphaPattern.Match(line).Value);

                                    try
                                    {
                                        if (blacklist.Contains(nand))
                                        {
                                            break;
                                        }
                                        if (Nand.Nand.imageknown(nand, false))
                                        {
                                            if (variables.debugme)
                                            {
                                                Console.WriteLine("Verifying key");
                                            }
                                            if (Nand.Nand.cpukeyverification(nand, cpukey, true))
                                            {
                                                break;
                                            }
                                            if (variables.debugme)
                                            {
                                                Console.WriteLine("Key not verified");
                                            }
                                        }
                                        if (variables.debugme)
                                        {
                                            Console.WriteLine("Image not known");
                                        }
                                    }
                                    catch (Exception ex) { blacklist.Add(nand); if (variables.debugme)
                                                           {
                                                               Console.WriteLine(ex.ToString());
                                                           }
                                                           continue; }
                                }

                                bool sts   = objAlphaPattern.IsMatch(cpukey);
                                bool check = false;

                                if (sts)
                                {
                                    try
                                    {
                                        check = Nand.Nand.cpukeyverification(nand, cpukey);
                                    }
                                    catch (Exception ex)
                                    {
                                        if (variables.debugme)
                                        {
                                            Console.WriteLine(nand.ToString() + " Balls");
                                        }
                                        if (variables.debugme)
                                        {
                                            Console.WriteLine(ex.ToString());
                                        }
                                    }
                                }

                                if (check)
                                {
                                    Nand.PrivateN nan      = new Nand.PrivateN(nand, cpukey);
                                    DataTable     cputable = dataSet1.DataTable1;
                                    try
                                    {
                                        bool found = false;
                                        for (int c = 0; c != index; c++)
                                        {
                                            if (!String.IsNullOrWhiteSpace(nan.ki.serial) && cputable.Rows[c]["Serial"].ToString().ToUpper().Contains(nan.ki.serial.ToUpper()))
                                            {
                                                if (String.IsNullOrWhiteSpace(cputable.Rows[c]["Comment"].ToString()) || String.IsNullOrWhiteSpace(cputable.Rows[c]["Region"].ToString()) ||
                                                    String.IsNullOrWhiteSpace(cputable.Rows[c]["DVDKey"].ToString()) || String.IsNullOrWhiteSpace(cputable.Rows[c]["OSIG"].ToString()))
                                                {
                                                    try
                                                    {
                                                        RegistryKey cpukeydb = Registry.CurrentUser.CreateSubKey("CPUKey_DB");
                                                        RegistryKey cpukeys  = cpukeydb.CreateSubKey(cputable.Rows[c]["ID"].ToString());
                                                        //RegistryKey cpukeys = cpukeydb.OpenSubKey(Nand.Nand.getConsoleName(nan, variables.flashconfig), true);
                                                        string moboname = Nand.Nand.getConsoleName(nan, variables.flashconfig);
                                                        cpukeys.SetValue("Mobo", (object)moboname);
                                                        cpukeys.SetValue("DVDKey", (object)nan.ki.dvdkey);
                                                        cpukeys.SetValue("Region", (object)nan.ki.region);
                                                        cpukeys.SetValue("OSIG", (object)nan.ki.osig);
                                                        //Console.WriteLine("Adding {0}", Nand.Nand.getConsoleName(nan, variables.flashconfig) + " to entry found blank in CPUKey db");
                                                        cputable.Rows[c]["Comment"] = moboname;
                                                        cputable.Rows[c]["DVDKey"]  = nan.ki.dvdkey;
                                                        cputable.Rows[c]["Region"]  = nan.ki.region;
                                                        cputable.Rows[c]["OSIG"]    = nan.ki.osig;
                                                    }
                                                    catch (Exception ex1)
                                                    {
                                                        if (variables.debugme)
                                                        {
                                                            Console.WriteLine(ex1.ToString());
                                                        }
                                                    }
                                                }
                                                found = true;
                                            }
                                            else if (cputable.Rows[c]["CPU Key"].ToString().ToUpper().Contains(cpukey.ToUpper()))
                                            {
                                                found = true;
                                            }
                                        }
                                        if (variables.debugme)
                                        {
                                            Console.WriteLine("found {0}", found);
                                        }
                                        if (!found)
                                        {
                                            regentries entry = new regentries();
                                            entry.kvcrc  = nan.kvcrc().ToString("X");
                                            entry.serial = nan.ki.serial;
                                            entry.cpukey = cpukey;
                                            entry.extra  = Nand.Nand.getConsoleName(nan, variables.flashconfig);
                                            entry.osig   = nan.ki.osig;
                                            entry.region = nan.ki.region;
                                            entry.dvdkey = nan.ki.dvdkey;

                                            addkey_s(entry, dataSet1);
                                        }
                                        found = false;
                                    }
                                    catch (Exception ex) { if (variables.debugme)
                                                           {
                                                               Console.WriteLine(ex.ToString());
                                                           }
                                    }
                                }
                                else if (variables.debugme)
                                {
                                    Console.WriteLine("2nd time veri failed");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { if (variables.debugme)
                                   {
                                       Console.WriteLine(ex.ToString());
                                   }
            }
            this.Refresh();
            Console.WriteLine("\rCompletion 100%");
            Console.WriteLine("Done.");
        }
Exemple #4
0
        private void importReg(string regfile)
        {
            Console.WriteLine("Importing");
            string[]          lines     = File.ReadAllLines(regfile);
            int               keystoadd = 0;
            STATES            state     = STATES.NONE;
            List <regentries> entries   = new List <regentries>();
            regentries        tempentry = new regentries();

            foreach (string line in lines)
            {
                if (line.StartsWith("["))
                {
                    if (line.Equals("[HKEY_CURRENT_USER\\CPUKey_DB]"))
                    {
                        state = STATES.INDEX;
                    }
                    else
                    {
                        state = STATES.KEY;
                    }
                    continue;
                }

                switch (state)
                {
                case STATES.INDEX:
                    Int32.TryParse(line.Substring(line.IndexOf(":") + 1), out keystoadd);
                    state = STATES.NONE;
                    break;

                case STATES.KEY:
                    if (line.StartsWith("\""))
                    {
                        if (line.Contains("Index"))
                        {
                            tempentry        = new regentries();
                            tempentry.extra  = "";
                            tempentry.dvdkey = "";
                            tempentry.osig   = "";
                            tempentry.region = "";
                            continue;
                        }
                        else if (line.Contains("Serial"))
                        {
                            tempentry.serial = (line.Substring(line.IndexOf("=\"") + 1)).Replace("\"", "");
                        }
                        else if (line.Contains("cpukey"))
                        {
                            tempentry.cpukey = (line.Substring(line.IndexOf("=\"") + 1)).Replace("\"", "");
                        }
                        else if (line.Contains("CRC_KV"))
                        {
                            tempentry.kvcrc = (line.Substring(line.IndexOf("=\"") + 1)).Replace("\"", "");
                        }
                        else if (line.Contains("Mobo"))
                        {
                            tempentry.extra = (line.Substring(line.IndexOf("=\"") + 1)).Replace("\"", "");
                        }
                        else if (line.Contains("DVDkey"))
                        {
                            tempentry.dvdkey = (line.Substring(line.IndexOf("=\"") + 1)).Replace("\"", "");
                        }
                        else if (line.Contains("Region"))
                        {
                            tempentry.region = (line.Substring(line.IndexOf("=\"") + 1)).Replace("\"", "");
                        }
                        else if (line.Contains("OSIG"))
                        {
                            tempentry.osig = (line.Substring(line.IndexOf("=\"") + 1)).Replace("\"", "");
                        }
                    }
                    else
                    {
                        entries.Add(tempentry);
                        state = STATES.NONE;
                    }
                    break;

                default:
                    break;
                }
            }
            Console.WriteLine("Checking {0} keys", keystoadd);
            int counter = 0;

            foreach (regentries entry in entries)
            {
                long crc;
                if (!long.TryParse(entry.kvcrc, System.Globalization.NumberStyles.HexNumber, System.Threading.Thread.CurrentThread.CurrentCulture, out crc))
                {
                    continue;
                }
                if (!String.IsNullOrWhiteSpace(getkey_s(crc, dataSet1)))
                {
                    continue;
                }
                if (getkey_s(entry.cpukey, dataSet1))
                {
                    continue;
                }


                if (addkey_s(entry, dataSet1))
                {
                    counter++;
                }
            }
            Console.WriteLine("Done, added {0} keys", counter);
        }