using System;
using System.Management;
using System.Security.Cryptography;
using System.Text;
namespace JEBKeyMaker
{
class MachineInfo
{
public static string GetBIOSNumber()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
"Select SerialNumber From Win32_BIOS"
);
string biosNumber = string.Empty;
foreach (ManagementObject mgt
in
searcher.Get())
{
biosNumber += mgt[
"SerialNumber"
].ToString();
}
return
biosNumber;
}
public static long GetMachineId(string biosNumber)
{
MD5 md5Hasher = MD5.Create();
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(biosNumber));
return
BitConverter.ToInt64(data, 0) & long.MaxValue;
}
}
}
using System;
using System.Text;
using System.Security.Cryptography;
namespace JEBKeyMaker
{
public class KeyMaker
{
private const int CONST1 = 从你的jar包中找;
//
通过查找黑名单
"f876add9497b7e2745266f83eebf208b64650fb00e71794892890b42d3e890da"
可以得到 这4个常量,替换这4个常量后就能生成你自己的序列号了
private const int CONST2 = 从你的jar包中找;
private const int CONST3 = 从你的jar包中找;
private const int CONST4 = 从你的jar包中找;
private long machineId;
public KeyMaker(long machineId)
{
this.machineId = machineId;
}
public bool isValidKey(String key, int[] outDate)
{
if
(key != null && key.Length != 0)
{
key = key.Trim();
int
date
= 0;
int index = key.IndexOf(
'Z'
);
if
(index >= 0)
{
String second = key.Substring(index + 1);
if
(second.Length < 2)
{
return
false
;
}
String dataPart = second.Substring(0, second.Length - 1);
String hashPart = second.Substring(second.Length - 1);
int dataVal;
try
{
dataVal = int.Parse(dataPart);
int hashVal = int.Parse(hashPart);
if
(this.dateHash(dataVal) != hashVal)
{
return
false
;
}
}
catch (Exception)
{
return
false
;
}
date
= dataVal ^ 1450416845;
key = key.Substring(0, index);
}
try
{
long keyVal = long.Parse(key);
if
(!this.isValidKey(keyVal))
{
return
false
;
}
}
catch (Exception)
{
return
false
;
}
if
(outDate != null && outDate.Length >= 1)
{
outDate[0] =
date
;
}
return
true
;
}
else
{
return
false
;
}
}
private int dateHash(int dataVal)
{
int
hash
;
for
(
hash
= 0; dataVal > 0; dataVal >>= 4)
{
hash
+= dataVal & 15;
}
return
hash
% 10;
}
private static byte[] sha256Hash(byte[] buffer)
{
SHA256 sha = new SHA256Managed();
return
sha.ComputeHash(buffer);
}
public static String toHexString(byte[] buffer)
{
StringBuilder sb = new StringBuilder();
for
(int i = 0; i < buffer.Length; ++i)
{
sb.Append(String.Format(
"{0:X2}"
, buffer[i]));
}
return
sb.ToString();
}
public String getValidKey(int
date
)
{
int lowId = (int)(this.machineId & -1L);
int hiId = (int)(this.machineId >> 32 & -1L);
int lowVal = lowId + CONST1 + CONST2 & -1;
int hiVal = hiId - CONST3 + CONST4 & int.MaxValue;
long keyVal = (long)(((ulong)hiVal << 32) | (uint)lowVal);
int lowKey = (int)(keyVal & -1L);
int hiKey = (int)(keyVal >> 32 & -1L);
if
(lowVal == lowKey && hiVal == hiKey)
{
String[] blackHashList = new String[] {
"f876add9497b7e2745266f83eebf208b64650fb00e71794892890b42d3e890da"
,
"1020e406024705930a03818381b2379a64929bd068cc96b6e256562c3dc57058"
,
"f876add9497b7e2745266f83eebf208b64650fb00e71794892890b42d3e890da"
,
"cb631c8d21bdc0c7b75e13c423c00a3a5cfe10782921837453ab1993b04410dc"
,
"82bb76b943b8ed15f70992a2830f826637a307c0aace1d1a4e188085169d6e91"
,
"eea85229acd2559ca62f013c81c5f3c2880adc880b8f8e9673eb6926de3d61bb"
,
"a005a5ca6874292a351a4329f1fdaaaf90ea1eda4e002e1179897c7b1f6615c3"
,
"e68104e9daf9509d03be7561a6bbb5afdfe063b595c1423ce2e51ac1dbd345cb"
,
"0df0317ef37bb52d315c12d07011782345bc99a5f9643e21485a36b1b62723a9"
,
"80e6fce9d2df9a1b89317b3bfd9c5b97c8c7a7e90ef3fdf18a7d226994fea927"
};
String keyHash = String.Format(
"{0}:{1}:{2}"
, 778899445566112233L, this.machineId, keyVal);
keyHash = toHexString(sha256Hash(Encoding.Default.GetBytes(keyHash))).ToLower();
int len = blackHashList.Length;
for
(int i = 0; i < len; ++i)
{
String blackHash = blackHashList[i];
if
(keyHash.Equals(blackHash))
{
return
""
;
}
}
int dataVal =
date
^ 1450416845;
int hashVal = dateHash(dataVal);
return
String.Format(
"{0}Z{1}{2}"
, keyVal, dataVal, hashVal);
}
else
{
return
""
;
}
}
private bool isValidKey(long keyVal)
{
int lowId = (int)(this.machineId & -1L);
int hiId = (int)(this.machineId >> 32 & -1L);
int lowKey = (int)(keyVal & -1L);
int hiKey = (int)(keyVal >> 32 & -1L);
int lowVal = lowId + CONST1 + CONST2 & -1;
int hiVal = hiId - CONST3 + CONST4 & int.MaxValue;
if
(lowVal == lowKey && hiVal == hiKey)
{
String[] blackHashList = new String[] {
"f876add9497b7e2745266f83eebf208b64650fb00e71794892890b42d3e890da"
,
"1020e406024705930a03818381b2379a64929bd068cc96b6e256562c3dc57058"
,
"f876add9497b7e2745266f83eebf208b64650fb00e71794892890b42d3e890da"
,
"cb631c8d21bdc0c7b75e13c423c00a3a5cfe10782921837453ab1993b04410dc"
,
"82bb76b943b8ed15f70992a2830f826637a307c0aace1d1a4e188085169d6e91"
,
"eea85229acd2559ca62f013c81c5f3c2880adc880b8f8e9673eb6926de3d61bb"
,
"a005a5ca6874292a351a4329f1fdaaaf90ea1eda4e002e1179897c7b1f6615c3"
,
"e68104e9daf9509d03be7561a6bbb5afdfe063b595c1423ce2e51ac1dbd345cb"
,
"0df0317ef37bb52d315c12d07011782345bc99a5f9643e21485a36b1b62723a9"
,
"80e6fce9d2df9a1b89317b3bfd9c5b97c8c7a7e90ef3fdf18a7d226994fea927"
};
String keyHash = String.Format(
"{0}:{1}:{2}"
, 778899445566112233L, this.machineId, keyVal);
keyHash = toHexString(sha256Hash(Encoding.Default.GetBytes(keyHash))).ToLower();
int len = blackHashList.Length;
for
(int i = 0; i < len; ++i)
{
String blackHash = blackHashList[i];
if
(keyHash.Equals(blackHash))
{
return
false
;
}
}
return
true
;
}
else
{
return
false
;
}
}
}
}
using System;
using System.Text;
namespace JEBKeyMaker
{
class Program
{
static void Main(string[] args)
{
string biosNumber = MachineInfo.GetBIOSNumber();
long machineId = MachineInfo.GetMachineId(biosNumber);
DateTime utcBegin = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
DateTime utcEnd = DateTime.Now.AddYears(3).AddDays(-13).ToUniversalTime();
TimeSpan ts = utcEnd.Subtract(utcBegin);
int dt = (int)(ts.TotalMilliseconds / 1000);
KeyMaker va = new KeyMaker(machineId);
string key = va.getValidKey(dt);
}
}
}