分析優秀的.NET 文檔設計工具Vsdocman 7.1 軟件保護技術


Vsdocman是一個優秀的.NET源代碼注釋編寫工具,方便的以GUI的方式設計.NET源代碼的注釋。

我們知道.NET源代碼的注釋是Xml格式的注釋,在生成程序集時,只需用選中生成Xml注釋,Visual Studio根據源代碼生成Xml注釋文件。把程序集和相應的Xml文件拷貝到其它電腦中,在Visual Studio中編輯引用類型時,Visual Studio智能提示會提取Xml注釋中的內容以方便編程開發。

image

.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的工具欄會多一個小按鈕,源代碼編輯器會增加以下三個菜單項。

image

Add Xml Comment 增加注釋

Comment Editor 編輯注釋

Add Description Attribute 增加描述,點擊此菜單之后會給當前方法增加特性。比如:

[System.ComponentModel.Description("編譯代碼")]

 

舉一個簡單的例子,感受一下所見即所得的注釋編輯器。

image

這樣可以省略不看MSDN中關於Xml介紹的知識,以圖形化方式直觀簡單的編寫注釋。

下面來看一下我是如何破解這個軟件的。Vsdocman編譯之后的代碼經過混淆,可以用.NET Reflector反編譯,查看關於對話框,可以看到有關試用的代碼片段:

   1:   private void About_Load(object sender, EventArgs e)
   2:          {
   3:              try
   4:              {
   5:                  try
   6:                  {
   7:     this.Label10.Text = "Version " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
   8:                  }
   9:                  catch (Exception exception1)
  10:                  {
  11:                      ProjectData.SetProjectError(exception1);
  12:                      ProjectData.ClearProjectError();
  13:                  }
  14:                  if (!Class138.smethod_0())
  15:                  {
  16:                      this.Label10.Text = this.Label10.Text + " trial";
  17:                  }
  18:                  this.Label12.Visible = false;
  19:                  this.Panel1.Visible = false;
  20:                  this.Label13.Visible = false;
  21:                  this.PanelTrial.Visible = false;
  22:                  if (!Class138.smethod_0())
  23:                  {
  24:                      this.Label13.Text = "THIS IS EVALUATION VERSION WITH 14 DAYS TRIAL PERIOD";
  25:                      this.Label13.Visible = true;
  26:                      this.Label14.Text = "You have been using VSdocman for ";
  27:                      if (Class140.smethod_5() > 1)
  28:                      {
  29:                          this.Label14.Text = this.Label14.Text + Conversions.ToString(Class140.smethod_5()) + " days.";
  30:                      }
  31:                      else
  32:                      {
  33:                          this.Label14.Text = this.Label14.Text + Conversions.ToString(Class140.smethod_5()) + " day.";
  34:                      }
  35:                      this.PanelTrial.Visible = true;
  36:                  }

 

第16行代碼后加面了一個試用的字樣,表明14行的方法返回false之后,會進入16號增加試用版字樣,我們只需要將Class138.smethod_0這個方法的調用返回值改成true即可。

再來看一下Class138.smethod_0方法的源代碼:

   1:   internal static bool smethod_0()
   2:          {
   3:              bool flag;
   4:              try
   5:              {
   6:                  flag = false;
   7:                  smethod_7();
   8:                  if (((string_0.Length != 0) & (class139_0.String_0.Length != 0)) && (class139_0.Int32_0 >= smethod_3()))
   9:                  {
  10:                      flag = smethod_5(string_0, class139_0.String_0);
  11:                  }
  12:              }
  13:              catch (Exception exception1)
  14:              {
  15:                  ProjectData.SetProjectError(exception1);
  16:                  ProjectData.ClearProjectError();
  17:              }
  18:              return flag;
  19:          }

以試用版的角度來看這段代碼,第10行的代碼應該是返回false。這時破解的思路也就產生了,修改

smethod_5方法的返回值,讓它總是返回true,或者修改8行的邏輯,讓條件總是false不能進入運行第10行代碼,再將第6行的代碼的默認值改成true,即可完成破解。我選擇了后者。

安裝Reflexil.Reflector.AIO插件,打開IL代碼編輯窗口,直接修改IL代碼,然后另存為即可。

image

如圖中所示,第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覆蓋到安裝目錄中即可。

程序僅僅限於交流和學習,切勿用於商業用途。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM