Tuesday, July 7, 2009

Zend Guard ... 不想折腾了

把这几天记下来的东西贴上来
懒得折腾了
太麻烦了,不靠谱
Java代码里没找到验证的部分
很多验证都是在调用resource下的几个程序
而这几个程序居然用OpenSSL。。。
DSA签名啊。。。




=============================================================

RegisterWizard.class:
    String str1 = null;
    if (this.a.a())
      try
      {
        File localFile = File.createTempFile("ZGLicense", null);
        localFile.deleteOnExit();
        str1 = localFile.getPath();
        String str2 = str1;
        1 local1 = new 1(this, str2);
        getContainer().run(true, true, local1);
      }
      catch (Exception localException)
      {
        CommonUIPlugin.a(localException);
        return false;
      }
    else
      str1 = this.a.e();
RegisterWizardPage1.class
  private RegisterWizardPage1 a;
a.a(); -> 返回 a.n
a.n:
 this.n = this.b.getSelection();
a.e(); -> 返回 a.r
a.r:
     this.r = str1;
----->
String str1 = this.l.getText().trim();

所以,a.e() 返回输入的文件名
        int i = GuardLicense.a(str1, GuardConsole.b().newOutputStream(), null);
GuardConsole.b():单件模式初始化对象
直接看 GuardLicense.class 的
  public static int a(String paramString, OutputStream paramOutputStream, IProgressMonitor paramIProgressMonitor)
    int i2 = ZendUtility.g;
// -> ZendUtility.g 一个static 的 int
String str = new File(ZendEncoder.a().d()).getParent();

// -> ZendEncoder.a().d() : .a()初始化对象,.d()是继承 ZendUtility 的 d()方法
代码如下
      String str1 = GuardCorePlugin.a().getBundle().getSymbolicName();
      StringBuffer localStringBuffer = new StringBuffer();
      localStringBuffer.append("/resources/");
      localStringBuffer.append(c());
// 这里c()返回的是 GuardEngine的文件名,Windows下加了 .exe 的扩展名
      String str2 = localStringBuffer.toString();
      URL localURL = FileLocator.find(Platform.getBundle(str1), new Path(str2), null);
      if (localURL != null)
      {
        localURL = FileLocator.resolve(localURL);
        String str3 = localURL.getFile();
        this.b = new Path(str3).toOSString();
      }
// 后边这个等着查javadoc吧

回来
    String str = new File(ZendEncoder.a().d()).getParent();
    File localFile1 = new File(str, "zend_guard.zl");
    File localFile2 = null;
    File localFile3 = new File(paramString);
    boolean bool = localFile1.getCanonicalPath().equals(localFile3.getCanonicalPath());
按照File的参数判断,str这个应该是取resources目录的绝对路径,或者类似的

下边的代码是处理文件存在的时候,将文件备份成***.bak文件
    if ((localFile1.exists()) && (!(bool)))
    {
      localFile2 = new File(localFile1.getAbsolutePath() + ".bak");
      localFile1.renameTo(localFile2);
      localFile1 = new File(str, "zend_guard.zl");
    }




































========================================================================================

从Java代码里很难找到验证相关的代码
看了看resources下的几个exe文件
都有license验证的提示

Ollydbg载入,看字符串参考
满眼全是 OpenSSL相关的东西

phpchina的sample license的内容,看着像是不对称加密的数据

相对而言,zendenc_sign的文件最小,内容较少
考虑调试这个东西


但是,从提示看
license的验证更像是验证证书的签名和有效性
而后的加密,貌似就是用这个分发的证书再对文件做签名

很诡异

如果真是证书的方式,那就可以不用考虑了
伪造证书、签名肯定不靠谱

No comments:

Post a Comment