编程语言
首页 > 编程语言> > [C#] 代码混淆和加壳

[C#] 代码混淆和加壳

作者:互联网

目的

对比不同的主流保护工具,针对 dnSpy 反编译出的效果。

非混淆代码:

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace test_winform
{
	// Token: 0x02000002 RID: 2
	public class Form1 : Form
	{
		// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
		public Form1()
		{
			this.InitializeComponent();
		}

		// Token: 0x06000002 RID: 2 RVA: 0x0000207A File Offset: 0x0000027A
		private void button1_Click(object sender, EventArgs e)
		{
			MessageBox.Show("123");
		}

		// Token: 0x06000003 RID: 3 RVA: 0x00002088 File Offset: 0x00000288
		protected override void Dispose(bool disposing)
		{
			bool flag = disposing && this.components != null;
			if (flag)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}

		// Token: 0x06000004 RID: 4 RVA: 0x000020C0 File Offset: 0x000002C0
		private void InitializeComponent()
		{
			this.button1 = new Button();
			base.SuspendLayout();
			this.button1.Location = new Point(394, 156);
			this.button1.Name = "button1";
			this.button1.Size = new Size(75, 23);
			this.button1.TabIndex = 0;
			this.button1.Text = "button1";
			this.button1.UseVisualStyleBackColor = true;
			this.button1.Click += this.button1_Click;
			base.AutoScaleDimensions = new SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(800, 450);
			base.Controls.Add(this.button1);
			base.Name = "Form1";
			this.Text = "Form1";
			base.ResumeLayout(false);
		}

		// Token: 0x04000001 RID: 1
		private int a = 1;

		// Token: 0x04000002 RID: 2
		private string b = "asd";

		// Token: 0x04000003 RID: 3
		private IContainer components = null;

		// Token: 0x04000004 RID: 4
		private Button button1;
	}
}

eazfuscator 混淆

下载安装,网上有基于 2018 的破解版,需要最新功能就购买正版。安装后如果提示这个错误:

Unable to find tool "ildasm.exe". Ensure .NET Framework SDK is installed.

就用 everything 搜一下这个文件,然后放在 eazfuscator 的根目录即可:
在这里插入图片描述

混淆效果

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

// Token: 0x02000018 RID: 24
public sealed class \u0008\u2000 : Form
{
	// Token: 0x0600003D RID: 61 RVA: 0x0000313C File Offset: 0x0000133C
	public \u0008\u2000()
	{
		this.\u0002();
	}

	// Token: 0x0600003E RID: 62 RVA: 0x00003168 File Offset: 0x00001368
	private void \u0002(object \u0002, EventArgs \u0003)
	{
		MessageBox.Show(\u000F\u2000.\u0002(1645278435));
	}

	// Token: 0x0600003F RID: 63 RVA: 0x0000317C File Offset: 0x0000137C
	protected override void Dispose(bool \u0002)
	{
		bool flag = \u0002 && this.\u0005 != null;
		if (flag)
		{
			this.\u0005.Dispose();
		}
		base.Dispose(\u0002);
	}

	// Token: 0x06000040 RID: 64 RVA: 0x000031B0 File Offset: 0x000013B0
	private void \u0002()
	{
		this.\u0008 = new Button();
		base.SuspendLayout();
		this.\u0008.Location = new Point(394, 156);
		this.\u0008.Name = \u000F\u2000.\u0002(1645278441);
		this.\u0008.Size = new Size(75, 23);
		this.\u0008.TabIndex = 0;
		this.\u0008.Text = \u000F\u2000.\u0002(1645278441);
		this.\u0008.UseVisualStyleBackColor = true;
		this.\u0008.Click += this.\u0002;
		base.AutoScaleDimensions = new SizeF(6f, 12f);
		base.AutoScaleMode = AutoScaleMode.Font;
		base.ClientSize = new Size(800, 450);
		base.Controls.Add(this.\u0008);
		base.Name = \u000F\u2000.\u0002(1645278235);
		this.Text = \u000F\u2000.\u0002(1645278235);
		base.ResumeLayout(false);
	}

	// Token: 0x0400000C RID: 12
	private int \u0002 = 1;

	// Token: 0x0400000D RID: 13
	private string \u0003 = \u000F\u2000.\u0002(1645278461);

	// Token: 0x0400000E RID: 14
	private IContainer \u0005 = null;

	// Token: 0x0400000F RID: 15
	private Button \u0008;
}


标签:混淆,u0002,C#,u0008,button1,加壳,Token,base,RID
来源: https://blog.csdn.net/Simon798/article/details/117261332