diff --git a/BunifuLicenseGenerator.csproj b/BunifuLicenseGenerator.csproj new file mode 100644 index 0000000..9437f7b --- /dev/null +++ b/BunifuLicenseGenerator.csproj @@ -0,0 +1,124 @@ + + + + + Debug + AnyCPU + {C0DAB379-0917-4DA0-B01E-6445F17F1B4A} + WinExe + BunifuLicenseGenerator + Bunifu License Generator + v4.8 + 512 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + Main\icon.ico + + + + packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.cs + + + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + False + Microsoft .NET Framework 4.8 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + \ No newline at end of file diff --git a/BunifuLicenseGenerator.sln b/BunifuLicenseGenerator.sln new file mode 100644 index 0000000..718db90 --- /dev/null +++ b/BunifuLicenseGenerator.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35312.102 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BunifuLicenseGenerator", "BunifuLicenseGenerator.csproj", "{C0DAB379-0917-4DA0-B01E-6445F17F1B4A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C0DAB379-0917-4DA0-B01E-6445F17F1B4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C0DAB379-0917-4DA0-B01E-6445F17F1B4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C0DAB379-0917-4DA0-B01E-6445F17F1B4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C0DAB379-0917-4DA0-B01E-6445F17F1B4A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B23ECA74-A840-4B6E-8B86-59752BE03AD1} + EndGlobalSection +EndGlobal diff --git a/Helpers/Cryptography.cs b/Helpers/Cryptography.cs new file mode 100644 index 0000000..42402b2 --- /dev/null +++ b/Helpers/Cryptography.cs @@ -0,0 +1,86 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; +using System.Text.RegularExpressions; + +namespace BunifuLicenseGenerator +{ + public class Cryptography + { + private const string SHA_KEY = "011c3c04-09f0-42ea-8932-f413a9d67a6b"; + + private static RijndaelManaged NewRijndaelManaged( string salt ) + { + bool flag = salt == null; + if (flag) + { + throw new ArgumentNullException("salt"); + } + byte[] bytes = Encoding.ASCII.GetBytes(salt); + Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes("011c3c04-09f0-42ea-8932-f413a9d67a6b", bytes); + RijndaelManaged rijndaelManaged = new RijndaelManaged(); + rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(rijndaelManaged.KeySize / 8); + rijndaelManaged.IV = rfc2898DeriveBytes.GetBytes(rijndaelManaged.BlockSize / 8); + return rijndaelManaged; + } + public static string Encrypt( string plainText ) + { + byte[] saltBytes = Encoding.ASCII.GetBytes(SHA_KEY); + Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes("011c3c04-09f0-42ea-8932-f413a9d67a6b", saltBytes); + + RijndaelManaged rijndaelManaged = new RijndaelManaged(); + rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(rijndaelManaged.KeySize / 8); + rijndaelManaged.IV = rfc2898DeriveBytes.GetBytes(rijndaelManaged.BlockSize / 8); + + ICryptoTransform encryptor = rijndaelManaged.CreateEncryptor(rijndaelManaged.Key, rijndaelManaged.IV); + using (MemoryStream ms = new MemoryStream()) + { + using (CryptoStream cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write)) + { + using (StreamWriter sw = new StreamWriter(cs)) + { + sw.Write(plainText); + } + } + return Convert.ToBase64String(ms.ToArray()); + } + } + + public static string Decrypt( string cipherText ) + { + if (!IsBase64String(cipherText)) + throw new Exception("The cipherText input parameter is not base64 encoded"); + + byte[] saltBytes = Encoding.ASCII.GetBytes(SHA_KEY); + Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes("011c3c04-09f0-42ea-8932-f413a9d67a6b", saltBytes); + + RijndaelManaged rijndaelManaged = new RijndaelManaged(); + rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(rijndaelManaged.KeySize / 8); + rijndaelManaged.IV = rfc2898DeriveBytes.GetBytes(rijndaelManaged.BlockSize / 8); + + ICryptoTransform decryptor = rijndaelManaged.CreateDecryptor(rijndaelManaged.Key, rijndaelManaged.IV); + byte[] encryptedBytes = Convert.FromBase64String(cipherText); + + using (MemoryStream ms = new MemoryStream(encryptedBytes)) + { + using (CryptoStream cs = new CryptoStream(ms, decryptor, CryptoStreamMode.Read)) + { + using (StreamReader sr = new StreamReader(cs)) + { + return sr.ReadToEnd(); + } + } + } + } + + public static bool IsBase64String( string base64String ) + { + base64String = base64String.Trim(); + return base64String.Length % 4 == 0 && Regex.IsMatch(base64String, "^[a-zA-Z0-9\\+/]*={0,3}$", RegexOptions.None); + } + public Cryptography() + { + } + } +} diff --git a/Helpers/Hardware.cs b/Helpers/Hardware.cs new file mode 100644 index 0000000..471340f --- /dev/null +++ b/Helpers/Hardware.cs @@ -0,0 +1,239 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Management; +using System.Security.Cryptography; +using System.Text; + +namespace BunifuLicenseGenerator +{ + [DebuggerStepThrough] + public class Hardware + { + public static string GetUniqueID() + { + return Hardware.Value(); + } + + + public static string GetOSName() + { + string text = string.Empty; + try + { + ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem"); + using (ManagementObjectCollection.ManagementObjectEnumerator enumerator = managementObjectSearcher.Get().GetEnumerator()) + { + if (enumerator.MoveNext()) + { + ManagementObject managementObject = (ManagementObject)enumerator.Current; + text = managementObject["Caption"].ToString(); + } + } + } + catch (Exception) + { + } + return text; + } + + public override string ToString() + { + return Hardware.Value(); + } + + private static string Value() + { + bool flag = string.IsNullOrEmpty(Hardware._fingerPrint); + if (flag) + { + Hardware._fingerPrint = Hardware.GetHash(string.Concat(new string[] + { + "CPU >> ", + Hardware.CpuId(), + "\nBIOS >> ", + Hardware.BiosId(), + "\nBASE >> ", + Hardware.BaseId(), + "\nVIDEO >> ", + Hardware.VideoId() + })); + } + return Hardware._fingerPrint; + } + + private static string GetHash( string s ) + { + MD5 md = new MD5CryptoServiceProvider(); + byte[] bytes = Encoding.ASCII.GetBytes(s); + return Hardware.GetHexString(md.ComputeHash(bytes)); + } + + private static string GetHexString( IList bt ) + { + string text = string.Empty; + for (int i = 0; i < bt.Count; i++) + { + byte b = bt[i]; + int num = (int)b; + int num2 = num & 15; + int num3 = (num >> 4) & 15; + bool flag = num3 > 9; + if (flag) + { + text += ((char)(num3 - 10 + 65)).ToString(CultureInfo.InvariantCulture); + } + else + { + text += num3.ToString(CultureInfo.InvariantCulture); + } + bool flag2 = num2 > 9; + if (flag2) + { + text += ((char)(num2 - 10 + 65)).ToString(CultureInfo.InvariantCulture); + } + else + { + text += num2.ToString(CultureInfo.InvariantCulture); + } + bool flag3 = i + 1 != bt.Count && (i + 1) % 2 == 0; + if (flag3) + { + text += "-"; + } + } + return text; + } + + private static string Identifier( string wmiClass, string wmiProperty, string wmiMustBeTrue ) + { + string text = ""; + ManagementClass managementClass = new ManagementClass(wmiClass); + ManagementObjectCollection instances = managementClass.GetInstances(); + foreach (ManagementBaseObject managementBaseObject in instances) + { + bool flag = managementBaseObject[wmiMustBeTrue].ToString() != "True"; + if (!flag) + { + bool flag2 = text != ""; + if (!flag2) + { + try + { + text = managementBaseObject[wmiProperty].ToString(); + break; + } + catch + { + } + } + } + } + return text; + } + + private static string Identifier( string wmiClass, string wmiProperty ) + { + string text = ""; + ManagementClass managementClass = new ManagementClass(wmiClass); + ManagementObjectCollection instances = managementClass.GetInstances(); + foreach (ManagementBaseObject managementBaseObject in instances) + { + bool flag = text != ""; + if (!flag) + { + try + { + bool flag2 = managementBaseObject[wmiProperty] != null; + if (flag2) + { + text = managementBaseObject[wmiProperty].ToString(); + } + break; + } + catch + { + } + } + } + return text; + } + + private static string CpuId() + { + string text = Hardware.Identifier("Win32_Processor", "UniqueId"); + bool flag = text != ""; + string text2; + if (flag) + { + text2 = text; + } + else + { + text = Hardware.Identifier("Win32_Processor", "ProcessorId"); + bool flag2 = text != ""; + if (flag2) + { + text2 = text; + } + else + { + text = Hardware.Identifier("Win32_Processor", "Name"); + bool flag3 = text == ""; + if (flag3) + { + text = Hardware.Identifier("Win32_Processor", "Manufacturer"); + } + text += Hardware.Identifier("Win32_Processor", "MaxClockSpeed"); + text2 = text; + } + } + return text2; + } + + private static string BiosId() + { + return string.Concat(new string[] + { + Hardware.Identifier("Win32_BIOS", "Manufacturer"), + Hardware.Identifier("Win32_BIOS", "SMBIOSBIOSVersion"), + Hardware.Identifier("Win32_BIOS", "IdentificationCode"), + Hardware.Identifier("Win32_BIOS", "SerialNumber"), + Hardware.Identifier("Win32_BIOS", "ReleaseDate"), + Hardware.Identifier("Win32_BIOS", "Version") + }); + } + + private static string DiskId() + { + return Hardware.Identifier("Win32_DiskDrive", "Model") + Hardware.Identifier("Win32_DiskDrive", "Manufacturer") + Hardware.Identifier("Win32_DiskDrive", "Signature") + Hardware.Identifier("Win32_DiskDrive", "TotalHeads"); + } + + private static string BaseId() + { + return Hardware.Identifier("Win32_BaseBoard", "Model") + Hardware.Identifier("Win32_BaseBoard", "Manufacturer") + Hardware.Identifier("Win32_BaseBoard", "Name") + Hardware.Identifier("Win32_BaseBoard", "SerialNumber"); + } + + private static string VideoId() + { + return Hardware.Identifier("Win32_VideoController", "DriverVersion") + Hardware.Identifier("Win32_VideoController", "Name"); + } + + private static string MacId() + { + return Hardware.Identifier("Win32_NetworkAdapterConfiguration", "MACAddress", "IPEnabled"); + } + + public Hardware() + { + } + + // Note: this type is marked as 'beforefieldinit'. + static Hardware() + { + } + + private static string _fingerPrint = string.Empty; + } +} diff --git a/Helpers/LicenseGenerator.cs b/Helpers/LicenseGenerator.cs new file mode 100644 index 0000000..ae4a64f --- /dev/null +++ b/Helpers/LicenseGenerator.cs @@ -0,0 +1,179 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Security.Cryptography; +using System.Text; +using System.Text.RegularExpressions; + +public class LicenseGenerator +{ + + public enum ProductType + { + UIWinForms = 0, + Charts = 1, + DatavizBasicWinForms = 2, + DatavizAdvancedWinForms = 3 + } + + public class Product + { + public int id { get; set; } + public ProductType name { get; set; } + public string uuid { get; set; } + } + + public class Client + { + public int ID { get; set; } + public int TeamID { get; set; } + public int WPUserID { get; set; } + public bool IsTeamAdmin { get; set; } + public string Name { get; set; } + public string Email { get; set; } + public bool Blocked { get; set; } + public DateTime CreatedAt { get; set; } + } + + public class Device + { + public int ID { get; set; } + public string Name { get; set; } + public string OS { get; set; } + public string HardwareID { get; set; } + public bool Blocked { get; set; } + public DateTime LastSeen { get; set; } + } + + public class License + { + public int ID { get; set; } + public string UUID { get; set; } + public int? BundleID { get; set; } + public int? TeamID { get; set; } + public int? UserID { get; set; } + public int PurchaseID { get; set; } + public int TotalDays { get; set; } + public int MaxDevices { get; set; } + public int Activations { get; set; } + public int RemainingDevices { get; set; } + public string Plan { get; set; } + public string RenewalURL { get; set; } + public string LicenseKey { get; set; } + public DateTime CreatedAt { get; set; } + public DateTime ExpiryDate { get; set; } + public ProductType Product { get; set; } + public List ProductsLicensed { get; set; } + public int Type { get; set; } + public int Status { get; set; } + } + + public class LicenseRecord + { + public bool IsValid { get; set; } + public int ID { get; set; } + public string UUID { get; set; } + public string LicenseKey { get; set; } + public string CreatedAt { get; set; } + public string LastSeen { get; set; } + public string RemovedAt { get; set; } + public Client Client { get; set; } + public Device Device { get; set; } + public License License { get; set; } + } + + public static string GenerateLicense( ProductType productType, string email, string name, string licenseKey, bool enterprise ) + { + return JsonConvert.SerializeObject(new LicenseRecord + { + IsValid = true, + ID = 123456, + UUID = "Fake-license-uuid-12345", + LicenseKey = licenseKey, + CreatedAt = DateTime.Now.ToString("o"), + LastSeen = "0001-01-01T00:00:00", + RemovedAt = "0001-01-01T00:00:00", + Client = new Client + { + Blocked = false, + IsTeamAdmin = false, + ID = 345678, + TeamID = 0, + WPUserID = 0, + Name = name, + Email = email, + CreatedAt = DateTime.Now + }, + Device = new Device + { + ID = 789012, + Name = Environment.MachineName, + OS = Environment.OSVersion.ToString(), + HardwareID = BunifuLicenseGenerator.Hardware.GetUniqueID(), + Blocked = false, + LastSeen = DateTime.Now + }, + License = new License + { + ID = 987654, + UUID = "Fake-license-plan-uuid-67890", + BundleID = null, + TeamID = null, + UserID = null, + PurchaseID = 112233, + TotalDays = enterprise ? 9999 : 365, + MaxDevices = 5, + Activations = 1, + RemainingDevices = enterprise ? 9999 : 4, + Plan = enterprise ? "Enterprise Plan" : "Premium Plan", + RenewalURL = null, + LicenseKey = null, + CreatedAt = DateTime.Now, + ExpiryDate = enterprise ? DateTime.Now.AddYears(30) : DateTime.Now.AddYears(1), + Product = productType, + ProductsLicensed = new List + { + new Product + { + id = (int)productType, + name = productType, + uuid = null + } + }, + Type = enterprise ? 2 : 1, + Status = 0 + } + }, Newtonsoft.Json.Formatting.None); + } + + + + public static void SaveLicenseToFile( string encryptedData, ProductType productType ) + { + string programDataPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), + "Bunifu Technologies" + ); + + string productFolder = Path.Combine(programDataPath, productType.ToString()); + Directory.CreateDirectory(productFolder); + + string licenseFilePath = Path.Combine(productFolder, "License.lic"); + + File.WriteAllText(licenseFilePath, encryptedData); + } + public static void SaveLicenseToRegistry( string encryptedData, ProductType productType ) + { + try + { + var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey($@"Software\Bunifu Technologies\{productType.ToString()}"); + key.SetValue("CLI", encryptedData); + key.Close(); + } + catch (Exception ex) + { + throw new Exception("Registry write failed: " + ex.Message); + } + } +} \ No newline at end of file diff --git a/Main/App.config b/Main/App.config new file mode 100644 index 0000000..3916e0e --- /dev/null +++ b/Main/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Main/MainForm.Designer.cs b/Main/MainForm.Designer.cs new file mode 100644 index 0000000..476c22c --- /dev/null +++ b/Main/MainForm.Designer.cs @@ -0,0 +1,221 @@ +namespace BunifuLicenseGenerator +{ + partial class MainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose( bool disposing ) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); + this.btnGenerate = new System.Windows.Forms.Button(); + this.txtEmail = new System.Windows.Forms.TextBox(); + this.cmbProduct = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.lbEmail = new System.Windows.Forms.Label(); + this.lbProduct = new System.Windows.Forms.Label(); + this.labelStatus = new System.Windows.Forms.Label(); + this.txtHWID = new System.Windows.Forms.TextBox(); + this.lbHWID = new System.Windows.Forms.Label(); + this.chkEnterprise = new System.Windows.Forms.CheckBox(); + this.lbLicense = new System.Windows.Forms.Label(); + this.txtLicenseKey = new System.Windows.Forms.TextBox(); + this.lbName = new System.Windows.Forms.Label(); + this.txtName = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // btnGenerate + // + this.btnGenerate.Location = new System.Drawing.Point(12, 230); + this.btnGenerate.Name = "btnGenerate"; + this.btnGenerate.Size = new System.Drawing.Size(260, 35); + this.btnGenerate.TabIndex = 5; + this.btnGenerate.Text = "Generate & Save License"; + this.btnGenerate.UseVisualStyleBackColor = true; + this.btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click); + // + // txtEmail + // + this.txtEmail.Location = new System.Drawing.Point(12, 105); + this.txtEmail.Name = "txtEmail"; + this.txtEmail.Size = new System.Drawing.Size(260, 20); + this.txtEmail.TabIndex = 2; + this.txtEmail.Text = "john.doe@example.com"; + // + // cmbProduct + // + this.cmbProduct.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbProduct.FormattingEnabled = true; + this.cmbProduct.Items.AddRange(new object[] { + "UIWinForms", + "Charts", + "DatavizBasicWinForms", + "DatavizAdvancedWinForms"}); + this.cmbProduct.Location = new System.Drawing.Point(12, 145); + this.cmbProduct.Name = "cmbProduct"; + this.cmbProduct.Size = new System.Drawing.Size(260, 21); + this.cmbProduct.TabIndex = 3; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 29); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 13); + this.label1.TabIndex = 6; + this.label1.Text = "Name:"; + // + // lbEmail + // + this.lbEmail.AutoSize = true; + this.lbEmail.Location = new System.Drawing.Point(12, 89); + this.lbEmail.Name = "lbEmail"; + this.lbEmail.Size = new System.Drawing.Size(35, 13); + this.lbEmail.TabIndex = 7; + this.lbEmail.Text = "Email:"; + // + // lbProduct + // + this.lbProduct.AutoSize = true; + this.lbProduct.Location = new System.Drawing.Point(12, 129); + this.lbProduct.Name = "lbProduct"; + this.lbProduct.Size = new System.Drawing.Size(48, 13); + this.lbProduct.TabIndex = 8; + this.lbProduct.Text = "Product:"; + // + // labelStatus + // + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(12, 270); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(0, 13); + this.labelStatus.TabIndex = 9; + // + // txtHWID + // + this.txtHWID.Location = new System.Drawing.Point(12, 185); + this.txtHWID.Name = "txtHWID"; + this.txtHWID.ReadOnly = true; + this.txtHWID.Size = new System.Drawing.Size(260, 20); + this.txtHWID.TabIndex = 10; + // + // lbHWID + // + this.lbHWID.AutoSize = true; + this.lbHWID.Location = new System.Drawing.Point(12, 169); + this.lbHWID.Name = "lbHWID"; + this.lbHWID.Size = new System.Drawing.Size(39, 13); + this.lbHWID.TabIndex = 11; + this.lbHWID.Text = "HWID:"; + // + // chkEnterprise + // + this.chkEnterprise.AutoSize = true; + this.chkEnterprise.Location = new System.Drawing.Point(15, 210); + this.chkEnterprise.Name = "chkEnterprise"; + this.chkEnterprise.Size = new System.Drawing.Size(113, 17); + this.chkEnterprise.TabIndex = 4; + this.chkEnterprise.Text = "Enterprise License"; + this.chkEnterprise.UseVisualStyleBackColor = true; + // + // lbLicense + // + this.lbLicense.AutoSize = true; + this.lbLicense.Location = new System.Drawing.Point(12, 9); + this.lbLicense.Name = "lbLicense"; + this.lbLicense.Size = new System.Drawing.Size(67, 13); + this.lbLicense.TabIndex = 13; + this.lbLicense.Text = "License Key:"; + // + // txtLicenseKey + // + this.txtLicenseKey.Location = new System.Drawing.Point(12, 25); + this.txtLicenseKey.Name = "txtLicenseKey"; + this.txtLicenseKey.Size = new System.Drawing.Size(260, 20); + this.txtLicenseKey.TabIndex = 0; + this.txtLicenseKey.Text = "Fake-LICENSE-KEY-12345"; + // + // lbName + // + this.lbName.AutoSize = true; + this.lbName.Location = new System.Drawing.Point(12, 50); + this.lbName.Name = "lbName"; + this.lbName.Size = new System.Drawing.Size(38, 13); + this.lbName.TabIndex = 15; + this.lbName.Text = "Name:"; + // + // txtName + // + this.txtName.Location = new System.Drawing.Point(12, 66); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(260, 20); + this.txtName.TabIndex = 14; + this.txtName.Text = "John Doe"; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(282, 287); + this.Controls.Add(this.lbName); + this.Controls.Add(this.txtName); + this.Controls.Add(this.txtLicenseKey); + this.Controls.Add(this.lbLicense); + this.Controls.Add(this.chkEnterprise); + this.Controls.Add(this.txtHWID); + this.Controls.Add(this.lbHWID); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.lbProduct); + this.Controls.Add(this.lbEmail); + this.Controls.Add(this.label1); + this.Controls.Add(this.cmbProduct); + this.Controls.Add(this.txtEmail); + this.Controls.Add(this.btnGenerate); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "MainForm"; + this.Text = "Bunifu License Generator"; + this.Load += new System.EventHandler(this.MainForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btnGenerate; + private System.Windows.Forms.TextBox txtEmail; + private System.Windows.Forms.ComboBox cmbProduct; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label lbEmail; + private System.Windows.Forms.Label lbProduct; + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.TextBox txtHWID; + private System.Windows.Forms.Label lbHWID; + private System.Windows.Forms.CheckBox chkEnterprise; + private System.Windows.Forms.Label lbLicense; + private System.Windows.Forms.TextBox txtLicenseKey; + private System.Windows.Forms.Label lbName; + private System.Windows.Forms.TextBox txtName; + } +} \ No newline at end of file diff --git a/Main/MainForm.cs b/Main/MainForm.cs new file mode 100644 index 0000000..4a76751 --- /dev/null +++ b/Main/MainForm.cs @@ -0,0 +1,104 @@ +using Newtonsoft.Json; +using System; +using System.IO; +using System.Windows.Forms; + +namespace BunifuLicenseGenerator +{ + public partial class MainForm : Form + { + public MainForm() + { + InitializeComponent(); + } + private void MainForm_Load( object sender, EventArgs e ) + { + txtHWID.Text = Hardware.GetUniqueID(); + cmbProduct.SelectedIndex = 0; + } + + private void btnGenerate_Click( object sender, EventArgs e ) + { + try + { + var productType = (LicenseGenerator.ProductType)cmbProduct.SelectedIndex; + var licenseKey = txtLicenseKey.Text.Trim(); + var name = txtName.Text.Trim(); + var email = txtEmail.Text.Trim(); + var isEnterprise = chkEnterprise.Checked; + + if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(email)) + { + MessageBox.Show("Please enter both name and email."); + return; + } + + string existingLicense = null; + + // Check file + string licenseFilePath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), + $"Bunifu Technologies/{productType}", + "License.lic" + ); + + if (File.Exists(licenseFilePath)) + { + string encryptedData = File.ReadAllText(licenseFilePath); + existingLicense = Cryptography.Decrypt(encryptedData); + } + + // Check registry + else + { + using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey($@"Software\Bunifu Technologies\{productType}")) + { + if (key != null) + { + var encryptedData = key.GetValue("CLI") as string; + if (!string.IsNullOrEmpty(encryptedData)) + { + existingLicense = Cryptography.Decrypt(encryptedData); + } + } + } + } + + if (!string.IsNullOrEmpty(existingLicense)) + { + var existingRecord = JsonConvert.DeserializeObject(existingLicense); + MessageBox.Show($"Existing license found. No new license was generated."); + return; + } + + labelStatus.Text = "Generating license..."; + Application.DoEvents(); + + string licenseJson = LicenseGenerator.GenerateLicense(productType, email, name, licenseKey, isEnterprise); + string encryptedLicense = Cryptography.Encrypt(licenseJson); + + LicenseGenerator.SaveLicenseToFile(encryptedLicense, productType); + LicenseGenerator.SaveLicenseToRegistry(encryptedLicense, productType); + + labelStatus.Text = "License generated and saved successfully!"; + MessageBox.Show("License generated successfully!\n\n" + + $"Product: {productType}\n" + + $"HWID: {Hardware.GetUniqueID()}\n" + + $"Email: {email}\n" + + $"License Type: {(isEnterprise ? "Enterprise" : "Premium")}", + "Success", + MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + catch (Exception ex) + { + labelStatus.Text = "Error generating license!"; + MessageBox.Show("Error: " + ex.Message, "Error", + MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + + } +} diff --git a/Main/MainForm.resx b/Main/MainForm.resx new file mode 100644 index 0000000..99b2afc --- /dev/null +++ b/Main/MainForm.resx @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAgBAAAAAAAAAAAAAAAAAAAAAA + AAC3lHH/vZ97/6uQcv+mh2P/t5hw/66Sa/+xkG3/s5d5/7Seif+hhXD/xJ5x/7GTc/+sjm7/q4xt/6OC + YP+Lc13/6+De/+7j3//p3tz/597Z/+jc2P/o3Nj/6N7b//ft7P+hkHr/TCUA/1AvAv9eOAT/RSkD/1k0 + Av9hPAL/Zz8C/7CPbf+7m3v/s5Rx/5p2U/+aeVf/rpN3/7Oehf+3nov/uqOL/7Sbff/GoXD/vZ99/7SU + ev+ojXX/qZB4/4VqS//Wy8P/8ufm/+rf3f/o3dn/593Z/+bc2P/p3tv/+u/t/4x9bf8tEwD/Mh0C/yoY + A/8rGQP/QCIA/0snAP9aNAH/qIZg/7GLYP+tjmT/nnpS/49tTP+1nYP/u6CC/7eVc/+3lW7/u5tv/8Gi + cv+9m3L/vpdw/7uYcP++nHj/q4RY/8a0pf/x6er/6t/b/+ne2v/p3dn/593Z/+rf2//+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AAAAAAAAAAAAAAAAAAAAA= + + + \ No newline at end of file diff --git a/Main/Program.cs b/Main/Program.cs new file mode 100644 index 0000000..bfff0db --- /dev/null +++ b/Main/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Windows.Forms; + +namespace BunifuLicenseGenerator +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git a/Main/icon.ico b/Main/icon.ico new file mode 100644 index 0000000..dcf91b7 Binary files /dev/null and b/Main/icon.ico differ diff --git a/Main/packages.config b/Main/packages.config new file mode 100644 index 0000000..2fcd6b2 --- /dev/null +++ b/Main/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file