C# dll反混淆,反编译
2015-09-29 13:35
519 查看
C#的源代码通过编译,会变成中间语言,dll程序集。如果我们想看源代码,需要反编译。有些代码经过了混淆,就需要反混淆。
我们先通过反编译软件Reflector,把dll中的代码反编译下。这里只要打开reflector,然后引入这个dll就行。
经过混淆的代码,如下
public static BaseSqlGenerator GetSqlGenerator(ModelConfigOptions cfgOptions, string[] properties)
{
BaseSqlGenerator generator = null;
if ((cfgOptions & ModelConfigOptions.CreateSqlByXmlCfg) == ModelConfigOptions.None)
{
Label_005A:
if (_AutoSqlCreate == null)
{
_AutoSqlCreate = new AutoMappingSqlGenerator();
if (4 == 0)
{
if (0 == 0)
{
}
goto Label_002B;
}
if (3 != 0)
{
goto Label_0061;
}
if (2 != 0)
{
goto Label_005A;
}
}
else
{
goto Label_0061;
}
}
if (_XmlSqlConfigObject == null)
{
_XmlSqlConfigObject = new XmlConfigSqlGenerator();
}
generator = _XmlSqlConfigObject;
if (2 == 0)
{
return generator;
}
goto Label_004B;
Label_002B:
if (_AutoSqlCreate == null)
{
_AutoSqlCreate = new AutoMappingSqlGenerator();
}
Label_0032:
return _AutoSqlCreate;
Label_004B:
if (properties == null)
{
return generator;
}
if (8 == 0)
{
goto Label_0032;
}
if (((3 == 0) && (0 == 0)) && ((0 == 0) && (-1 != 0)))
{
if (0 == 0)
{
return generator;
}
goto Label_0032;
}
if (properties.Length <= 0)
{
return generator;
}
goto Label_002B;
Label_0061:
generator = _AutoSqlCreate;
goto Label_004B;
}
让人实在是费解。一般,通过反混淆,可以得到清楚的代码。我们通过de4dot工具反混淆下,
反混淆步骤如下:
通过cmd命令: F:\我的文件\安装文件\de4dot-2.0.3\de4dot-2.0.3>de4dot.exe
C:\Users\hq01ub721\Des
ktop\MB.ORM.dll
就会在同一级目录下生成一个叫...clean的程序集。然后再通过reflector工具打开着个dll。
下面是对dll反混淆后的代码
public static BaseSqlGenerator GetSqlGenerator(ModelConfigOptions cfgOptions, string[] properties)
{
BaseSqlGenerator generator = null;
if ((cfgOptions & ModelConfigOptions.CreateSqlByXmlCfg) != ModelConfigOptions.None)
{
if (_XmlSqlConfigObject == null)
{
_XmlSqlConfigObject = new XmlConfigSqlGenerator();
}
generator = _XmlSqlConfigObject;
}
else
{
if (_AutoSqlCreate == null)
{
_AutoSqlCreate = new AutoMappingSqlGenerator();
}
generator = _AutoSqlCreate;
}
if ((properties == null) || (properties.Length <= 0))
{
return generator;
}
if (_AutoSqlCreate == null)
{
_AutoSqlCreate = new AutoMappingSqlGenerator();
}
return _AutoSqlCreate;
}
这样就清楚多了。这代码会跟源码有点点区别,因为编译过程中,编译器帮你优化了一些语句,但是逻辑是不会改变的。
我们先通过反编译软件Reflector,把dll中的代码反编译下。这里只要打开reflector,然后引入这个dll就行。
经过混淆的代码,如下
public static BaseSqlGenerator GetSqlGenerator(ModelConfigOptions cfgOptions, string[] properties)
{
BaseSqlGenerator generator = null;
if ((cfgOptions & ModelConfigOptions.CreateSqlByXmlCfg) == ModelConfigOptions.None)
{
Label_005A:
if (_AutoSqlCreate == null)
{
_AutoSqlCreate = new AutoMappingSqlGenerator();
if (4 == 0)
{
if (0 == 0)
{
}
goto Label_002B;
}
if (3 != 0)
{
goto Label_0061;
}
if (2 != 0)
{
goto Label_005A;
}
}
else
{
goto Label_0061;
}
}
if (_XmlSqlConfigObject == null)
{
_XmlSqlConfigObject = new XmlConfigSqlGenerator();
}
generator = _XmlSqlConfigObject;
if (2 == 0)
{
return generator;
}
goto Label_004B;
Label_002B:
if (_AutoSqlCreate == null)
{
_AutoSqlCreate = new AutoMappingSqlGenerator();
}
Label_0032:
return _AutoSqlCreate;
Label_004B:
if (properties == null)
{
return generator;
}
if (8 == 0)
{
goto Label_0032;
}
if (((3 == 0) && (0 == 0)) && ((0 == 0) && (-1 != 0)))
{
if (0 == 0)
{
return generator;
}
goto Label_0032;
}
if (properties.Length <= 0)
{
return generator;
}
goto Label_002B;
Label_0061:
generator = _AutoSqlCreate;
goto Label_004B;
}
让人实在是费解。一般,通过反混淆,可以得到清楚的代码。我们通过de4dot工具反混淆下,
反混淆步骤如下:
通过cmd命令: F:\我的文件\安装文件\de4dot-2.0.3\de4dot-2.0.3>de4dot.exe
C:\Users\hq01ub721\Des
ktop\MB.ORM.dll
就会在同一级目录下生成一个叫...clean的程序集。然后再通过reflector工具打开着个dll。
下面是对dll反混淆后的代码
public static BaseSqlGenerator GetSqlGenerator(ModelConfigOptions cfgOptions, string[] properties)
{
BaseSqlGenerator generator = null;
if ((cfgOptions & ModelConfigOptions.CreateSqlByXmlCfg) != ModelConfigOptions.None)
{
if (_XmlSqlConfigObject == null)
{
_XmlSqlConfigObject = new XmlConfigSqlGenerator();
}
generator = _XmlSqlConfigObject;
}
else
{
if (_AutoSqlCreate == null)
{
_AutoSqlCreate = new AutoMappingSqlGenerator();
}
generator = _AutoSqlCreate;
}
if ((properties == null) || (properties.Length <= 0))
{
return generator;
}
if (_AutoSqlCreate == null)
{
_AutoSqlCreate = new AutoMappingSqlGenerator();
}
return _AutoSqlCreate;
}
这样就清楚多了。这代码会跟源码有点点区别,因为编译过程中,编译器帮你优化了一些语句,但是逻辑是不会改变的。
相关文章推荐
- c#调用COM组件
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- C#实现把指定数据写入串口
- C#动态创建button的方法
- C#中抽象方法与虚拟方法的区别
- c#中虚函数的相关使用方法
- C#使用加边法计算行列式的值
- C#实现多线程的同步方法实例分析
- C#中尾递归的使用、优化及编译器优化
- C#实现子窗体与父窗体通信方法实例总结
- C#通用邮件发送类分享
- C#中this的用法集锦
- C#.NET获取拨号连接的宽带连接方法
- C#异步绑定数据实现方法
- C#实现AddRange为数组添加多个元素的方法
- C#中Equality和Identity浅析
- C#生成饼形图及添加文字说明实例代码
- C#判等对象是否相等的方法汇总
- C#简单的向量用法实例教程
- C#实现基于链表的内存记事本实例