当前位置:编程学习 > asp >>

URTracker 2.11版 license验证原理剖析

注    :原创,转载请注明出处。
作 者:草惜草
首 发: http://kokey.blogchina.com

序言:

   看了henryouly的文章以后深受启发,决定对URTracker最新的版本来个剖析。在此,特别感谢henryouly!

×××××××××××××××××××××××××××××××××××××××××××××
URTracker事务跟踪系统是一款功能强大而且易于使用的Web方式的协同工作软件 。它用于帮助公司和团队跟踪工作中的问题,管理和记录这些问题的处理过程。
URTracker向您的团队提供了一个全功能的,高度可定制的软件工具用于报告和跟踪问题、需求、缺陷(BUG)或者任务等事务。它拥有丰富的自定义字段、基于项目和角色的权限控制、简化的工作流、友好的用户界面,以及更多的其他特性。我们非常确信您将会喜欢上URTracker,因为我们相信她正是您所需要的。
 ××××××××××××××××××××××××××××××××××××××××××××
 工具介绍:
 
   要研究.NET当然离不开Reflector for .NET 。(Reflector is a class browser for .NET components. It supports assembly and namespace views, type and member search, XML documentation, call and callee graphs, IL, Visual Basic, Delphi and C# decompiler, dependency trees, base type and derived type hierarchies and resource viewers. )
   如果想把代码保存下来,那就需要Reflector的插件Reflector.FileDisassembler了。(The Reflector.FileDisassembler is a little add-in for the new version of Lutz Roeders .NET Reflector that you can use to dump the decompiler output to files of any Reflector supported language (C#, VB.NET, Delphi). This is extremely useful if you are searching for a specific line of code as you can use VS.NETs "Find in Files" or want to convert a class from one language to another.

  下载地址:Reflector for .NET   http://www.aisto.com/roeder/dotnet/
                      Reflector.FileDisassembler    aspx">http://www.denisbauer.com/NETTools/FileDisassembler.aspx
 
 正文:

严重声明:本文只作科研和学习用途。如果由本文产生的法律纠纷,一概与本人无关。

好了,了解了Reflector咱们就可以动手研究URTracker了。

当然首先用Reflector分析bin文件夹下的文件,一共有12个DLL文件,从他们的名称你也可以猜出个八八九九,反正你不怕麻烦你就挨个用Reflector试好了...^_^
最后找到了WebTracker.dll 可疑,因为在Reflector按F3,你可以搜索到很多关于license的东东。哈哈,探究之路开始了。
首先看看Lealsoft.URTracker.BLL下有个ServerLicenseProvider类。

public class ServerLicenseProvider : LicenseProvider
{
      // Methods
      static ServerLicenseProvider();
      public ServerLicenseProvider();
      protected virtual ServerLicense CreateEmptyLicense(Type type);
      protected virtual ServerLicense CreateLicense(Type type, string key);
      public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions);
      protected virtual string GetLicenseData(Type type);
      protected virtual Stream GetLicenseDataStream(Type type);
      protected virtual bool ValidateLicense(ServerLicense license, out string errorMessage);
      protected virtual bool ValidateLicenseData(Type type, string licenseData);

      // Fields
      private static readonly ServerLicenseCollector LicenseCollector;

      // Nested Types
      private sealed class ServerLicenseCollector
      {
            // Methods
            public ServerLicenseCollector();
            public void AddLicense(Type objectType, ServerLicense license);
            public ServerLicense GetLicense(Type objectType);
            public void RemoveLicense(Type objectType);

            // Fields
            private IDictionary _collectedLicenses;
      }
}
 
看到没,有几个CreateLicense,GetLicense,ValidateLicense ,ValidateLicenseData,GetLicenseDataStream这几个方法。好,打开看看都是什么东东。

protected virtual ServerLicense CreateLicense(Type type, string key)
{
      char[] chArray1 = new char[1] { : } ;
      string[] textArray1 = key.Split(chArray1);
      return new URTrackerLicense(type, key, long.Parse(textArray1[1], CultureInfo.InvariantCulture), long.Parse(textArray1[2], CultureInfo.InvariantCulture), textArray1[3], long.Parse(textArray1[4], CultureInfo.InvariantCulture), long.Parse(textArray1[5], CultureInfo.InvariantCulture), textArray1[6]);
}
 
哇!就是新建license,URTrackerLicense后面有几个参数,什么也看不出,感觉是要用":"split开一个字符串。来,打开URTrackerLicense构造函数看看。
public URTrackerLicense(Type type, string key, long startTicks, long ticks, string username, long userIndex, long clientCount, string mac) : base(type, key)
{
      this._foundMac = false;
      this._ticks = ticks;
      this._startTicks = startTicks;
      this._username = username;
      this._userIndex = userIndex;
      this._clientCount = clientCount;
      this._mac = mac;
      this._macArray = URTrackerLicense.GetMacArray();
      this._foundMac = this._macArray.IndexOf(this._mac) > -1;
}
 
哦,看到ticks,startTicks,username,userIndex,clientCount,mac
难道这些就是所需参数"到期时间,使用开始时间,用户名,用户名索引,用户数,本机网卡地址"
有点意思了。呵呵。
找到了 URTrackerLicense 类,你就会知道我们猜测的没有错了。
public class URTrackerLicense : ServerLicense
{
      // Methods
      public URTrackerLicense(Type type, string key, long startTicks, long ticks, string username, long userIndex, long clientCount, string mac);
      public static ArrayList GetMacArray();

      // Properties
      public long ClientCount { get; }
      public bool IsExpired { get; }
      public string Mac { get; }
      public long StartTicks { get; }
      public long Ticks { get; }
      public long UserIndex { get; }
      public string Username { get; }

      // Fields
      private long _clientCount;
      private bool _foundMac;
      private string _mac;
      private ArrayList _macArray;
      private long _startTicks;
      private long _ticks;
 &nb

补充:Web开发 , ASP.Net ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,