Licensing
serverName 和 ip
分别是.GetServerVariable("SERVER_NAME").ToLower(), control.GetServerVariable("LOCAL_ADDR"),
这个为真的的话就暴破完成
protected bool CheckLicenseKeys(out string errorMessage)
{
errorMessage = new Licensing(this).CheckLicenseKeys();
return (string.Empty == errorMessage);
}
关键的注册算法
private Licensing.ValidationResult ValidateLicense(string companyName, string encodedLicense, string serverName, string serverIP)
{
string text1;
DateTime time1;
try
{
text1 = this.DecryptLicense(Convert.FromBase64String(encodedLicense));
}
catch (FormatException)
{
return Licensing.ValidationResult.LicenseInvalid;
}
string[] textArray1 = text1.Split(new char[] { Convert.ToChar(1) });
if ((((textArray1.Length < 5) || (textArray1[4] != "v2")) || (textArray1[1] != companyName)) || ((!this._isLocalhost && !serverName.EndsWith("." + this.LicensedServer(textArray1))) && (((serverName != this.LicensedServer(textArray1)) && (serverName != textArray1[0])) && !this.MatchesLicenseIP(textArray1, serverIP))))
{
return Licensing.ValidationResult.LicenseInvalid;
}
try
{
time1 = DateTime.ParseExact(textArray1[2], "d", new CultureInfo("en-US", true));
}
catch (FormatException)
{
if (textArray1[2] == "forever")
{
return Licensing.ValidationResult.LicenseOk;
}
return Licensing.ValidationResult.LicenseInvalid;
}
TimeSpan span1 = (TimeSpan) (time1 - DateTime.Now);
if (span1.Days > 0)
{
return Licensing.ValidationResult.LicenseOk;
}
return Licensing.ValidationResult.LicenseExpired;
}
private string DecryptLicense(byte[] licenseKey)
{
string text1 = string.Empty;
RijndaelManaged managed1 = new RijndaelManaged();
managed1.Mode = CipherMode.CBC;
MemoryStream stream1 = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream1, managed1.CreateDecryptor(ControlHelper.Key, ControlHelper.Vector), CryptoStreamMode.Write);
stream2.Write(licenseKey, 0, licenseKey.Length);
try
{
stream2.Close();
stream1.Close(); // 不知道反编译的时候为什么会有这个问题
return Encoding.ASCII.GetString(stream1.ToArray());
}
catch (Exception)
{
stream2 = null;
return "";
}
}
把第三个字符变小写
private string LicensedServer(string[] licenseParts)
{
return licenseParts[3].ToLower();
}
private bool MatchesLicenseIP(string[] licenseParts, string serverIP)
{
if ((licenseParts.Length >= 6) && (licenseParts[5] == "s1"))
{
return (this.LicensedIP(licenseParts) == serverIP);
}
return false;
}
private string LicensedIP(string[] licenseParts)
{
return licenseParts[3];
}
if ((((textArray1.Length < 5) || (textArray1[4] != "v2")) || (textArray1[1] != companyName)) || ((!this._isLocalhost && !serverName.EndsWith("." + this.LicensedServer(textArray1))) && (((serverName != this.LicensedServer(textArray1)) && (serverName != textArray1[0])) && !this.MatchesLicenseIP(textArray1, serverIP))))
{
return Licensing.ValidationResult.LicenseInvalid;
}
radcontrol与这个来分隔
((textArray1.Length < 5) || (textArray1[4] != "v2"))
长度必面是大于五 第四为V2
(textArray1[1] != companyName))
第一个数组必须为 companyName
((!this._isLocalhost && !serverName.EndsWith("." + this.LicensedServer(textArray1))) && (((serverName != this.LicensedServer(textArray1)) && (serverName != textArray1[0])) && !this.MatchesLicenseIP(textArray1, serverIP)))
(!this._isLocalhost && !serverName.EndsWith("." + this.LicensedServer(textArray1)))
isLocalhost 应该是判断是否为本机 如果是本机等到的为假
判断 serverName 是否为 第三个数组 当服务器判断正解也为假
得出如果是本机的话 到这边就可以结束了 如果是服务器还会为真
如果是服务器则继续看下去
(((serverName != this.LicensedServer(textArray1)) && (serverName != textArray1[0])) && !this.MatchesLicenseIP(textArray1, serverIP))
((serverName != this.LicensedServer(textArray1)) && (serverName != textArray1[0]))
数组的第三个为 ip 或者服务器的名字都可以
第二个数组为textArray1[2] == "forever"
表示永远不会过期
第一个为companyname第二个为时间第三个为服务器名和IP地址 数组要大于6个
不时道哪边地方出现了错误..自己写的注册机并没有成功,,有空的时候再继续了