本帖最后由 vipcrack 于 2020-9-30 19:29 编辑
反编译软件,看注册码判断的地方:
[C#] 纯文本查看 复制代码 private void BtnRegister_Click(object sender, EventArgs e)
{
try
{
string register = TbRegisterCode.Text.Trim();
string code = TbMachineCode.Text.Trim();
string machine = DES.GetMachine(register);
if (machine.Equals(code))
{
dal.Register(register);
base.DialogResult = DialogResult.OK;
Close();
return;
}
throw new Exception("Registration key mismatch");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Tips");
}
}
machine.Equals(code),是说你输入的注册信息,DES.GetMachine(register)用这个函数解密后,必须等于机器码。
那么去看这个函数
[C#] 纯文本查看 复制代码 public static string GetMachine(string pToDecrypt)
{
if (string.IsNullOrWhiteSpace(pToDecrypt))
{
return string.Empty;
}
string str = Decrypt(pToDecrypt, key);//这里用des的key来对输入的注册码解码
return str.Substring(0, str.Length - 3);//解码后的数据,去掉后3位
}
也就是说解密输入的注册码后的内容,去掉后3位必须等于机器码。
那么我们把机器码和后3位加密回去就是注册码,加密需要用到函数
[C#] 纯文本查看 复制代码 public static string Encrypt(string pToEncrypt, string sKey)
{
try
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.Default.GetBytes(pToEncrypt);
des.Key = Encoding.ASCII.GetBytes(sKey);
des.IV = Encoding.ASCII.GetBytes(sKey);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
StringBuilder ret = new StringBuilder();
byte[] array = ms.ToArray();
foreach (byte b in array)
{
ret.AppendFormat("{0:X2}", b);
}
ret.ToString();
return ret.ToString();
}
catch (Exception)
{
return "";
}
}
这两个函数都是DES这个类中,直接复制代码出来,然后做注册机就行。
这里的后三位可以从代码里看到是啥?:
[C#] 纯文本查看 复制代码 public static int GetNum(string pToDecrypt)
{
if (string.IsNullOrWhiteSpace(pToDecrypt))
{
return 0;
}
string str = Decrypt(pToDecrypt, key);
string num = str.Substring(str.Length - 3);
return Convert.ToInt32(num);
}
这里可以看到是注册界面的key后面的数据,不知道干啥的,我没SQL环境。
[C#] 纯文本查看 复制代码 private void InitialLoad()
{
try
{
LblSoftwareVerNO.Text = "3.20.0003";
chkBase64.Checked = (GetConfigValue("UseBase64", pathConfig) == "1");
string uuid = ComputerHelper.GetUniqueIdentification();
TbMachineCode.Text = uuid;
string key = DecryptKeyDAL.GetKey();
lblKeyNum.Text = DES.GetNum(key).ToString();
TbRegisterCode.Text = (DES.GetMachine(key).Equals(uuid) ? DecryptKeyDAL.GetKey() : string.Empty);
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Error");
}
}
知道了这些,就把DES里用到的Encrypt函数,keys,key常量复制出来,然后用C#弄个界面,写成注册机就行了,代码就是前面我回复的代码。
[C#] 纯文本查看 复制代码 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
namespace keygen
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private static byte[] Keys = new byte[8]
{
52,
17,
6,
239,
154,
52,
17,
16
};
private static string key = "bxu+ss@q";
public static string Encrypt(string pToEncrypt, string sKey)
{
try
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.Default.GetBytes(pToEncrypt);
des.Key = Encoding.ASCII.GetBytes(sKey);
des.IV = Encoding.ASCII.GetBytes(sKey);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
StringBuilder ret = new StringBuilder();
byte[] array = ms.ToArray();
foreach (byte b in array)
{
ret.AppendFormat("{0:X2}", b);
}
ret.ToString();
return ret.ToString();
}
catch (Exception)
{
return "";
}
}
private void button1_Click(object sender, EventArgs e)
{
string str = Encrypt(textBox1.Text+"999", key);
textBox2.Text = str;
}
}
}
界面上放两个TextBox一个Button就行了,Button代码用上面的。
|