您的位置:首页 > 其它

分析优秀的.NET 文档设计工具Vsdocman 7.1 软件保护技术

2015-07-14 08:27 267 查看
Vsdocman是一个优秀的.NET源代码注释编写工具,方便的以GUI的方式设计.NET源代码的注释。

我们知道.NET源代码的注释是Xml格式的注释,在生成程序集时,只需用选中生成Xml注释,Visual Studio根据源代码生成Xml注释文件。把程序集和相应的Xml文件拷贝到其它电脑中,在Visual Studio中编辑引用类型时,Visual Studio智能提示会提取Xml注释中的内容以方便编程开发。





.NET Xml注释的强大功能不在此多讲,我们来看一下Vsdocman提供了哪些功能令我很满意:

1 在源代码中增加,编辑和生成注释。

2 借助于所见即所得的注释编辑器(WYSIWYG comment editor)帮助编写注释。

3 很容易的直接在源代码中插入表格,列表,图片,联接,类图数据项。

4 生成专业的文档,支持多种格式和多个国家语言输出。输出格式有HTML, CHM, Docx, MS Help Viewer (help for VS 2010 and higher), Help2 (help for VS 2002-2008), RTF, XML。

5 与VS帮助系统直接集成。

6 支持命令行方式调用。

生成的输出文件格式丰富和支持命令行调用令我很满意,只需要写一个Post Build事件命令行调用即可生成文档。

安装好程序之后,Visual Studio的工具栏会多一个小按钮,源代码编辑器会增加以下三个菜单项。





Add Xml Comment 增加注释

Comment Editor 编辑注释

Add Description Attribute 增加描述,点击此菜单之后会给当前方法增加特性。比如:

[System.ComponentModel.Description("编译代码")]

举一个简单的例子,感受一下所见即所得的注释编辑器。





这样可以省略不看MSDN中关于Xml介绍的知识,以图形化方式直观简单的编写注释。

下面来看一下我是如何破解这个软件的。Vsdocman编译之后的代码经过混淆,可以用.NET Reflector反编译,查看关于对话框,可以看到有关试用的代码片段:

 private void About_Load(object sender, EventArgs e)

[code] {

try

{

    try

    {

this.Label10.Text = "Version " + Assembly.GetExecutingAssembly().GetName().Version.ToString();

}

catch (Exception exception1)

    {

ProjectData.SetProjectError(exception1);

ProjectData.ClearProjectError();

}

if (!Class138.smethod_0())

    {

this.Label10.Text = this.Label10.Text + " trial";

}

this.Label12.Visible = false;

this.Panel1.Visible = false;

this.Label13.Visible = false;

this.PanelTrial.Visible = false;

if (!Class138.smethod_0())

    {

this.Label13.Text = "THIS IS EVALUATION VERSION WITH 14 DAYS TRIAL PERIOD";

this.Label13.Visible = true;

this.Label14.Text = "You have been using VSdocman for ";

if (Class140.smethod_5() > 1)

        {

this.Label14.Text = this.Label14.Text + Conversions.ToString(Class140.smethod_5()) + " days.";

    }

else

        {

this.Label14.Text = this.Label14.Text + Conversions.ToString(Class140.smethod_5()) + " day.";

    }

this.PanelTrial.Visible = true;

}

[/code]

第16行代码后加面了一个试用的字样,表明14行的方法返回false之后,会进入16号增加试用版字样,我们只需要将Class138.smethod_0这个方法的调用返回值改成true即可。

再来看一下Class138.smethod_0方法的源代码:

 internal static bool smethod_0()

[code] {

bool flag;

try

{

flag = false;

smethod_7();

if (((string_0.Length != 0) & (class139_0.String_0.Length != 0)) && (class139_0.Int32_0 >= smethod_3()))

    {

flag = smethod_5(string_0, class139_0.String_0);

}

}

catch (Exception exception1)

{

ProjectData.SetProjectError(exception1);

ProjectData.ClearProjectError();

}

return flag;

}

[/code]

以试用版的角度来看这段代码,第10行的代码应该是返回false。这时破解的思路也就产生了,修改

smethod_5方法的返回值,让它总是返回true,或者修改8行的逻辑,让条件总是false不能进入运行第10行代码,再将第6行的代码的默认值改成true,即可完成破解。我选择了后者。

安装Reflexil.Reflector.AIO插件,打开IL代码编辑窗口,直接修改IL代码,然后另存为即可。





如图中所示,第0行的默认值已经改成true,上图中第8行的判断条件,随意改成小于或是等于让它返回false即可,修改之后,再用.NET Reflector加载程序集,源代码反编译如下:

internal static bool smethod_0()
{
bool flag;
try
{
flag = true;
smethod_7();
if (!((string_0.Length != 0) & (class139_0.String_0.Length != 0)) && (class139_0.Int32_0 >= smethod_3()))
{
flag = smethod_5(string_0, class139_0.String_0);
}
}
catch (Exception exception1)
{
ProjectData.SetProjectError(exception1);
ProjectData.ClearProjectError();
}
return flag;
}

破解完毕。

Vsdocman的源代码保护方式是采用Xml签名技术,部分片段代码参考如下:

internal static bool smethod_1(string string_2, string string_3)
{
string_2 = string_2.Trim();
string_2 = string_2.ToUpper();
string_2 = string_2.PadRight(100, '.');
string_2 = smethod_3(string_2);
byte[] bytes = new UnicodeEncoding().GetBytes(string_2);
string_3 = string_3.Replace("\r\n", string.Empty);
string_3 = string_3.Substring(0, string_3.Length - 0x10);
byte[] buffer2 = smethod_6(string_3);
RSACryptoServiceProvider provider = new RSACryptoServiceProvider();
provider.FromXmlString("<RSAKeyValue><Modulus>q/Y9KSdZYHGjjHTLtl5ZzHoaLfyBqGpTISoA98KymLZCoWiudsalpz0zORTYr7LdwHSQiDhMynAxHB2+HR2Tw1c0awwa95VcUUyFIAhTiRoDC8MNHo8R9xxiWIWp0Z1VGKqngtC9RCjdmVethIcSUc167Jw9nNLPAXC0vrmGRs0=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");
RSAParameters parameters = provider.ExportParameters(false);
provider.FromXmlString("<RSAKeyValue><Modulus>q/Y9KSdZYHGjjHTLtl5ZzHoaLfyBqGpTISoA98KymLZCoWiudsalpz0zORTYr7LdwHSQiDhMynAxHB2+HR2Tw1c0awwa95VcUUyFIAhTiRoDC8MNHo8R9xxiWIWp0Z1VGKqngtC9RCjdmVethIcSUc167Jw9nNLPAXC0vrmGRs0=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");
parameters = provider.ExportParameters(false);
return smethod_2(bytes, buffer2, parameters);
}


这与我的文章《大型.NET商业软件保护技术》中介绍的第3条技术相同。

完整的安装程序和破解文件下载:vsdocman_7_1_setup

安装完成之后,直接将VSdocman2.dll覆盖到安装目录中即可。

程序仅仅限于交流和学习,切勿用于商业用途。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: