首页
社区
课程
招聘
C#有这些代码改如何编写注册机
发表于: 2009-5-1 02:11 7541

C#有这些代码改如何编写注册机

2009-5-1 02:11
7541
附带程序  www.809108233.com/www.rar

public class FrmRegister : Form
{
    // Fields
    private Button btnGenerate;
    private Button btnOK;
    private IContainer components;
    private Label label1;
    private Label label2;
    private string RegisterCode;
    private static string rootpath;
    private TextBox txtCode;
    private TextBox txtSN;

    // Methods
    static FrmRegister();
    public FrmRegister();
    private void btnGenerate_Click(object sender, EventArgs e);
    private void btnOK_Click(object sender, EventArgs e);
    public static bool CheckRegisterCode(string code);
    protected override void Dispose(bool disposing);
    private void FrmRegister_Load(object sender, EventArgs e);
    private void InitializeComponent();
    public static string ShowFrmRegister();
    public static string ShowFrmRegisterMachine();
}

Expand Methods

求教C#   反编印以后
private void btnOK_Click(object sender, EventArgs e)
{
    try
    {
        if (this.txtSN.get_Text() != RegisterMachine.EncryptCode(RegisterMachine.DecryptCode(this.txtCode.get_Text().Trim(), RegisterMachine.KEY_SECOND), RegisterMachine.KEY_FIRST))
        {
            this.RegisterCode = "";
            MessageBox.Show("注册码不正确!");
        }
        else
        {
            this.RegisterCode = this.txtCode.get_Text().Trim();
            if (CheckRegisterCode(this.RegisterCode))
            {
                base.Close();
            }
        }
    }
    catch (Exception)
    {
        this.RegisterCode = "";
        MessageBox.Show("注册码错误!");
    }
}

private void btnGenerate_Click(object sender, EventArgs e)
{
    try
    {
        this.RegisterCode = RegisterMachine.EncryptCode(RegisterMachine.DecryptCode(this.txtSN.get_Text().Trim(), RegisterMachine.KEY_FIRST), RegisterMachine.KEY_SECOND);
    }
    catch (Exception)
    {
        this.RegisterCode = "";
        MessageBox.Show("生成注册码失败,请检查!");
    }
    this.txtCode.set_Text(this.RegisterCode);
}

下这些代码应该是登陆截面
private void InitializeComponent()
{
    this.label1 = new Label();
    this.label2 = new Label();
    this.btnOK = new Button();
    this.btnGenerate = new Button();
    this.txtCode = new TextBox();
    this.txtSN = new TextBox();
    base.SuspendLayout();
    this.label1.set_AutoSize(true);
    this.label1.set_Location(new Point(12, 9));
    this.label1.set_Name("label1");
    this.label1.set_Size(new Size(0x17, 12));
    this.label1.set_TabIndex(0);
    this.label1.set_Text("S/N");
    this.label2.set_AutoSize(true);
    this.label2.set_Location(new Point(12, 0x24));
    this.label2.set_Name("label2");
    this.label2.set_Size(new Size(0x1d, 12));
    this.label2.set_TabIndex(2);
    this.label2.set_Text("Code");
    this.btnOK.set_Location(new Point(160, 70));
    this.btnOK.set_Name("btnOK");
    this.btnOK.set_Size(new Size(0x4b, 0x17));
    this.btnOK.set_TabIndex(4);
    this.btnOK.set_Text("确定");
    this.btnOK.set_UseVisualStyleBackColor(true);
    this.btnOK.add_Click(new EventHandler(this, this.btnOK_Click));
    this.btnGenerate.set_Location(new Point(0x45, 0x45));
    this.btnGenerate.set_Name("btnGenerate");
    this.btnGenerate.set_Size(new Size(0x4b, 0x17));
    this.btnGenerate.set_TabIndex(5);
    this.btnGenerate.set_Text("生成");
    this.btnGenerate.set_UseVisualStyleBackColor(true);
    this.btnGenerate.add_Click(new EventHandler(this, this.btnGenerate_Click));
    this.txtCode.set_Location(new Point(0x3b, 0x21));
    this.txtCode.set_MaxLength(8);
    this.txtCode.set_Name("txtCode");
    this.txtCode.set_Size(new Size(0xb0, 0x15));
    this.txtCode.set_TabIndex(7);
    this.txtSN.set_Location(new Point(0x3b, 6));
    this.txtSN.set_MaxLength(8);
    this.txtSN.set_Name("txtSN");
    this.txtSN.set_Size(new Size(0xb0, 0x15));
    this.txtSN.set_TabIndex(8);
    base.set_AutoScaleDimensions(new SizeF(6f, 12f));
    base.set_AutoScaleMode(1);
    base.set_ClientSize(new Size(0xfd, 0x6a));
    base.get_Controls().Add(this.txtSN);
    base.get_Controls().Add(this.txtCode);
    base.get_Controls().Add(this.btnGenerate);
    base.get_Controls().Add(this.btnOK);
    base.get_Controls().Add(this.label2);
    base.get_Controls().Add(this.label1);
    base.set_Name("FrmRegister");
    base.set_StartPosition(4);
    this.set_Text("请输入注册码");
    base.add_Load(new EventHandler(this, this.FrmRegister_Load));
    base.ResumeLayout(false);
    base.PerformLayout();
}

这个代表什么
static RegisterMachine()
{
    KEY_FIRST = "82225788";
    KEY_SECOND = "ABCDEFAB";
}

下面是不是注册算法

public static string ConverseString(string src)
{
    string str = "";
    string str2 = src;
    for (int i = 0; i < str2.get_Length(); i++)
    {
        str = str2.get_Chars(i) + str;
    }
    return str;
}

public static string DecryptCode(string strSNCode, string strKey)
{
    if (strSNCode.get_Length() != strKey.get_Length())
    {
        throw new ArgumentException("参数字符串长度不相等,导致无法解出密钥!");
    }
    return EncryptCode(ConverseString(strSNCode), strKey);
}

public static string EncryptCode(string strSN, string strKey)
{
    if (strSN.get_Length() != strKey.get_Length())
    {
        throw new ArgumentException("参数字符串长度不相等,导致无法生成密钥!");
    }
    string src = "";
    for (int i = 0; i < strSN.get_Length(); i++)
    {
        src = src + ((Convert.ToByte(strSN.get_Chars(i).ToString(), 0x10) ^ Convert.ToByte(strKey.get_Chars(i).ToString(), 0x10))).ToString("X");
    }
    return ConverseString(src);
}

[DllImport("kernel32.dll")]
public static extern int GetLastError();

应该是这个吧public static string GetSysDriveSN(string lpRootPathName)
{
    string lpVolumeNameBuffer = null;
    uint nVolumeNameSize = 0xff;
    uint lpVolumeSerialNumber = 0;
    uint lpMaximumComponentLength = 0xff;
    uint lpFileSystemFlags = 0;
    string lpFileSystemNameBuffer = null;
    uint nFileSystemNameSize = 0xff;
    if (GetVolumeInformation(lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize, ref lpVolumeSerialNumber, ref lpMaximumComponentLength, ref lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize))
    {
        return string.Format("{0:X8}", lpVolumeSerialNumber);
    }
    GetLastError();
    return "";
}

[课程]FART 脱壳王!加量不加价!FART作者讲授!

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 7906
活跃值: (3086)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
朋友说幸好没加密,又跟朋友学了点东西
上传的附件:
  • 1.jpg (80.44kb,72次下载)
2009-5-5 11:17
0
雪    币: 23
活跃值: (20)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
什么修改他的字符串呢
2009-5-6 13:26
0
游客
登录 | 注册 方可回帖
返回
//