快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

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 Roeder\\\'s .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.NET\\\'s \"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    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;
      private long _userIndex;
      private string _username;
}
 
继承,刚才找了CreateLicense,现在开始找ValidateLicenseData。
protected virtual bool ValidateLicenseData(Type type, string licenseData)
{
      bool flag1 = false;
      char[] chArray1 = new char[1] { \\\':\\\' } ;
      string[] textArray1 = licenseData.Split(chArray1);
      if (textArray1.Length == 7)
      {
            return (string.Compare(\"URTracker1Licensed\", textArray1[0], true, CultureInfo.InvariantCulture) == 0);
      }
      return flag1;
}
 
哈哈,就是说刚才分析那个数组中textArray1[0],必须是URTracker1Licensed!哈哈,这也进一步证明了我们要把注册信息字符串用\":\"分开的设想。
Come on!离成功越来越近了!接着分析ValidateLicense。
protected virtual bool ValidateLicense(ServerLicense license, out string errorMessage)
{
      errorMessage = null;
      URTrackerLicense license1 = (URTrackerLicense) license;
      if (license1.IsExpired)
      {
            errorMessage = \"The License has expired.\";
            return false;
      }
      return true;
}
 
哦,知道了!原来是判定URTrackerLicense的属性IsExpired的真假!好,咱们看看属性IsExpired。
public bool IsExpired
{
      get
      {
            if ((DateTime.Today.Ticks <= this._ticks) && (DateTime.Now.Ticks >= this._startTicks))
            {
                  return !this._foundMac;
            }
            return true;
      }
}
 
 知道了吧!就是判定当前时间要在ticks和startTicks之间!然后再判定Mac的值。
 现在查找Mac的相关类或者方式。找到了GetMacArray
 public static ArrayList GetMacArray()
{
      ManagementClass class1 = new ManagementClass(\"Win32_NetworkAdapterConfiguration\");
      ManagementObjectCollection collection1 = class1.GetInstances();
      ArrayList list1 = new ArrayList();
      using (ManagementObjectCollection.ManagementObjectEnumerator enumerator1 = collection1.GetEnumerator())
      {
            while (enumerator1.MoveNext())
            {
                  ManagementObject obj1 = enumerator1.get_Current();
                  if ((bool) obj1.get_Item(\"IPEnabled\"))
                  {
                        list1.Add(obj1.get_Item(\"MacAddress\").ToString().Replace(\":\", \"\").ToUpper());
                  }
                  obj1.Dispose();
            }
      }
      return list1;
}

本新闻共2页,当前在第1页  1  2  

本新闻共2页,当前在第1页  1  2  


返回类别: 教程
上一教程: 挤压造型Extrusion的节点说明和应用实例
下一教程: ASP.NET创建XML Web服务全接触(10)

您可以阅读与"URTracker 2.11版 license验证原理剖析"相关的教程:
· ASP.NET创建XML Web服务全接触(11)
· 加入身份验证信息的SMTP mail发送
· 深入讲解 ASP+ 验证(一)
· asp+中的session 的使用和原理() 不需要cookie也可以使用session
· .NET 1.1中预编译ASP.NET页面实现原理浅析 [1] 自动预编译机制浅析
    微笑服务 优质保证 索取样品