欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

测试开源.net 混淆器ConfuserEx

程序员文章站 2022-06-10 16:10:14
由于公司业务需要简单的把代码加密混淆,于是了解了一下相关的工具然后打算用ConfuserEx试试。 开源地址:https://github.com/yck1509/ConfuserEx/ 下载地址:https://github.com/yck1509/ConfuserEx/releases 开始工作 ......

由于公司业务需要简单的把代码加密混淆,于是了解了一下相关的工具然后打算用confuserex试试。

开源地址:https://github.com/yck1509/confuserex/

下载地址:https://github.com/yck1509/confuserex/releases

开始工作

1.简单编写一个产生随机数的winform窗口程序

测试开源.net 混淆器ConfuserEx

 

 

 代码如下

using system;
using system.windows.forms;

namespace confuserex_test
{
    public partial class form1 : form
    {
        public form1()
        {
            initializecomponent();
        }

        private void button1_click(object sender, eventargs e)
        {
            var max = (double)numericupdown1.value;
            var min = (double)numericupdown2.value;
            random random = new random();
            double v = random.nextdouble() * (max -min) + min;
            label1.text = v.tostring();
            textbox1.appendtext(v.tostring() + "\r\n");

        }
    }
}
namespace confuserex_test
{
    partial class form1
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private system.componentmodel.icontainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.dispose();
            }
            base.dispose(disposing);
        }

        #region windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要修改
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void initializecomponent()
        {
            this.button1 = new system.windows.forms.button();
            this.label1 = new system.windows.forms.label();
            this.textbox1 = new system.windows.forms.textbox();
            this.numericupdown1 = new system.windows.forms.numericupdown();
            this.label2 = new system.windows.forms.label();
            this.label3 = new system.windows.forms.label();
            this.numericupdown2 = new system.windows.forms.numericupdown();
            ((system.componentmodel.isupportinitialize)(this.numericupdown1)).begininit();
            ((system.componentmodel.isupportinitialize)(this.numericupdown2)).begininit();
            this.suspendlayout();
            // 
            // button1
            // 
            this.button1.location = new system.drawing.point(225, 140);
            this.button1.name = "button1";
            this.button1.size = new system.drawing.size(213, 53);
            this.button1.tabindex = 0;
            this.button1.text = "生成随机数";
            this.button1.usevisualstylebackcolor = true;
            this.button1.click += new system.eventhandler(this.button1_click);
            // 
            // label1
            // 
            this.label1.autosize = true;
            this.label1.location = new system.drawing.point(12, 9);
            this.label1.name = "label1";
            this.label1.size = new system.drawing.size(35, 13);
            this.label1.tabindex = 1;
            this.label1.text = "label1";
            // 
            // textbox1
            // 
            this.textbox1.location = new system.drawing.point(12, 36);
            this.textbox1.multiline = true;
            this.textbox1.name = "textbox1";
            this.textbox1.scrollbars = system.windows.forms.scrollbars.both;
            this.textbox1.size = new system.drawing.size(207, 157);
            this.textbox1.tabindex = 2;
            // 
            // numericupdown1
            // 
            this.numericupdown1.location = new system.drawing.point(298, 68);
            this.numericupdown1.maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
            this.numericupdown1.minimum = new decimal(new int[] {
            100000,
            0,
            0,
            -2147483648});
            this.numericupdown1.name = "numericupdown1";
            this.numericupdown1.size = new system.drawing.size(84, 20);
            this.numericupdown1.tabindex = 3;
            this.numericupdown1.value = new decimal(new int[] {
            100,
            0,
            0,
            0});
            // 
            // label2
            // 
            this.label2.autosize = true;
            this.label2.location = new system.drawing.point(247, 70);
            this.label2.name = "label2";
            this.label2.size = new system.drawing.size(43, 13);
            this.label2.tabindex = 5;
            this.label2.text = "最大值";
            // 
            // label3
            // 
            this.label3.autosize = true;
            this.label3.location = new system.drawing.point(247, 96);
            this.label3.name = "label3";
            this.label3.size = new system.drawing.size(43, 13);
            this.label3.tabindex = 6;
            this.label3.text = "最小值";
            // 
            // numericupdown2
            // 
            this.numericupdown2.location = new system.drawing.point(298, 94);
            this.numericupdown2.maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
            this.numericupdown2.minimum = new decimal(new int[] {
            100000,
            0,
            0,
            -2147483648});
            this.numericupdown2.name = "numericupdown2";
            this.numericupdown2.size = new system.drawing.size(84, 20);
            this.numericupdown2.tabindex = 7;
            this.numericupdown2.value = new decimal(new int[] {
            100,
            0,
            0,
            -2147483648});
            // 
            // form1
            // 
            this.autoscaledimensions = new system.drawing.sizef(6f, 13f);
            this.autoscalemode = system.windows.forms.autoscalemode.font;
            this.clientsize = new system.drawing.size(444, 205);
            this.controls.add(this.numericupdown2);
            this.controls.add(this.label3);
            this.controls.add(this.label2);
            this.controls.add(this.numericupdown1);
            this.controls.add(this.textbox1);
            this.controls.add(this.label1);
            this.controls.add(this.button1);
            this.name = "form1";
            this.text = "confuserex加密混淆测试";
            ((system.componentmodel.isupportinitialize)(this.numericupdown1)).endinit();
            ((system.componentmodel.isupportinitialize)(this.numericupdown2)).endinit();
            this.resumelayout(false);
            this.performlayout();

        }

        #endregion

        private system.windows.forms.button button1;
        private system.windows.forms.label label1;
        private system.windows.forms.textbox textbox1;
        private system.windows.forms.numericupdown numericupdown1;
        private system.windows.forms.label label2;
        private system.windows.forms.label label3;
        private system.windows.forms.numericupdown numericupdown2;
    }
}

其功能如图:

测试开源.net 混淆器ConfuserEx

 

 

 2.下载打开confuserex使用

2.1 将生成的exe文件拖拽到confuserex的project中

测试开源.net 混淆器ConfuserEx

 

 

 2.2在settings中选中packer(据说dll文件不是这样的),再点击exe文件,添加一个true。

测试开源.net 混淆器ConfuserEx

 

 

 2.3点击protect!看到finished at xx:xx, xx:xx elapsed.表示完成

测试开源.net 混淆器ConfuserEx

 

 

 3.测试加密混淆结果

3.1下载ilspy--(百度百科:ilspy是一个开源的.net反编译软件,使用十分方便。)

3.2将保护前编译出的exe文件拖拉到ilspy中

测试开源.net 混淆器ConfuserEx

很方便就能够看到源码

测试开源.net 混淆器ConfuserEx

 

3.2 将保护后的exe文件拖拉到ilspy中与之前的做对比

 测试开源.net 混淆器ConfuserEx

 

4.结论

简单的测试了一下,这种保护便于操作,有明显的保护效果,能够防止只会下载反编译软件来获得源码的人,但是可能不是所有反编译软件都能防止。只是做个简单保护。

后面我会做一个reflector反编译实验以及脱壳后再来反编译。

附加1

reflector反编译实验结果,保护后的直接打不开

测试开源.net 混淆器ConfuserEx