Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e15bc58dfc | ||
|
|
a3f60cfd25 | ||
|
|
7c2960e1d7 |
No files matched your search
+13
-6
@@ -47,17 +47,24 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Keygen.cs" />
|
<Compile Include="Keygen\KeygenBase.cs" />
|
||||||
<Compile Include="MainForm.cs">
|
<Compile Include="Keygen\KeygenProduct.cs" />
|
||||||
|
<Compile Include="Keygen\LicenseTypes.cs" />
|
||||||
|
<Compile Include="Keygen\Platforms\PlatformAndroid.cs" />
|
||||||
|
<Compile Include="Keygen\Platforms\PlatformJava.cs" />
|
||||||
|
<Compile Include="Keygen\Platforms\PlatformJavaScript.cs" />
|
||||||
|
<Compile Include="Keygen\Platforms\PlatformMac.cs" />
|
||||||
|
<Compile Include="Keygen\Platforms\PlatformWindows.cs" />
|
||||||
|
<Compile Include="FrmMain.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="MainForm.Designer.cs">
|
<Compile Include="FrmMain.Designer.cs">
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<EmbeddedResource Include="MainForm.resx">
|
<EmbeddedResource Include="FrmMain.resx">
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28307.1022
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrappeMocha", "FrappeMocha.csproj", "{04AB5523-E679-4628-8B8B-B928A5DA5107}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrappeMocha", "FrappeMocha.csproj", "{04AB5523-E679-4628-8B8B-B928A5DA5107}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlatformUnitTests", "PlatformUnitTests\PlatformUnitTests.csproj", "{CEF3A8CA-7FAA-416F-A1FD-2AB221A84AF8}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -15,6 +17,10 @@ Global
|
|||||||
{04AB5523-E679-4628-8B8B-B928A5DA5107}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{04AB5523-E679-4628-8B8B-B928A5DA5107}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{04AB5523-E679-4628-8B8B-B928A5DA5107}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{04AB5523-E679-4628-8B8B-B928A5DA5107}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{04AB5523-E679-4628-8B8B-B928A5DA5107}.Release|Any CPU.Build.0 = Release|Any CPU
|
{04AB5523-E679-4628-8B8B-B928A5DA5107}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{CEF3A8CA-7FAA-416F-A1FD-2AB221A84AF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{CEF3A8CA-7FAA-416F-A1FD-2AB221A84AF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{CEF3A8CA-7FAA-416F-A1FD-2AB221A84AF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{CEF3A8CA-7FAA-416F-A1FD-2AB221A84AF8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Generated
+199
@@ -0,0 +1,199 @@
|
|||||||
|
namespace FrappeMocha
|
||||||
|
{
|
||||||
|
partial class FrmMain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region PlatformWindows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
|
||||||
|
this.cbxLicenseType = new System.Windows.Forms.ComboBox();
|
||||||
|
this.tbxCompanyUserName = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblLicenseType = new System.Windows.Forms.Label();
|
||||||
|
this.lblCompanyUserName = new System.Windows.Forms.Label();
|
||||||
|
this.lblLicenseKey = new System.Windows.Forms.Label();
|
||||||
|
this.tbxLicenseKey = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnSubmit = new System.Windows.Forms.Button();
|
||||||
|
this.lblProduct = new System.Windows.Forms.Label();
|
||||||
|
this.cbxProduct = new System.Windows.Forms.ComboBox();
|
||||||
|
this.lblPlatform = new System.Windows.Forms.Label();
|
||||||
|
this.cbxPlatform = new System.Windows.Forms.ComboBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// cbxLicenseType
|
||||||
|
//
|
||||||
|
this.cbxLicenseType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.cbxLicenseType.FormattingEnabled = true;
|
||||||
|
this.cbxLicenseType.Items.AddRange(new object[] {
|
||||||
|
"Company License",
|
||||||
|
"Single User License"});
|
||||||
|
this.cbxLicenseType.Location = new System.Drawing.Point(12, 112);
|
||||||
|
this.cbxLicenseType.Name = "cbxLicenseType";
|
||||||
|
this.cbxLicenseType.Size = new System.Drawing.Size(146, 21);
|
||||||
|
this.cbxLicenseType.TabIndex = 0;
|
||||||
|
this.cbxLicenseType.SelectedIndexChanged += new System.EventHandler(this.cbxLicenseType_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// tbxCompanyUserName
|
||||||
|
//
|
||||||
|
this.tbxCompanyUserName.Location = new System.Drawing.Point(12, 152);
|
||||||
|
this.tbxCompanyUserName.MaxLength = 80;
|
||||||
|
this.tbxCompanyUserName.Name = "tbxCompanyUserName";
|
||||||
|
this.tbxCompanyUserName.Size = new System.Drawing.Size(146, 20);
|
||||||
|
this.tbxCompanyUserName.TabIndex = 1;
|
||||||
|
this.tbxCompanyUserName.Text = "FrappeMocha";
|
||||||
|
//
|
||||||
|
// lblLicenseType
|
||||||
|
//
|
||||||
|
this.lblLicenseType.AutoSize = true;
|
||||||
|
this.lblLicenseType.Location = new System.Drawing.Point(9, 96);
|
||||||
|
this.lblLicenseType.Name = "lblLicenseType";
|
||||||
|
this.lblLicenseType.Size = new System.Drawing.Size(71, 13);
|
||||||
|
this.lblLicenseType.TabIndex = 2;
|
||||||
|
this.lblLicenseType.Text = "License Type";
|
||||||
|
//
|
||||||
|
// lblCompanyUserName
|
||||||
|
//
|
||||||
|
this.lblCompanyUserName.AutoSize = true;
|
||||||
|
this.lblCompanyUserName.Location = new System.Drawing.Point(9, 136);
|
||||||
|
this.lblCompanyUserName.Name = "lblCompanyUserName";
|
||||||
|
this.lblCompanyUserName.Size = new System.Drawing.Size(115, 13);
|
||||||
|
this.lblCompanyUserName.TabIndex = 3;
|
||||||
|
this.lblCompanyUserName.Text = "Company / User Name";
|
||||||
|
//
|
||||||
|
// lblLicenseKey
|
||||||
|
//
|
||||||
|
this.lblLicenseKey.AutoSize = true;
|
||||||
|
this.lblLicenseKey.Location = new System.Drawing.Point(9, 175);
|
||||||
|
this.lblLicenseKey.Name = "lblLicenseKey";
|
||||||
|
this.lblLicenseKey.Size = new System.Drawing.Size(65, 13);
|
||||||
|
this.lblLicenseKey.TabIndex = 4;
|
||||||
|
this.lblLicenseKey.Text = "License Key";
|
||||||
|
//
|
||||||
|
// tbxLicenseKey
|
||||||
|
//
|
||||||
|
this.tbxLicenseKey.Location = new System.Drawing.Point(12, 191);
|
||||||
|
this.tbxLicenseKey.Name = "tbxLicenseKey";
|
||||||
|
this.tbxLicenseKey.ReadOnly = true;
|
||||||
|
this.tbxLicenseKey.Size = new System.Drawing.Size(146, 20);
|
||||||
|
this.tbxLicenseKey.TabIndex = 5;
|
||||||
|
this.tbxLicenseKey.Click += new System.EventHandler(this.tbxLicenseKey_Click);
|
||||||
|
//
|
||||||
|
// btnSubmit
|
||||||
|
//
|
||||||
|
this.btnSubmit.Location = new System.Drawing.Point(12, 222);
|
||||||
|
this.btnSubmit.Name = "btnSubmit";
|
||||||
|
this.btnSubmit.Size = new System.Drawing.Size(146, 23);
|
||||||
|
this.btnSubmit.TabIndex = 6;
|
||||||
|
this.btnSubmit.Text = "Frappe Mocha";
|
||||||
|
this.btnSubmit.UseVisualStyleBackColor = true;
|
||||||
|
this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
|
||||||
|
//
|
||||||
|
// lblProduct
|
||||||
|
//
|
||||||
|
this.lblProduct.AutoSize = true;
|
||||||
|
this.lblProduct.Location = new System.Drawing.Point(9, 56);
|
||||||
|
this.lblProduct.Name = "lblProduct";
|
||||||
|
this.lblProduct.Size = new System.Drawing.Size(44, 13);
|
||||||
|
this.lblProduct.TabIndex = 7;
|
||||||
|
this.lblProduct.Text = "Product";
|
||||||
|
//
|
||||||
|
// cbxProduct
|
||||||
|
//
|
||||||
|
this.cbxProduct.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.cbxProduct.FormattingEnabled = true;
|
||||||
|
this.cbxProduct.Location = new System.Drawing.Point(12, 72);
|
||||||
|
this.cbxProduct.Name = "cbxProduct";
|
||||||
|
this.cbxProduct.Size = new System.Drawing.Size(146, 21);
|
||||||
|
this.cbxProduct.TabIndex = 8;
|
||||||
|
this.cbxProduct.SelectedIndexChanged += new System.EventHandler(this.cbxProduct_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// lblPlatform
|
||||||
|
//
|
||||||
|
this.lblPlatform.AutoSize = true;
|
||||||
|
this.lblPlatform.Location = new System.Drawing.Point(9, 13);
|
||||||
|
this.lblPlatform.Name = "lblPlatform";
|
||||||
|
this.lblPlatform.Size = new System.Drawing.Size(45, 13);
|
||||||
|
this.lblPlatform.TabIndex = 9;
|
||||||
|
this.lblPlatform.Text = "Platform";
|
||||||
|
//
|
||||||
|
// cbxPlatform
|
||||||
|
//
|
||||||
|
this.cbxPlatform.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.cbxPlatform.FormattingEnabled = true;
|
||||||
|
this.cbxPlatform.Location = new System.Drawing.Point(12, 29);
|
||||||
|
this.cbxPlatform.Name = "cbxPlatform";
|
||||||
|
this.cbxPlatform.Size = new System.Drawing.Size(146, 21);
|
||||||
|
this.cbxPlatform.TabIndex = 10;
|
||||||
|
this.cbxPlatform.SelectedIndexChanged += new System.EventHandler(this.cbxPlatform_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// FrmMain
|
||||||
|
//
|
||||||
|
this.AcceptButton = this.btnSubmit;
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.BackColor = System.Drawing.SystemColors.Window;
|
||||||
|
this.ClientSize = new System.Drawing.Size(173, 258);
|
||||||
|
this.Controls.Add(this.cbxPlatform);
|
||||||
|
this.Controls.Add(this.lblPlatform);
|
||||||
|
this.Controls.Add(this.cbxProduct);
|
||||||
|
this.Controls.Add(this.lblProduct);
|
||||||
|
this.Controls.Add(this.btnSubmit);
|
||||||
|
this.Controls.Add(this.tbxLicenseKey);
|
||||||
|
this.Controls.Add(this.lblLicenseKey);
|
||||||
|
this.Controls.Add(this.lblCompanyUserName);
|
||||||
|
this.Controls.Add(this.lblLicenseType);
|
||||||
|
this.Controls.Add(this.tbxCompanyUserName);
|
||||||
|
this.Controls.Add(this.cbxLicenseType);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||||
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.KeyPreview = true;
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.Name = "FrmMain";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "FrappeMocha";
|
||||||
|
this.Shown += new System.EventHandler(this.frmMain_Shown);
|
||||||
|
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.frmMain_KeyPress);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.ComboBox cbxLicenseType;
|
||||||
|
private System.Windows.Forms.TextBox tbxCompanyUserName;
|
||||||
|
private System.Windows.Forms.Label lblLicenseType;
|
||||||
|
private System.Windows.Forms.Label lblCompanyUserName;
|
||||||
|
private System.Windows.Forms.Label lblLicenseKey;
|
||||||
|
private System.Windows.Forms.TextBox tbxLicenseKey;
|
||||||
|
private System.Windows.Forms.Button btnSubmit;
|
||||||
|
private System.Windows.Forms.Label lblProduct;
|
||||||
|
private System.Windows.Forms.ComboBox cbxProduct;
|
||||||
|
private System.Windows.Forms.Label lblPlatform;
|
||||||
|
private System.Windows.Forms.ComboBox cbxPlatform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+2494
-2493
File diff suppressed because it is too large.
Load diff
@@ -1,479 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace FrappeMocha
|
|
||||||
{
|
|
||||||
public class Keygen
|
|
||||||
{
|
|
||||||
private int param_encoding;
|
|
||||||
|
|
||||||
public enum LicenseTypes
|
|
||||||
{
|
|
||||||
LicenseWindows3270 = 0x8c,
|
|
||||||
LicenseWindows5250 = 0x80,
|
|
||||||
LicenseWindows3812 = 0xa0,
|
|
||||||
LicenseWindowsTelnet = 0x9b,
|
|
||||||
LicenseJava3270 = 0x1e,
|
|
||||||
LicenseJava5250 = 0x1e,
|
|
||||||
LicenseJavaTelnet = 0x1b,
|
|
||||||
LicenseMac3270 = 0x5d,
|
|
||||||
LicenseMac5250 = 0x16,
|
|
||||||
LicenseMac3812 = 0x22,
|
|
||||||
LicenseMacTelnet = 0x5e,
|
|
||||||
LicenseMacKeyboard = 0xa5,
|
|
||||||
LicenseChrome3270 = 0xb3,
|
|
||||||
LicenseChrome5250 = 0xb2,
|
|
||||||
LicenseChromeTelnet = 0xb4,
|
|
||||||
LicenseAndroid3270 = 0x94,
|
|
||||||
LicenseAndroid5250 = 0x91,
|
|
||||||
LicenseAndroidTelnet = 0x96,
|
|
||||||
LicenseAndroidVnc = 0x92,
|
|
||||||
LicenseAndroidBarcode = 0x9c,
|
|
||||||
}
|
|
||||||
|
|
||||||
public Keygen()
|
|
||||||
{
|
|
||||||
this.param_encoding = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public string GenLicense(int type, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
switch (license)
|
|
||||||
{
|
|
||||||
case LicenseTypes.LicenseWindows3270:
|
|
||||||
case LicenseTypes.LicenseWindows3812:
|
|
||||||
case LicenseTypes.LicenseWindows5250:
|
|
||||||
case LicenseTypes.LicenseWindowsTelnet:
|
|
||||||
return GenLicenseWindows(type, param_company, license);
|
|
||||||
|
|
||||||
case LicenseTypes.LicenseJavaTelnet:
|
|
||||||
case LicenseTypes.LicenseJava3270:
|
|
||||||
// case LicenseTypes.LicenseJava5250:
|
|
||||||
return GenLicenseJava(type, param_company, license);
|
|
||||||
|
|
||||||
case LicenseTypes.LicenseMac3270:
|
|
||||||
case LicenseTypes.LicenseMac5250:
|
|
||||||
return GenLicenseMacAlpha(type, param_company, license);
|
|
||||||
|
|
||||||
case LicenseTypes.LicenseMac3812:
|
|
||||||
case LicenseTypes.LicenseMacTelnet:
|
|
||||||
case LicenseTypes.LicenseMacKeyboard:
|
|
||||||
return GenLicenseMacNum(type, param_company, license);
|
|
||||||
|
|
||||||
case LicenseTypes.LicenseChrome3270:
|
|
||||||
case LicenseTypes.LicenseChrome5250:
|
|
||||||
case LicenseTypes.LicenseChromeTelnet:
|
|
||||||
return GenLicenseJavascript(type, param_company, license);
|
|
||||||
|
|
||||||
case LicenseTypes.LicenseAndroid3270:
|
|
||||||
case LicenseTypes.LicenseAndroid5250:
|
|
||||||
case LicenseTypes.LicenseAndroidTelnet:
|
|
||||||
case LicenseTypes.LicenseAndroidVnc:
|
|
||||||
case LicenseTypes.LicenseAndroidBarcode:
|
|
||||||
return GenLicenseAndroid(type, param_company, license);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* By far the easiest implemntation, everything was already in .NET :P
|
|
||||||
*/
|
|
||||||
public string GenLicenseWindows(int type, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
string param_lickey = type.ToString();
|
|
||||||
uint num1 = 0;
|
|
||||||
byte[] byteArray = this.StrToByteArray(param_company);
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if ((int) byteArray[index] >= 65 && (int) byteArray[index] <= 90)
|
|
||||||
byteArray[index] += (byte) 32; // this is basically str.toLower()
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if ((int) byteArray[index] >= 65) // 'A'
|
|
||||||
num1 += (uint) byteArray[index] + (uint) license;
|
|
||||||
}
|
|
||||||
uint num2 = num1 * (uint) param_lickey[0];
|
|
||||||
uint num3 = (uint) ((int) num2 * ((int) num2 & (int) byte.MaxValue) & (int) ushort.MaxValue);
|
|
||||||
if (num3 < 100U)
|
|
||||||
num3 = 2728U;
|
|
||||||
|
|
||||||
param_lickey = (param_lickey[0].ToString() + (object) num3) + '-' +
|
|
||||||
(Int32) (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
|
||||||
|
|
||||||
|
|
||||||
return param_lickey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pretty stright forward implementation as well
|
|
||||||
* .NET is just a copy of Java afterall
|
|
||||||
*/
|
|
||||||
public string GenLicenseJava(int itype, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
char type = (char) (itype + (int) 'A');
|
|
||||||
string param_lickey = type.ToString() + '@';
|
|
||||||
byte[] byteArray = this.StrToByteArray(param_company);
|
|
||||||
uint num1 = 0;
|
|
||||||
|
|
||||||
for (int b = 0; b < byteArray.Length; b++)
|
|
||||||
{
|
|
||||||
if (param_company.ToCharArray()[b] > ' ')
|
|
||||||
num1 += param_company.ToCharArray()[b] + (uint) license;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint num2 = num1 * (uint) param_lickey[0];
|
|
||||||
uint num3 = (uint) ((int) num2 * ((int) num2 & (int) byte.MaxValue) & (int) ushort.MaxValue);
|
|
||||||
param_lickey += (object) num3;
|
|
||||||
return param_lickey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Now the fun stuff..
|
|
||||||
*
|
|
||||||
* Beware! the Mac versions rely on datatype truncation
|
|
||||||
* It's a real pain in the ass to make sure the datatypes are all accurate
|
|
||||||
*/
|
|
||||||
public string GenLicenseMacAlpha(int itype, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
// must start with an 'a' or 'b;
|
|
||||||
char type = (char) (itype + (int) 'a');
|
|
||||||
string param_lickey = type.ToString();
|
|
||||||
byte[] byteArray = this.StrToByteArray(param_company);
|
|
||||||
short num1 = 0;
|
|
||||||
|
|
||||||
for (int b = 0; b < byteArray.Length; b++)
|
|
||||||
{
|
|
||||||
if (param_company.ToCharArray()[b] >= 0x21)
|
|
||||||
num1 += (short) (param_company.ToCharArray()[b] + license);
|
|
||||||
}
|
|
||||||
|
|
||||||
ushort num2 = (ushort) (num1 * (short) param_lickey[0]);
|
|
||||||
param_lickey += (ushort) ((num2 & byte.MaxValue) * num2);
|
|
||||||
return param_lickey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Beware! the Mac versions rely on datatype truncation
|
|
||||||
* It's a real pain in the ass to make sure the datatypes are all accurate
|
|
||||||
*
|
|
||||||
* There's a special case for the MacKeyboard as it deviates from the rest of the algoritm
|
|
||||||
* The (byte) cast is extmely important
|
|
||||||
*/
|
|
||||||
public string GenLicenseMacNum(int itype, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
char type = (char) (itype + (int) '0');
|
|
||||||
string param_lickey = type.ToString();
|
|
||||||
uint num1 = 0;
|
|
||||||
byte[] byteArray = this.StrToByteArray(param_company);
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if (license == LicenseTypes.LicenseMacKeyboard && (byte) (byteArray[index] + 0xbf) < 0x1a)
|
|
||||||
{
|
|
||||||
byteArray[index] += 32;
|
|
||||||
}
|
|
||||||
else if (license != LicenseTypes.LicenseMacKeyboard && byteArray[index] + 0xbf < 0x1a)
|
|
||||||
{
|
|
||||||
byteArray[index] += 32;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if ((int) byteArray[index] >= 0x41) // 'A'
|
|
||||||
num1 += (uint) byteArray[index] + (uint) license;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint num2 = (uint) (num1 * (int) param_lickey[0]);
|
|
||||||
num2 = (uint) (num2 * (num2 & byte.MaxValue) & ushort.MaxValue);
|
|
||||||
ulong num3 = 0xaa8;
|
|
||||||
if (99 < num2)
|
|
||||||
{
|
|
||||||
num3 = (ulong) num2;
|
|
||||||
}
|
|
||||||
|
|
||||||
param_lickey = param_lickey[0].ToString() + (object) num3;
|
|
||||||
|
|
||||||
|
|
||||||
return param_lickey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This one was fun as well
|
|
||||||
* Found out that the license must end with "45" in order to validate
|
|
||||||
*/
|
|
||||||
public string GenLicenseJavascript(int itype, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
char type = (char) (itype + (int) '0');
|
|
||||||
string param_lickey = type.ToString();
|
|
||||||
ulong sum = 0;
|
|
||||||
byte[] byteArray = this.StrToByteArray(param_company);
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if ((ulong) byteArray[index] >= 65 && (ulong) byteArray[index] <= 90)
|
|
||||||
byteArray[index] += 32; // this is basically str.toLower()
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if ((ulong) byteArray[index] >= 65 && (ulong) byteArray[index] <= 122)
|
|
||||||
{
|
|
||||||
sum += byteArray[index] + (uint) license;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sum = sum * param_lickey[0];
|
|
||||||
sum = sum * (sum & byte.MaxValue) & ushort.MaxValue;
|
|
||||||
if (sum < 100U)
|
|
||||||
sum = 2728U;
|
|
||||||
|
|
||||||
param_lickey = (param_lickey[0].ToString() + (object) sum) + '-' +
|
|
||||||
(Int32) (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds
|
|
||||||
+ "45"; // a little salt, as a treat
|
|
||||||
|
|
||||||
return param_lickey;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public string GenLicenseAndroid(int itype, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
char type = (char) (itype + (int) '0');
|
|
||||||
string param_lickey = type.ToString();
|
|
||||||
long sum = 0;
|
|
||||||
byte[] byteArray = this.StrToByteArray(param_company);
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if ((long) byteArray[index] >= 65 && (long) byteArray[index] <= 90)
|
|
||||||
byteArray[index] += 32; // this is basically str.toLower()
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if ((ulong) byteArray[index] >= 65 && (ulong) byteArray[index] <= 122)
|
|
||||||
{
|
|
||||||
sum += byteArray[index] + (uint) license;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sum = sum * param_lickey[0];
|
|
||||||
sum = sum * (sum & byte.MaxValue) & ushort.MaxValue;
|
|
||||||
if (sum < 100U)
|
|
||||||
sum = 2728U;
|
|
||||||
|
|
||||||
param_lickey = (param_lickey[0].ToString() + (object) sum) + '-' +
|
|
||||||
(Int32) (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
|
||||||
|
|
||||||
return param_lickey;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public bool CheckLicense(string param_lickey, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
switch (license)
|
|
||||||
{
|
|
||||||
case LicenseTypes.LicenseWindows3270:
|
|
||||||
case LicenseTypes.LicenseWindows3812:
|
|
||||||
case LicenseTypes.LicenseWindows5250:
|
|
||||||
case LicenseTypes.LicenseWindowsTelnet:
|
|
||||||
return CheckLicenseWindows(param_lickey, param_company, license);
|
|
||||||
|
|
||||||
case LicenseTypes.LicenseJavaTelnet:
|
|
||||||
case LicenseTypes.LicenseJava3270:
|
|
||||||
// case LicenseTypes.LicenseJava5250:
|
|
||||||
return CheckLicenseJava(param_lickey, param_company, license);
|
|
||||||
|
|
||||||
case LicenseTypes.LicenseMac3270:
|
|
||||||
case LicenseTypes.LicenseMac5250:
|
|
||||||
case LicenseTypes.LicenseMac3812:
|
|
||||||
case LicenseTypes.LicenseMacTelnet:
|
|
||||||
case LicenseTypes.LicenseMacKeyboard:
|
|
||||||
return CheckLicenseMac(param_lickey, param_company, license);
|
|
||||||
|
|
||||||
case LicenseTypes.LicenseChrome3270:
|
|
||||||
case LicenseTypes.LicenseChrome5250:
|
|
||||||
case LicenseTypes.LicenseChromeTelnet:
|
|
||||||
return CheckLicenseJavaScript(param_lickey, param_company, license);
|
|
||||||
|
|
||||||
case LicenseTypes.LicenseAndroid3270:
|
|
||||||
case LicenseTypes.LicenseAndroid5250:
|
|
||||||
case LicenseTypes.LicenseAndroidTelnet:
|
|
||||||
case LicenseTypes.LicenseAndroidVnc:
|
|
||||||
case LicenseTypes.LicenseAndroidBarcode:
|
|
||||||
return CheckLicenseAndroid(param_lickey, param_company, license);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo: write some sanity checks
|
|
||||||
*/
|
|
||||||
public bool CheckLicenseAndroid(string param_lickey, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
byte[] bArr = new byte[255];
|
|
||||||
byte[] bArr2 = new byte[255];
|
|
||||||
if (param_company.Length < 2 || param_lickey.Length < 2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < param_lickey.Length; i++)
|
|
||||||
{
|
|
||||||
bArr2[i] = (byte) param_lickey[i];
|
|
||||||
}
|
|
||||||
for (int i2 = 0; i2 < param_company.Length; i2++)
|
|
||||||
{
|
|
||||||
bArr[i2] = (byte) param_company[i2];
|
|
||||||
if (param_company[i2] >= 'A' && param_company[i2] <= 'Z')
|
|
||||||
{
|
|
||||||
bArr[i2] = (byte) (bArr[i2] + 32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long j = 0;
|
|
||||||
for (int i3 = 0; i3 < param_company.Length; i3++)
|
|
||||||
{
|
|
||||||
if (bArr[i3] >= 65 && bArr[i3] <= 122)
|
|
||||||
{
|
|
||||||
j += (bArr[i3] + (long) license);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long j2 = j * bArr2[0];
|
|
||||||
long j3 = (j2 * (j2 & 255)) & 65535;
|
|
||||||
if (j3 < 100)
|
|
||||||
{
|
|
||||||
j3 = 2728;
|
|
||||||
}
|
|
||||||
string sb = "";
|
|
||||||
sb += param_lickey[0];
|
|
||||||
sb += (object) j3;
|
|
||||||
if (param_lickey.StartsWith(sb))
|
|
||||||
{
|
|
||||||
// lictype = bArr2[0] - 48;
|
|
||||||
// is_lite2 = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// lictype = -1;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All Javascript licenses need to end with "45" in order to validate
|
|
||||||
*/
|
|
||||||
public bool CheckLicenseJavaScript(string param_lickey, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
ulong sum = 0;
|
|
||||||
byte[] byteArray = this.StrToByteArray(param_company);
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if ((ulong) byteArray[index] >= 65 && (ulong) byteArray[index] <= 90)
|
|
||||||
byteArray[index] += 32; // this is basically str.toLower()
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if ((ulong) byteArray[index] >= 65 && (ulong) byteArray[index] <= 122)
|
|
||||||
{
|
|
||||||
sum += byteArray[index] + (uint) license;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sum = sum * param_lickey[0];
|
|
||||||
sum = sum * (sum & byte.MaxValue) & ushort.MaxValue;
|
|
||||||
if (sum < 100U)
|
|
||||||
sum = 2728U;
|
|
||||||
|
|
||||||
if (!param_lickey.StartsWith(param_lickey[0].ToString() + (object) sum) || !param_lickey.EndsWith("45"))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo: write some sanity checks
|
|
||||||
*/
|
|
||||||
public bool CheckLicenseJava(string param_lickey, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo: write some sanity checks
|
|
||||||
*/
|
|
||||||
public bool CheckLicenseMac(string param_lickey, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CheckLicenseWindows(string param_lickey, string param_company, LicenseTypes license)
|
|
||||||
{
|
|
||||||
uint num1 = 0;
|
|
||||||
if (param_company == null || param_company.Length < 2)
|
|
||||||
return false;
|
|
||||||
byte[] byteArray = this.StrToByteArray(param_company);
|
|
||||||
if (param_lickey == null || param_lickey.Length < 6)
|
|
||||||
return false;
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
// >= 'A' && <= 'Z'
|
|
||||||
if ((int) byteArray[index] >= 65 && (int) byteArray[index] <= 90)
|
|
||||||
byteArray[index] += (byte) 32;
|
|
||||||
}
|
|
||||||
for (int index = 0; index < byteArray.Length; ++index)
|
|
||||||
{
|
|
||||||
if ((int) byteArray[index] >= 65) // 'A'
|
|
||||||
num1 += (uint) byteArray[index] + (uint) license;
|
|
||||||
}
|
|
||||||
uint num2 = num1 * (uint) param_lickey[0];
|
|
||||||
uint num3 = (uint) ((int) num2 * ((int) num2 & (int) byte.MaxValue) & (int) ushort.MaxValue);
|
|
||||||
if (num3 < 100U)
|
|
||||||
num3 = 2728U;
|
|
||||||
|
|
||||||
if (param_lickey.StartsWith((param_lickey[0].ToString() ?? "") + (object) num3))
|
|
||||||
{
|
|
||||||
//this.aa = param_lickey.Substring(0, 1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//this.aa = "";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] StrToByteArray(string str)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Encoding.GetEncoding(this.param_encoding).GetBytes(str);
|
|
||||||
}
|
|
||||||
catch (Exception ex1)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Encoding.GetEncoding(0).GetBytes(str);
|
|
||||||
}
|
|
||||||
catch (Exception ex2)
|
|
||||||
{
|
|
||||||
return new byte[1] {(byte) 63};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ByteArrayToStr(byte[] barr, int index, int length)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Encoding.GetEncoding(this.param_encoding).GetString(barr, index, length);
|
|
||||||
}
|
|
||||||
catch (Exception ex1)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Encoding.GetEncoding(0).GetString(barr, index, length);
|
|
||||||
}
|
|
||||||
catch (Exception ex2)
|
|
||||||
{
|
|
||||||
return "?";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FrappeMocha.Keygen
|
||||||
|
{
|
||||||
|
public abstract class KeygenBase
|
||||||
|
{
|
||||||
|
public const string CompanyLicense = "Company License";
|
||||||
|
public const string SingleUserLicense = "Single User License";
|
||||||
|
|
||||||
|
protected string Platform;
|
||||||
|
protected int ByteEncoding = 0;
|
||||||
|
public List<KeygenProduct> Products = new List<KeygenProduct>();
|
||||||
|
|
||||||
|
public abstract string Generate(int type, string paramCompany, LicenseTypes license);
|
||||||
|
public abstract bool Check(string paramLicenseKey, string paramCompany, LicenseTypes license);
|
||||||
|
|
||||||
|
|
||||||
|
public virtual List<string> GenerateLicencetypes(KeygenProduct p)
|
||||||
|
{
|
||||||
|
List<string> licenses = new List<string>();
|
||||||
|
licenses.Add(CompanyLicense);
|
||||||
|
licenses.Add(SingleUserLicense);
|
||||||
|
return licenses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] StrToByteArray(string str)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Encoding.GetEncoding(this.ByteEncoding).GetBytes(str);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Encoding.GetEncoding(0).GetBytes(str);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return new byte[1] { (byte)63 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ByteArrayToStr(byte[] barr, int index, int length)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Encoding.GetEncoding(this.ByteEncoding).GetString(barr, index, length);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Encoding.GetEncoding(0).GetString(barr, index, length);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace FrappeMocha.Keygen
|
||||||
|
{
|
||||||
|
public class KeygenProduct
|
||||||
|
{
|
||||||
|
public LicenseTypes Licence;
|
||||||
|
public string Description;
|
||||||
|
|
||||||
|
public KeygenProduct(LicenseTypes licence, string description, string platform)
|
||||||
|
{
|
||||||
|
Licence = licence;
|
||||||
|
Description = description + " for " + platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
return obj is KeygenProduct product && Description == product.Description ||
|
||||||
|
obj is string description && description == Description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
var hashCode = -1651123971;
|
||||||
|
hashCode = hashCode * -1521134295 + Licence.GetHashCode();
|
||||||
|
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Description);
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
namespace FrappeMocha.Keygen
|
||||||
|
{
|
||||||
|
public enum LicenseTypes
|
||||||
|
{
|
||||||
|
Windows3270 = 0x8c,
|
||||||
|
Windows5250 = 0x80,
|
||||||
|
Windows3812 = 0xa0,
|
||||||
|
WindowsTelnet = 0x9b,
|
||||||
|
|
||||||
|
Java3270 = 0x1b + 2,
|
||||||
|
Java5250 = 0x1b + 2,
|
||||||
|
JavaTelnet = 0x1b,
|
||||||
|
|
||||||
|
Mac3270 = 0x5d,
|
||||||
|
Mac5250 = 0x16,
|
||||||
|
Mac3812 = 0x22,
|
||||||
|
MacTelnet = 0x5e,
|
||||||
|
MacKeyboard = 0xa5,
|
||||||
|
|
||||||
|
JavaScript3270 = 0xb3,
|
||||||
|
JavaScript5250 = 0xb2,
|
||||||
|
JavaScriptTelnet = 0xb4,
|
||||||
|
|
||||||
|
Android3270 = 0x94,
|
||||||
|
Android5250 = 0x91,
|
||||||
|
AndroidTelnet = 0x96,
|
||||||
|
AndroidVnc = 0x92,
|
||||||
|
AndroidBarcode = 0x9c,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FrappeMocha.Keygen.Platforms
|
||||||
|
{
|
||||||
|
public class PlatformAndroid : KeygenBase
|
||||||
|
{
|
||||||
|
public PlatformAndroid()
|
||||||
|
{
|
||||||
|
Platform = "Android";
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.Android3270, "TN3270", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.Android5250, "TN5250", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.AndroidTelnet, "TN3812", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.AndroidVnc, "VNC", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.AndroidBarcode, "Barcode", Platform));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This was also a piece of cake since PlatformJava is the underlying tech on PlatformAndroid
|
||||||
|
* The Dex object engine keept pretty good tabs on the types and var names as well!
|
||||||
|
*/
|
||||||
|
public override string Generate(int itype, string paramCompany, LicenseTypes license)
|
||||||
|
{
|
||||||
|
char type = (char)(itype + '0');
|
||||||
|
string paramLicencekey = type.ToString();
|
||||||
|
long sum = 0;
|
||||||
|
byte[] byteArray = StrToByteArray(paramCompany);
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if ((long)byteArray[index] >= 'A' && (long)byteArray[index] <= 'Z')
|
||||||
|
byteArray[index] += 32; // this is basically str.toLower()
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if ((ulong)byteArray[index] >= 'A' && (ulong)byteArray[index] <= 'z')
|
||||||
|
{
|
||||||
|
sum += byteArray[index] + (uint)license;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sum = sum * paramLicencekey[0];
|
||||||
|
sum = sum * (sum & byte.MaxValue) & ushort.MaxValue;
|
||||||
|
if (sum < 100U)
|
||||||
|
sum = 2728U;
|
||||||
|
|
||||||
|
paramLicencekey = (paramLicencekey[0].ToString() + sum) + '-' +
|
||||||
|
(Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||||
|
|
||||||
|
return paramLicencekey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Straight outta da Dex
|
||||||
|
*/
|
||||||
|
public override bool Check(string paramLicenseKey, string paramCompany, LicenseTypes license)
|
||||||
|
{
|
||||||
|
byte[] bArr = new byte[255];
|
||||||
|
byte[] bArr2 = new byte[255];
|
||||||
|
if (paramCompany.Length < 2 || paramLicenseKey.Length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < paramLicenseKey.Length; i++)
|
||||||
|
{
|
||||||
|
bArr2[i] = (byte)paramLicenseKey[i];
|
||||||
|
}
|
||||||
|
for (int i2 = 0; i2 < paramCompany.Length; i2++)
|
||||||
|
{
|
||||||
|
bArr[i2] = (byte)paramCompany[i2];
|
||||||
|
if (paramCompany[i2] >= 'A' && paramCompany[i2] <= 'Z')
|
||||||
|
{
|
||||||
|
bArr[i2] = (byte)(bArr[i2] + 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long j = 0;
|
||||||
|
for (int i3 = 0; i3 < paramCompany.Length; i3++)
|
||||||
|
{
|
||||||
|
if (bArr[i3] >= 65 && bArr[i3] <= 122)
|
||||||
|
{
|
||||||
|
j += (bArr[i3] + (long)license);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long j2 = j * bArr2[0];
|
||||||
|
long j3 = (j2 * (j2 & 255)) & 65535;
|
||||||
|
if (j3 < 100)
|
||||||
|
{
|
||||||
|
j3 = 2728;
|
||||||
|
}
|
||||||
|
string sb = "";
|
||||||
|
sb += paramLicenseKey[0];
|
||||||
|
sb += (object)j3;
|
||||||
|
if (paramLicenseKey.StartsWith(sb))
|
||||||
|
{
|
||||||
|
// lictype = bArr2[0] - 48;
|
||||||
|
// is_lite2 = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// lictype = -1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace FrappeMocha.Keygen.Platforms
|
||||||
|
{
|
||||||
|
public class PlatformJava : KeygenBase
|
||||||
|
{
|
||||||
|
public PlatformJava()
|
||||||
|
{
|
||||||
|
Platform = "Java";
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.Java3270, "TN3270", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.Java5250, "TN5250", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.JavaTelnet, "Telnet", Platform));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override List<string> GenerateLicencetypes(KeygenProduct p)
|
||||||
|
{
|
||||||
|
List<string> types = new List<string>();
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
types.Add(((char)(i + 'A')).ToString());
|
||||||
|
}
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pretty stright forward implementation as well
|
||||||
|
* .NET is just a copy of PlatformJava afterall
|
||||||
|
*/
|
||||||
|
public override string Generate(int itype, string paramCompany, LicenseTypes license)
|
||||||
|
{
|
||||||
|
char type = (char)(itype + 'A');
|
||||||
|
string paramLicencekey = type.ToString() + '@';
|
||||||
|
int sum = 0;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (i < paramCompany.Length)
|
||||||
|
{
|
||||||
|
if (paramCompany[i] > ' ')
|
||||||
|
{
|
||||||
|
// 3270 and 5250 have a hardcoded 0x1b+2 here, we've just added it to the enum
|
||||||
|
sum += paramCompany[i] + (int)license;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
sum = sum * paramLicencekey[0];
|
||||||
|
sum = sum * (sum & byte.MaxValue) & ushort.MaxValue;
|
||||||
|
paramLicencekey += sum.ToString();
|
||||||
|
return paramLicencekey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Straight outta da JAR
|
||||||
|
*/
|
||||||
|
public override bool Check(string paramLicenseKey, string paramCompany, LicenseTypes license)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int n = 0;
|
||||||
|
while (i < paramCompany.Length)
|
||||||
|
{
|
||||||
|
if (paramCompany[i] > ' ')
|
||||||
|
{
|
||||||
|
// 3270 and 5250 have a hardcoded 0x1b+2 here, we've just added it to the enum
|
||||||
|
n += paramCompany[i] + (int)license;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
if (paramLicenseKey.Length > 0)
|
||||||
|
{
|
||||||
|
switch (paramLicenseKey[0])
|
||||||
|
{
|
||||||
|
case 'A':
|
||||||
|
case 'B':
|
||||||
|
case 'C':
|
||||||
|
case 'D':
|
||||||
|
case 'E':
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int n2 = n * paramLicenseKey[0];
|
||||||
|
n2 = n2 * (n2 & 0xFF) & 0xFFFF;
|
||||||
|
|
||||||
|
string check = paramLicenseKey[0].ToString() + paramLicenseKey[1].ToString() + n2.ToString();
|
||||||
|
if (paramLicenseKey[1] == '@' && check == paramLicenseKey)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FrappeMocha.Keygen.Platforms
|
||||||
|
{
|
||||||
|
public class PlatformJavaScript : KeygenBase
|
||||||
|
{
|
||||||
|
public PlatformJavaScript()
|
||||||
|
{
|
||||||
|
Platform = "Google Chrome";
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.JavaScript3270, "TN3270", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.JavaScript5250, "TN5250", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.JavaScriptTelnet, "Telnet", Platform));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This one was fun as well
|
||||||
|
* Found out that the license must end with "45" in order to validate
|
||||||
|
*/
|
||||||
|
public override string Generate(int itype, string paramCompany, LicenseTypes license)
|
||||||
|
{
|
||||||
|
char type = (char)(itype + '0');
|
||||||
|
string param_lickey = type.ToString();
|
||||||
|
ulong sum = 0;
|
||||||
|
byte[] byteArray = StrToByteArray(paramCompany);
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if (byteArray[index] >= 'A' && byteArray[index] <= 'Z')
|
||||||
|
byteArray[index] += 32; // ASCII 'Space'
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if ((ulong)byteArray[index] >= 'A' && (ulong)byteArray[index] <= 'z')
|
||||||
|
{
|
||||||
|
sum += byteArray[index] + (uint)license;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sum = sum * param_lickey[0];
|
||||||
|
sum = sum * (sum & byte.MaxValue) & ushort.MaxValue;
|
||||||
|
if (sum < 100U)
|
||||||
|
sum = 2728U;
|
||||||
|
|
||||||
|
param_lickey = (param_lickey[0].ToString() + sum) + '-' +
|
||||||
|
(Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds
|
||||||
|
+ "45"; // a little salt, as a treat
|
||||||
|
|
||||||
|
return param_lickey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Straight outta da JS
|
||||||
|
*/
|
||||||
|
public override bool Check(string paramLicenseKey, string paramCompany, LicenseTypes license)
|
||||||
|
{
|
||||||
|
ulong sum = 0;
|
||||||
|
byte[] byteArray = this.StrToByteArray(paramCompany);
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if ((ulong)byteArray[index] >= 65 && (ulong)byteArray[index] <= 90)
|
||||||
|
byteArray[index] += 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if ((ulong)byteArray[index] >= 65 && (ulong)byteArray[index] <= 122)
|
||||||
|
{
|
||||||
|
sum += byteArray[index] + (uint)license;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sum = sum * paramLicenseKey[0];
|
||||||
|
sum = sum * (sum & byte.MaxValue) & ushort.MaxValue;
|
||||||
|
if (sum < 100U)
|
||||||
|
sum = 2728U;
|
||||||
|
|
||||||
|
if (!paramLicenseKey.StartsWith(paramLicenseKey[0].ToString() + sum) || !paramLicenseKey.EndsWith("45"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace FrappeMocha.Keygen.Platforms
|
||||||
|
{
|
||||||
|
public class PlatformMac : KeygenBase
|
||||||
|
{
|
||||||
|
public PlatformMac()
|
||||||
|
{
|
||||||
|
Platform = "MacOSX";
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.Mac3270, "TN3270", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.Mac5250, "TN5250", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.Mac3812, "TN3812", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.MacTelnet, "Telnet", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.MacKeyboard, "Keyboard", Platform));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override List<string> GenerateLicencetypes(KeygenProduct p)
|
||||||
|
{
|
||||||
|
if (p.Licence != LicenseTypes.Mac3812 &&
|
||||||
|
p.Licence != LicenseTypes.MacTelnet &&
|
||||||
|
p.Licence != LicenseTypes.MacKeyboard)
|
||||||
|
{
|
||||||
|
return base.GenerateLicencetypes(p);
|
||||||
|
}
|
||||||
|
List<string> types = new List<string>();
|
||||||
|
types.Add("0");
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Generate(int type, string paramCompany, LicenseTypes license)
|
||||||
|
{
|
||||||
|
switch (license)
|
||||||
|
{
|
||||||
|
// Prefix Num
|
||||||
|
case LicenseTypes.Mac3270:
|
||||||
|
case LicenseTypes.Mac5250:
|
||||||
|
return GeneratePrefixNumber(type, paramCompany, license);
|
||||||
|
|
||||||
|
// Prefix Alpha
|
||||||
|
case LicenseTypes.Mac3812:
|
||||||
|
case LicenseTypes.MacTelnet:
|
||||||
|
case LicenseTypes.MacKeyboard:
|
||||||
|
return GeneratePrefixAlpha(type, paramCompany, license);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo: write some sanity checks
|
||||||
|
* I doubt I'll be able to get something straight outta da Ghidra here...
|
||||||
|
*/
|
||||||
|
public override bool Check(string paramLicenseKey, string paramCompany, LicenseTypes license)
|
||||||
|
{
|
||||||
|
switch (license)
|
||||||
|
{
|
||||||
|
// Prefix Num
|
||||||
|
case LicenseTypes.Mac3270:
|
||||||
|
case LicenseTypes.Mac5250:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Prefix Alpha
|
||||||
|
case LicenseTypes.Mac3812:
|
||||||
|
case LicenseTypes.MacTelnet:
|
||||||
|
case LicenseTypes.MacKeyboard:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Now the fun stuff..
|
||||||
|
*
|
||||||
|
* Beware! the PlatformMac versions rely on datatype truncation
|
||||||
|
* It's a real pain in the ass to make sure the datatypes are all accurate
|
||||||
|
*/
|
||||||
|
public string GeneratePrefixAlpha(int itype, string param_company, LicenseTypes license)
|
||||||
|
{
|
||||||
|
// must start with an 'a' or 'b;
|
||||||
|
char type = (char)(itype + (int)'a');
|
||||||
|
string param_lickey = type.ToString();
|
||||||
|
ushort sum = 0;
|
||||||
|
|
||||||
|
for (int b = 0; b < param_company.Length; b++)
|
||||||
|
{
|
||||||
|
if (param_company[b] >= 0x21)
|
||||||
|
sum += (ushort)(param_company[b] + license);
|
||||||
|
}
|
||||||
|
|
||||||
|
sum = (ushort)(sum * (short)param_lickey[0]);
|
||||||
|
param_lickey += (ushort)((sum & byte.MaxValue) * sum);
|
||||||
|
return param_lickey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Beware! the PlatformMac versions rely on datatype truncation
|
||||||
|
* It's a real pain in the ass to make sure the datatypes are all accurate
|
||||||
|
*
|
||||||
|
* There's a special case for the MacKeyboard as it deviates from the rest of the algoritm
|
||||||
|
* The (byte) cast is extmely important
|
||||||
|
*/
|
||||||
|
public string GeneratePrefixNumber(int itype, string param_company, LicenseTypes license)
|
||||||
|
{
|
||||||
|
char type = (char)(itype + (int)'0');
|
||||||
|
string param_lickey = type.ToString();
|
||||||
|
uint num1 = 0;
|
||||||
|
byte[] byteArray = StrToByteArray(param_company);
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if (license == LicenseTypes.MacKeyboard && (byte)(byteArray[index] + 0xbf) < 0x1a)
|
||||||
|
{
|
||||||
|
byteArray[index] += 32;
|
||||||
|
}
|
||||||
|
else if (license != LicenseTypes.MacKeyboard && byteArray[index] + 0xbf < 0x1a)
|
||||||
|
{
|
||||||
|
byteArray[index] += 32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if (byteArray[index] >= 0x41) // 'A'
|
||||||
|
num1 += byteArray[index] + (uint)license;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint num2 = (uint)(num1 * (int)param_lickey[0]);
|
||||||
|
num2 = (num2 * (num2 & byte.MaxValue) & ushort.MaxValue);
|
||||||
|
ulong num3 = 0xaa8;
|
||||||
|
if (99 < num2)
|
||||||
|
{
|
||||||
|
num3 = num2;
|
||||||
|
}
|
||||||
|
|
||||||
|
param_lickey = param_lickey[0].ToString() + num3;
|
||||||
|
|
||||||
|
|
||||||
|
return param_lickey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FrappeMocha.Keygen.Platforms
|
||||||
|
{
|
||||||
|
public class PlatformWindows : KeygenBase
|
||||||
|
{
|
||||||
|
public PlatformWindows()
|
||||||
|
{
|
||||||
|
Platform = "Windows";
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.Windows3270, "TN3270", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.Windows5250, "TN5250", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.Windows3812, "TN3812", Platform));
|
||||||
|
Products.Add(new KeygenProduct(LicenseTypes.WindowsTelnet, "Telnet", Platform));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Generate(int type, string paramCompany, LicenseTypes license)
|
||||||
|
{
|
||||||
|
string licenseKey = type.ToString();
|
||||||
|
uint sum = 0;
|
||||||
|
byte[] byteArray = StrToByteArray(paramCompany);
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if (byteArray[index] >= 'A' && byteArray[index] <= 'Z')
|
||||||
|
byteArray[index] += 32; // ASCII 'Space'
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if (byteArray[index] >= 'A')
|
||||||
|
sum += byteArray[index] + (uint)license;
|
||||||
|
}
|
||||||
|
sum = sum * licenseKey[0];
|
||||||
|
sum = (uint)((int)sum * ((int)sum & byte.MaxValue) & ushort.MaxValue);
|
||||||
|
if (sum < 100U)
|
||||||
|
sum = 2728U;
|
||||||
|
|
||||||
|
licenseKey = (licenseKey[0].ToString() + sum) + '-' +
|
||||||
|
(Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||||
|
|
||||||
|
|
||||||
|
return licenseKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Straight outta da Assembley
|
||||||
|
*/
|
||||||
|
public override bool Check(string paramLicenseKey, string paramCompany, LicenseTypes license)
|
||||||
|
{
|
||||||
|
uint num1 = 0;
|
||||||
|
if (paramCompany == null || paramCompany.Length < 2)
|
||||||
|
return false;
|
||||||
|
byte[] byteArray = this.StrToByteArray(paramCompany);
|
||||||
|
if (paramLicenseKey == null || paramLicenseKey.Length < 6)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
// >= 'A' && <= 'Z'
|
||||||
|
if ((int)byteArray[index] >= 65 && (int)byteArray[index] <= 90)
|
||||||
|
byteArray[index] += (byte)32;
|
||||||
|
}
|
||||||
|
for (int index = 0; index < byteArray.Length; ++index)
|
||||||
|
{
|
||||||
|
if ((int)byteArray[index] >= 65) // 'A'
|
||||||
|
num1 += (uint)byteArray[index] + (uint)license;
|
||||||
|
}
|
||||||
|
uint num2 = num1 * (uint)paramLicenseKey[0];
|
||||||
|
uint num3 = (uint)((int)num2 * ((int)num2 & (int)byte.MaxValue) & (int)ushort.MaxValue);
|
||||||
|
if (num3 < 100U)
|
||||||
|
num3 = 2728U;
|
||||||
|
|
||||||
|
if (paramLicenseKey.StartsWith((paramLicenseKey[0].ToString() ?? "") + (object)num3))
|
||||||
|
{
|
||||||
|
//this.aa = param_lickey.Substring(0, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//this.aa = "";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
-194
@@ -1,194 +0,0 @@
|
|||||||
namespace FrappeMocha
|
|
||||||
{
|
|
||||||
partial class MainForm
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
|
||||||
this.TypeDropDown = new System.Windows.Forms.ComboBox();
|
|
||||||
this.companytext = new System.Windows.Forms.TextBox();
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.companyusernamelabel = new System.Windows.Forms.Label();
|
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
|
||||||
this.licensebox = new System.Windows.Forms.TextBox();
|
|
||||||
this.submit = new System.Windows.Forms.Button();
|
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
|
||||||
this.productSelect = new System.Windows.Forms.ComboBox();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// TypeDropDown
|
|
||||||
//
|
|
||||||
this.TypeDropDown.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.TypeDropDown.FormattingEnabled = true;
|
|
||||||
this.TypeDropDown.Items.AddRange(new object[] {
|
|
||||||
"Company License",
|
|
||||||
"Single User License"});
|
|
||||||
this.TypeDropDown.Location = new System.Drawing.Point(12, 65);
|
|
||||||
this.TypeDropDown.Name = "TypeDropDown";
|
|
||||||
this.TypeDropDown.Size = new System.Drawing.Size(146, 21);
|
|
||||||
this.TypeDropDown.TabIndex = 0;
|
|
||||||
this.TypeDropDown.SelectedIndexChanged += new System.EventHandler(this.TypeDropDown_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// companytext
|
|
||||||
//
|
|
||||||
this.companytext.Location = new System.Drawing.Point(12, 105);
|
|
||||||
this.companytext.MaxLength = 80;
|
|
||||||
this.companytext.Name = "companytext";
|
|
||||||
this.companytext.Size = new System.Drawing.Size(146, 20);
|
|
||||||
this.companytext.TabIndex = 1;
|
|
||||||
this.companytext.Text = "FrappeMocha";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(9, 49);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(71, 13);
|
|
||||||
this.label1.TabIndex = 2;
|
|
||||||
this.label1.Text = "License Type";
|
|
||||||
//
|
|
||||||
// companyusernamelabel
|
|
||||||
//
|
|
||||||
this.companyusernamelabel.AutoSize = true;
|
|
||||||
this.companyusernamelabel.Location = new System.Drawing.Point(9, 89);
|
|
||||||
this.companyusernamelabel.Name = "companyusernamelabel";
|
|
||||||
this.companyusernamelabel.Size = new System.Drawing.Size(115, 13);
|
|
||||||
this.companyusernamelabel.TabIndex = 3;
|
|
||||||
this.companyusernamelabel.Text = "Company / User Name";
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
this.label3.AutoSize = true;
|
|
||||||
this.label3.Location = new System.Drawing.Point(9, 128);
|
|
||||||
this.label3.Name = "label3";
|
|
||||||
this.label3.Size = new System.Drawing.Size(65, 13);
|
|
||||||
this.label3.TabIndex = 4;
|
|
||||||
this.label3.Text = "License Key";
|
|
||||||
//
|
|
||||||
// licensebox
|
|
||||||
//
|
|
||||||
this.licensebox.Location = new System.Drawing.Point(12, 144);
|
|
||||||
this.licensebox.Name = "licensebox";
|
|
||||||
this.licensebox.ReadOnly = true;
|
|
||||||
this.licensebox.Size = new System.Drawing.Size(146, 20);
|
|
||||||
this.licensebox.TabIndex = 5;
|
|
||||||
this.licensebox.Click += new System.EventHandler(this.licensebox_Click);
|
|
||||||
//
|
|
||||||
// submit
|
|
||||||
//
|
|
||||||
this.submit.Location = new System.Drawing.Point(12, 175);
|
|
||||||
this.submit.Name = "submit";
|
|
||||||
this.submit.Size = new System.Drawing.Size(146, 23);
|
|
||||||
this.submit.TabIndex = 6;
|
|
||||||
this.submit.Text = "Frappe Mocha";
|
|
||||||
this.submit.UseVisualStyleBackColor = true;
|
|
||||||
this.submit.Click += new System.EventHandler(this.submit_Click);
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
this.label2.AutoSize = true;
|
|
||||||
this.label2.Location = new System.Drawing.Point(12, 9);
|
|
||||||
this.label2.Name = "label2";
|
|
||||||
this.label2.Size = new System.Drawing.Size(44, 13);
|
|
||||||
this.label2.TabIndex = 7;
|
|
||||||
this.label2.Text = "Product";
|
|
||||||
//
|
|
||||||
// productSelect
|
|
||||||
//
|
|
||||||
this.productSelect.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.productSelect.FormattingEnabled = true;
|
|
||||||
this.productSelect.Items.AddRange(new object[] {
|
|
||||||
"TN3270 for Windows",
|
|
||||||
"TN5250 for Windows",
|
|
||||||
"TN3812 for Windows",
|
|
||||||
"Telnet for Windows",
|
|
||||||
"TN3270 for Java",
|
|
||||||
"TN5250 for Java",
|
|
||||||
"Telnet for Java",
|
|
||||||
"TN3270 for Mac OS X",
|
|
||||||
"TN5250 for Mac OS X",
|
|
||||||
"TN3812 for Mac OS X",
|
|
||||||
"Telnet for Mac OS X",
|
|
||||||
"Keyboard for Mac OS X",
|
|
||||||
"TN3270 for Google Chrome",
|
|
||||||
"TN5250 for Google Chrome",
|
|
||||||
"Telnet for Google Chrome",
|
|
||||||
"TN3270 for Android",
|
|
||||||
"TN5250 for Android",
|
|
||||||
"Telnet for Android",
|
|
||||||
"VNC for Android",
|
|
||||||
"Barcode for Android"});
|
|
||||||
this.productSelect.Location = new System.Drawing.Point(12, 25);
|
|
||||||
this.productSelect.Name = "productSelect";
|
|
||||||
this.productSelect.Size = new System.Drawing.Size(146, 21);
|
|
||||||
this.productSelect.TabIndex = 8;
|
|
||||||
this.productSelect.SelectedIndexChanged += new System.EventHandler(this.productSelect_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// MainForm
|
|
||||||
//
|
|
||||||
this.AcceptButton = this.submit;
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.BackColor = System.Drawing.SystemColors.Window;
|
|
||||||
this.ClientSize = new System.Drawing.Size(173, 210);
|
|
||||||
this.Controls.Add(this.productSelect);
|
|
||||||
this.Controls.Add(this.label2);
|
|
||||||
this.Controls.Add(this.submit);
|
|
||||||
this.Controls.Add(this.licensebox);
|
|
||||||
this.Controls.Add(this.label3);
|
|
||||||
this.Controls.Add(this.companyusernamelabel);
|
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Controls.Add(this.companytext);
|
|
||||||
this.Controls.Add(this.TypeDropDown);
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
|
||||||
this.KeyPreview = true;
|
|
||||||
this.MaximizeBox = false;
|
|
||||||
this.MinimizeBox = false;
|
|
||||||
this.Name = "MainForm";
|
|
||||||
this.Text = "FrappeMocha";
|
|
||||||
this.Shown += new System.EventHandler(this.MainForm_Shown);
|
|
||||||
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MainForm_KeyPress);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private System.Windows.Forms.ComboBox TypeDropDown;
|
|
||||||
private System.Windows.Forms.TextBox companytext;
|
|
||||||
private System.Windows.Forms.Label label1;
|
|
||||||
private System.Windows.Forms.Label companyusernamelabel;
|
|
||||||
private System.Windows.Forms.Label label3;
|
|
||||||
private System.Windows.Forms.TextBox licensebox;
|
|
||||||
private System.Windows.Forms.Button submit;
|
|
||||||
private System.Windows.Forms.Label label2;
|
|
||||||
private System.Windows.Forms.ComboBox productSelect;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-271
@@ -1,271 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace FrappeMocha
|
|
||||||
{
|
|
||||||
public partial class MainForm : Form
|
|
||||||
{
|
|
||||||
protected Keygen frappeKeygen;
|
|
||||||
private char[] ficus = new char[6];
|
|
||||||
private object[] windowsLicenseTypeItems = new object[2];
|
|
||||||
private object[] macLicenseTypeItems = new object[1];
|
|
||||||
private object[] javaLicenseTypeItems = new object[5];
|
|
||||||
|
|
||||||
public MainForm()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
TypeDropDown.SelectedIndex = 0;
|
|
||||||
productSelect.SelectedIndex = 0;
|
|
||||||
frappeKeygen = new Keygen();
|
|
||||||
this.initDropDownMenuItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initDropDownMenuItems()
|
|
||||||
{
|
|
||||||
TypeDropDown.Items.CopyTo(windowsLicenseTypeItems, 0);
|
|
||||||
|
|
||||||
initJavaLicenseTypeItems();
|
|
||||||
initMacLicenseTypeItems();
|
|
||||||
|
|
||||||
TypeDropDown.Items.Clear();
|
|
||||||
TypeDropDown.Items.AddRange(this.windowsLicenseTypeItems);
|
|
||||||
TypeDropDown.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initJavaLicenseTypeItems()
|
|
||||||
{
|
|
||||||
TypeDropDown.Items.Clear();
|
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
TypeDropDown.Items.Add((char) ('A' + i));
|
|
||||||
}
|
|
||||||
TypeDropDown.Items.CopyTo(this.javaLicenseTypeItems, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initMacLicenseTypeItems()
|
|
||||||
{
|
|
||||||
TypeDropDown.Items.Clear();
|
|
||||||
for (int i = 0; i < 1; i++)
|
|
||||||
{
|
|
||||||
TypeDropDown.Items.Add((char) ('0' + i));
|
|
||||||
}
|
|
||||||
TypeDropDown.Items.CopyTo(this.macLicenseTypeItems, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void submit_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
switch (productSelect.SelectedIndex)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseWindows3270);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseWindows5250);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseWindows3812);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseWindowsTelnet);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseJava3270);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseJava5250);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseJavaTelnet);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseMac3270);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseMac5250);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 9:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseMac3812);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 10:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseMacTelnet);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 11:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseMacKeyboard);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 12:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseChrome3270);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 13:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseChrome5250);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 14:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseChromeTelnet);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 15:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseAndroid3270);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 16:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseAndroid5250);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 17:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseAndroidTelnet);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 18:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseAndroidVnc);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 19:
|
|
||||||
this.keygen(Keygen.LicenseTypes.LicenseAndroidBarcode);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TypeDropDown_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
switch (TypeDropDown.SelectedIndex)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
companyusernamelabel.Text = "Company Name";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
companyusernamelabel.Text = "User Name";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TypeDropDown.Items.Count > 2)
|
|
||||||
{
|
|
||||||
companyusernamelabel.Text = "Name";
|
|
||||||
}
|
|
||||||
|
|
||||||
AcceptButton.PerformClick();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void keygen(Keygen.LicenseTypes license)
|
|
||||||
{
|
|
||||||
if (companytext.Text.Length <= 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show(
|
|
||||||
(TypeDropDown.SelectedIndex == 0
|
|
||||||
? "Company Name"
|
|
||||||
: "User Name") + " must be longer than one character", "Error",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (companytext.Text.Length > 80)
|
|
||||||
{
|
|
||||||
MessageBox.Show(
|
|
||||||
(TypeDropDown.SelectedIndex == 0
|
|
||||||
? "Company Name"
|
|
||||||
: "User Name") + " must not be greater than eighty characters", "Error",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string genlicense = frappeKeygen.GenLicense(TypeDropDown.SelectedIndex, companytext.Text, license);
|
|
||||||
if (!frappeKeygen.CheckLicense(genlicense, companytext.Text, license))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Generated license did not pass self check, please try again", "Warning",
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Warning);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
licensebox.Text = genlicense;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void productSelect_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
switch (productSelect.SelectedIndex)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 7: // mac type 1
|
|
||||||
case 8: // mac type 1
|
|
||||||
case 12:
|
|
||||||
if (windowsLicenseTypeItems[0] != null)
|
|
||||||
{
|
|
||||||
TypeDropDown.Items.Clear();
|
|
||||||
TypeDropDown.Items.AddRange(this.windowsLicenseTypeItems);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
TypeDropDown.Items.Clear();
|
|
||||||
TypeDropDown.Items.AddRange(this.javaLicenseTypeItems);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 9: // mac type 2
|
|
||||||
case 10:
|
|
||||||
case 11:
|
|
||||||
TypeDropDown.Items.Clear();
|
|
||||||
TypeDropDown.Items.AddRange(this.macLicenseTypeItems);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
TypeDropDown.SelectedIndex = 0;
|
|
||||||
AcceptButton.PerformClick();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void licensebox_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
licensebox.SelectAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MainForm_Shown(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
AcceptButton.PerformClick();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MainForm_KeyPress(object sender, KeyPressEventArgs e)
|
|
||||||
{
|
|
||||||
Array.Copy(this.ficus, 1, this.ficus, 0, this.ficus.Length - 1);
|
|
||||||
this.ficus[ficus.Length - 1] = e.KeyChar;
|
|
||||||
if (new string(ficus) == "spicey")
|
|
||||||
{
|
|
||||||
switch (MessageBox.Show("Would you like a little salt, as a treat?", "Orly?",
|
|
||||||
MessageBoxButtons.YesNoCancel,
|
|
||||||
MessageBoxIcon.Question))
|
|
||||||
{
|
|
||||||
case DialogResult.Yes:
|
|
||||||
Process.Start("https://i.imgur.com/EJ31bmk.jpg");
|
|
||||||
break;
|
|
||||||
case DialogResult.No:
|
|
||||||
Process.Start(
|
|
||||||
"https://pics.me.me/white-people-cant-handle-spicy-food-um-try-again-sweetie-6626438.png");
|
|
||||||
break;
|
|
||||||
case DialogResult.Cancel:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using FrappeMocha.Keygen;
|
||||||
|
using FrappeMocha.Keygen.Platforms;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
namespace PlatformUnitTests
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class PlatformUnitTest
|
||||||
|
{
|
||||||
|
private KeygenBase platform;
|
||||||
|
private readonly string[] _testCompanyUserStrings = {"Test", "FrappeMocha", "abcd", "1234"};
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestWindowsPlatform()
|
||||||
|
{
|
||||||
|
platform = new PlatformWindows();
|
||||||
|
foreach (var product in platform.Products)
|
||||||
|
{
|
||||||
|
var types = platform.GenerateLicencetypes(product);
|
||||||
|
for (int i = 0; i < types.Count; i++)
|
||||||
|
{
|
||||||
|
foreach (string company in _testCompanyUserStrings)
|
||||||
|
{
|
||||||
|
var key = platform.Generate(i, company, product.Licence);
|
||||||
|
Assert.IsTrue(platform.Check(key, company, product.Licence));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestMacOsxPlatform()
|
||||||
|
{
|
||||||
|
platform = new PlatformMac();
|
||||||
|
foreach (var product in platform.Products)
|
||||||
|
{
|
||||||
|
var types = platform.GenerateLicencetypes(product);
|
||||||
|
for (int i = 0; i < types.Count; i++)
|
||||||
|
{
|
||||||
|
foreach (string company in _testCompanyUserStrings)
|
||||||
|
{
|
||||||
|
var key = platform.Generate(i, company, product.Licence);
|
||||||
|
Assert.IsTrue(platform.Check(key, company, product.Licence));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestAndroidPlatform()
|
||||||
|
{
|
||||||
|
platform = new PlatformAndroid();
|
||||||
|
foreach (var product in platform.Products)
|
||||||
|
{
|
||||||
|
var types = platform.GenerateLicencetypes(product);
|
||||||
|
for (int i = 0; i < types.Count; i++)
|
||||||
|
{
|
||||||
|
foreach (string company in _testCompanyUserStrings)
|
||||||
|
{
|
||||||
|
var key = platform.Generate(i, company, product.Licence);
|
||||||
|
Assert.IsTrue(platform.Check(key, company, product.Licence));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestJavaPlatform()
|
||||||
|
{
|
||||||
|
platform = new PlatformJava();
|
||||||
|
foreach (var product in platform.Products)
|
||||||
|
{
|
||||||
|
var types = platform.GenerateLicencetypes(product);
|
||||||
|
for (int i = 0; i < types.Count; i++)
|
||||||
|
{
|
||||||
|
foreach (string company in _testCompanyUserStrings)
|
||||||
|
{
|
||||||
|
var key = platform.Generate(i, company, product.Licence);
|
||||||
|
Assert.IsTrue(platform.Check(key, company, product.Licence));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestJavaScriptPlatform()
|
||||||
|
{
|
||||||
|
platform = new PlatformJavaScript();
|
||||||
|
foreach (var product in platform.Products)
|
||||||
|
{
|
||||||
|
var types = platform.GenerateLicencetypes(product);
|
||||||
|
for (int i = 0; i < types.Count; i++)
|
||||||
|
{
|
||||||
|
foreach (string company in _testCompanyUserStrings)
|
||||||
|
{
|
||||||
|
var key = platform.Generate(i, company, product.Licence);
|
||||||
|
Assert.IsTrue(platform.Check(key, company, product.Licence));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
|
||||||
|
<ApplicationIcon />
|
||||||
|
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
|
||||||
|
<StartupObject />
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FrappeMocha.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
+1
-1
@@ -14,7 +14,7 @@ namespace FrappeMocha
|
|||||||
{
|
{
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new MainForm());
|
Application.Run(new FrmMain());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,24 @@
|
|||||||
# FrappeMocha
|
# FrappeMocha
|
||||||
|
|
||||||
|
<img src="https://neo-desktop.github.io/FrappeMocha/images/logo.png" height=100 />
|
||||||
|
|
||||||
Generates keys for an aptly named 3270 terminal emulator
|
Generates keys for an aptly named 3270 terminal emulator
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Supported Platforms and Products
|
||||||
|
Product | Windows | MacOSX | Java | Chrome | Android
|
||||||
|
-------- |:-------:|:------:|:----:|:------:|:-------:
|
||||||
|
**TN3270** | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:
|
||||||
|
**TN5250** | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:
|
||||||
|
**Telnet** | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark:
|
||||||
|
**TN3812** | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | ------ | :heavy_check_mark:
|
||||||
|
**Keyboard** | ------ | :heavy_check_mark: | ------ | ------ | ------
|
||||||
|
**VNC** | ------ | ------ | ------ | ------ | :heavy_check_mark:
|
||||||
|
**Barcode** | ------ | ------ | ------ | ------ | :heavy_check_mark:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Note
|
### Note
|
||||||
This is mostly for educational purposes only
|
This is mostly for educational purposes only
|
||||||
Documentation is non-existant
|
Documentation is non-existant
|
||||||
|
|||||||
+153
@@ -0,0 +1,153 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using FrappeMocha.Keygen;
|
||||||
|
using FrappeMocha.Keygen.Platforms;
|
||||||
|
|
||||||
|
namespace FrappeMocha
|
||||||
|
{
|
||||||
|
public partial class FrmMain : Form
|
||||||
|
{
|
||||||
|
private char[] ficus = new char[6];
|
||||||
|
private Dictionary<string, KeygenBase> keygens = new Dictionary<string, KeygenBase>();
|
||||||
|
private string[] platforms = {"Windows", "MacOSX", "Java", "Google Chrome", "Android"};
|
||||||
|
private string[] companyUserName = {"Company Name", "User Name"};
|
||||||
|
|
||||||
|
public FrmMain()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
keygens.Add(platforms[0], new PlatformWindows());
|
||||||
|
keygens.Add(platforms[1], new PlatformMac());
|
||||||
|
keygens.Add(platforms[2], new PlatformJava());
|
||||||
|
keygens.Add(platforms[3], new PlatformJavaScript());
|
||||||
|
keygens.Add(platforms[4], new PlatformAndroid());
|
||||||
|
|
||||||
|
foreach (var item in keygens)
|
||||||
|
{
|
||||||
|
cbxPlatform.Items.Add(item.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
cbxPlatform.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string keygen(KeygenBase platform, KeygenProduct product, int type, string name)
|
||||||
|
{
|
||||||
|
if (name.Length <= 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show( companyUserName[type] + " must be longer than one character", "Error",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.Length > 80)
|
||||||
|
{
|
||||||
|
MessageBox.Show( companyUserName[type] + " must not be greater than eighty characters", "Error",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
string genlicense = platform.Generate(type, name, product.Licence);
|
||||||
|
if (!platform.Check(genlicense, name, product.Licence))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Generated license did not pass self check, please try again", "Warning",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
return genlicense;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void frmMain_Shown(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
AcceptButton.PerformClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void frmMain_KeyPress(object sender, KeyPressEventArgs e)
|
||||||
|
{
|
||||||
|
Array.Copy(ficus, 1, ficus, 0, ficus.Length - 1);
|
||||||
|
this.ficus[ficus.Length - 1] = e.KeyChar;
|
||||||
|
if (new string(ficus) == "spicey")
|
||||||
|
{
|
||||||
|
switch (MessageBox.Show("Would you like a little salt, as a treat?", "Orly?",
|
||||||
|
MessageBoxButtons.YesNoCancel,
|
||||||
|
MessageBoxIcon.Question))
|
||||||
|
{
|
||||||
|
case DialogResult.Yes:
|
||||||
|
Process.Start("https://i.imgur.com/EJ31bmk.jpg");
|
||||||
|
break;
|
||||||
|
case DialogResult.No:
|
||||||
|
Process.Start(
|
||||||
|
"https://pics.me.me/white-people-cant-handle-spicy-food-um-try-again-sweetie-6626438.png");
|
||||||
|
break;
|
||||||
|
case DialogResult.Cancel:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSubmit_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
KeygenBase platform = (KeygenBase)cbxPlatform.SelectedItem;
|
||||||
|
KeygenProduct product = (KeygenProduct)cbxProduct.SelectedItem;
|
||||||
|
int type = cbxLicenseType.SelectedIndex;
|
||||||
|
string name = tbxCompanyUserName.Text;
|
||||||
|
|
||||||
|
tbxLicenseKey.Text = keygen(platform, product, type, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tbxLicenseKey_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
tbxLicenseKey.SelectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cbxPlatform_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
KeygenBase platform = (KeygenBase) cbxPlatform.SelectedItem;
|
||||||
|
|
||||||
|
cbxProduct.Enabled = false;
|
||||||
|
cbxProduct.Items.Clear();
|
||||||
|
foreach (var p in platform.Products)
|
||||||
|
{
|
||||||
|
cbxProduct.Items.Add(p);
|
||||||
|
}
|
||||||
|
cbxProduct.SelectedIndex = 0;
|
||||||
|
cbxProduct.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cbxProduct_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
KeygenBase platform = (KeygenBase)cbxPlatform.SelectedItem;
|
||||||
|
KeygenProduct product = (KeygenProduct) cbxProduct.SelectedItem;
|
||||||
|
|
||||||
|
cbxLicenseType.Enabled = false;
|
||||||
|
cbxLicenseType.Items.Clear();
|
||||||
|
var LicenceTypes = platform.GenerateLicencetypes(product);
|
||||||
|
foreach (string type in LicenceTypes)
|
||||||
|
{
|
||||||
|
cbxLicenseType.Items.Add(type);
|
||||||
|
}
|
||||||
|
cbxLicenseType.Enabled = true;
|
||||||
|
cbxLicenseType.SelectedIndex = 0;
|
||||||
|
AcceptButton.PerformClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cbxLicenseType_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (cbxLicenseType.Items.Count != 2)
|
||||||
|
{
|
||||||
|
lblCompanyUserName.Text = "Name";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lblCompanyUserName.Text = companyUserName[cbxLicenseType.SelectedIndex];
|
||||||
|
}
|
||||||
|
AcceptButton.PerformClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user