Example #1
0
        private void frmInterface_Load(object sender, EventArgs e)
        {
            if (ForceToClose)
            {
                this.Close();
            }
            using (RegistryKey Key = Registry.LocalMachine.OpenSubKey(@"Software\Autodesk\AutoCAD\R17.2\ACAD-7001:409\Applications\ATEND", false))
            {
                if (Key != null)
                {
                    lblPath.Text = Key.GetValue("LOADER").ToString();
                    Path         = Key.GetValue("LOADER").ToString();

                    lblVersion.Text = Key.GetValue("VERSION").ToString();
                    Version         = Key.GetValue("VERSION").ToString();
                }
            }
            Path    = Path.Replace("Atend.dll", "");
            Version = Version.Substring(6, 7).Replace(".", "");
            Atend.Global.Utility.UInterface inter = new Atend.Global.Utility.UInterface();

            string plainText          = inter.GetInterface();
            string passPhrase         = Version;
            string saltValue          = Version;
            string hashAlgorithm      = "SHA1";
            int    passwordIterations = 2;
            string initVector         = "@1B2c3D4e5F6g7H8";
            int    keySize            = 256;
            string EncryptText        = inter.EnInterface(plainText, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize);

            lblRequest.Text = EncryptText;

            FileStream stream = new FileStream(string.Format(@"{0}LICENCE.ATND", Path), System.IO.FileMode.Create);

            System.Text.ASCIIEncoding a = new ASCIIEncoding();
            byte[] reader = a.GetBytes(EncryptText); //Convert.FromBase64String(EncryptText);
            stream.Write(reader, 0, reader.Length);
            stream.Close();
        }
Example #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtActivePath.Text != "")
            {
                FileStream   fs = new FileStream(txtActivePath.Text, FileMode.Open);
                BinaryReader br = new BinaryReader(fs);
                byte[]       s  = br.ReadBytes((Int32)br.BaseStream.Length);
                fs.Dispose();
                System.Text.ASCIIEncoding a = new ASCIIEncoding();
                string activepass           = a.GetString(s);

                string versionsoft = "";
                using (RegistryKey Key = Registry.LocalMachine.OpenSubKey(@"Software\Autodesk\AutoCAD\R17.2\ACAD-7001:409\Applications\ATEND", false))
                {
                    if (Key != null)
                    {
                        versionsoft = Key.GetValue("VERSION").ToString();
                    }
                }
                versionsoft = versionsoft.Substring(6, 7).Replace(".", "");
                Atend.Global.Utility.UInterface inter = new Atend.Global.Utility.UInterface();

                string passPhrase         = versionsoft;
                string saltValue          = versionsoft;
                string hashAlgorithm      = "SHA1";
                int    passwordIterations = 2;
                string initVector         = "@1B2c3D4e5F6g7H8";
                int    keySize            = 256;
                string orginalpass        = inter.DeInterface(activepass, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize);
                if (orginalpass != "")
                {
                    if (orginalpass.Length == 48 || orginalpass.Length == 47)
                    {
                        try
                        {
                            string pinterface  = orginalpass.Substring(0, 16);
                            string hinterface  = orginalpass.Substring(16, 10);
                            string dinterface  = orginalpass.Substring(26, 8);
                            string vinterface  = orginalpass.Substring(34, 4);
                            string tinterface  = orginalpass.Substring(38, 8);
                            string duinterface = orginalpass.Substring(46);

                            string temp  = inter.GetInterface();
                            string ptemp = temp.Substring(0, 16);
                            string htemp = orginalpass.Substring(16, 10);

                            if (ptemp != pinterface || htemp != hinterface)
                            {
                                MessageBox.Show("کد فعال سازی اشتباه می باشد");
                                AllowClosing = false;
                                return;
                            }
                            else
                            {
                                RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Autodesk\AutoCAD\R17.2\ACAD-7001:409\Applications\ATEND", true);
                                if (key != null)
                                {
                                    key.SetValue("InterfacePI", pinterface, RegistryValueKind.String);
                                    key.SetValue("InterfaceHS", hinterface, RegistryValueKind.String);
                                    key.SetValue("InterfaceDT", tinterface, RegistryValueKind.String);
                                    key.SetValue("InterfaceDU", duinterface, RegistryValueKind.DWord);

                                    _ISACTIVE = 1;
                                    MessageBox.Show("فعال سازی با موفقیت نجام گردید ");
                                    AllowClosing = true;
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            MessageBox.Show("خطا ." + ex.Message);
                            AllowClosing = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("کد فعال سازی اشتباه می باشد");
                        AllowClosing = false;
                    }
                }
                else
                {
                    MessageBox.Show("کد فعال سازی اشتباه می باشد");
                    AllowClosing = false;
                    return;
                }
            }
        }