編輯IL文件 修改DLL文件


本文章只是技術探討,學習,技術上的研究而已。請支持正版.

如:KS.Gantt.DLL 為例

  1. 使用ILSpy反編譯 工具
  2. 利用ildasm反編譯 KS.Gantt.dll  生成IL中間代碼 一般會生成 *.il 和*.res 一些其它資源文件 *.resources
  3. 然后用記事本修改IL文件
  4. 然后用ilasm編譯中間代碼,生成新的KS.Gantt.dll
  5. 在項目中使用 查看效果

破解過程

修改驗證的代碼

利用ildasm反編譯 KS.Gantt.dll 

打開IL文件找到對應的代碼然后刪除掉 

哈哈 就這個。。

  .try
    {
      IL_0260:  ldarg.0
      IL_0261:  ldtoken    KS.Gantt.Gantt
      IL_0266:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
      IL_026b:  ldarg.0
      IL_026c:  call       class [System]System.ComponentModel.License [System]System.ComponentModel.LicenseManager::Validate(class [mscorlib]System.Type,
                                                                                                                              object)
      IL_0271:  stfld      class [System]System.ComponentModel.License KS.Gantt.Gantt::license
      IL_0276:  leave.s    IL_0297

    }  // end .try
    catch [mscorlib]System.Exception 
    {
      IL_0278:  pop
      IL_0279:  call       bool [mscorlib]System.Diagnostics.Debugger::get_IsAttached()
      IL_027e:  brtrue.s   IL_0295

      IL_0280:  newobj     instance void KS.Gantt.frmAbout::.ctor()
      IL_0285:  stloc.0
      IL_0286:  ldloc.0
      IL_0287:  callvirt   instance valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.Form::ShowDialog()
      IL_028c:  pop
      IL_028d:  ldloc.0
      IL_028e:  callvirt   instance void [System]System.ComponentModel.Component::Dispose()
      IL_0293:  ldnull
      IL_0294:  stloc.0
      IL_0295:  leave.s    IL_0297

    } 

然后用ilasm編譯中間代碼

ilasm /dll /output=D:\MyDll\KS.Gantt.dll /Resource=D:\MyDll\Gantt.res D:\MyDll\Gantt.il

我一看到這幾個單詞。我就知道成功了。。

然后在去驗證

那個授權驗證代碼不在了哈。。

 不過呢。后來我測試 。我發現在這個DLL不能用的。運行會報這個錯的

Unhandled Exception: System.IO.FileLoadException: Strong name validation failed 

所以又得刪除那個簽名,刪除以下所有內容

.publickey = (00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00   // .$.............. 
                00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00   // .$..RSA1........ 
                3B B2 D0 F9 DA 7E 55 B2 50 40 6B CF EB 20 F6 67   // ;....~U.P@k.. .g 
                E7 D6 AF 65 32 4F 6D 21 5D 91 53 0B 04 C7 E2 15   // ...e2Om!].S..... 
                F0 6A EE 38 F8 74 DB 22 34 F9 A1 B5 16 C1 04 66   // .j.8.t."4......f 
                B7 0B A8 36 49 9E 8A 71 E1 D1 26 AB A2 78 4E 3A   // ...6I..q..&..xN: 
                8B 71 8C 7F 4D 54 22 28 5F 1F 8D DE 6C 96 EC 22   // .q..MT"(_...l.." 
                34 8A 35 3F 95 0A F4 F4 7F B7 8C F5 5D F4 CB 54   // 4.5?........]..T 
                92 94 DD 5E D5 0D 20 12 7F B1 9B 15 7F 0E FB 2A   // ...^.. ........* 
                76 5F 45 3D 20 2C E2 6D FE 55 72 30 49 76 28 FE ) // v_E= ,.m.Ur0Iv(.

最后在從新編譯DLL。成功了

 


免責聲明!

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



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