无废话aspose-words-18.6 java版破解

用到的工具:

JByteMod、javassist 可在文章最下方下载


下载原版aspose-words-18.6-jdk16.jar

使用执行JByteMod-1.8.0.jar反编译其源码查看其注册文件的加载类

package com.aspose.words;

import asposewobfuscated.*;
import java.io.*;

public class License
{
    @Deprecated
    public boolean getIsLicensed() {
        return zzZLX.zzZJT() == 1;
    }
    
    public boolean isLicensed() {
        return zzZLX.zzZJT() == 1;
    }
    
    public void setLicense(final String licenseName) throws Exception {
        if (licenseName == null) {
            throw new NullPointerException("licenseName");
        }
        new zzZLX().zzY(licenseName, zz2W.zzA3());
    }
    
    public void setLicense(final InputStream stream) throws Exception {
        if (stream == null) {
            throw new NullPointerException("stream");
        }
        new zzZLX().zzX(stream);
    }
}

可见主要的处理类为zzZLX,反编译后找到关键代码如下

    private static void zzZ(final Node node, final Node node2) throws Exception {
        byte[] bytes;
        if (node != null) {
            final StringBuilder sb;
            zzZ(sb = new StringBuilder(), node);
            bytes = sb.toString().getBytes("UTF-16LE");
        }
        else {
            bytes = new byte[0];
        }
        byte[] decode;
        if (node2 != null) {
            decode = zz35.decode(node2.getFirstChild().getNodeValue());
        }
        else {
            decode = new byte[0];
        }
        final Signature instance = Signature.getInstance("SHA1withRSA");
        instance.initVerify(KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger(1, zzZg(zz35.decode("0nRuwNEddXwLfXB7pw66G71MS93gW8mNzJ7vuh3Sf4VAEOBfpxtHLCotymv1PoeukxYe31K441Ivq0Pkvx1yZZG4O1KCv3Omdbs7uqzUB4xXHlOub4VsTODzDJ5MWHqlRCB1HHcGjlyT2sVGiovLt0Grvqw5+QXBuinoBY0suX0="))), new BigInteger(1, zzZg(zz35.decode("AQAB"))))));
        instance.update(bytes);
        if (!instance.verify(decode)) {
            throw new IllegalStateException("The signature is invalid.");
        }
    }

可见这是使用rsa加密验证许可证的合法性,只需要屏蔽验证过程许可证即有效,使用javassist进行代码修改:

	public static void changeMethod() throws Exception {
		ClassPool.getDefault().insertClassPath(
				"D:/aspose-words-18.6-jdk16.jar");
		CtClass c2 = ClassPool.getDefault()
				.getCtClass("com.aspose.words.zzZLX");
		CtMethod[] ms = c2.getDeclaredMethods();
		for (CtMethod c : ms) {
			System.out.println(c.getName());
			CtClass[] ps = c.getParameterTypes();
			for (CtClass cx : ps) {
				System.out.println("\t" + cx.getName());
			}

			if (c.getName().equals("zzZ") && ps.length == 2
					&& ps[0].getName().equals("org.w3c.dom.Node")
					&& ps[1].getName().equals("org.w3c.dom.Node")) {
				System.out.println("find it!");
				c.insertBefore("{return;}");
			}

		}
		c2.writeFile();

	}

以上可生成zzZLX.class文件,放入jar文件中替换,为防止文件指纹校验,删除jar文件中的META-INF文件夹

下面生成一个许可文件com.aspose.words.lic_2999.xml:


  
    
      Aspose.Words for Java
    
    Enterprise
    29991231
    29991231
    ---
  
  ---

为方便使用,我将此文件放入了jar文件根目录下

以下为使用代码,Enjoy it:)

package test_fileconvert;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

import com.aspose.words.Document;
import com.aspose.words.License;
import com.aspose.words.SaveFormat;

public class Doc2Pdf {

	public static void main(String[] args) throws Exception {
		doc2pdf("e:/pjtemp/f_new.docx", "e:/pjtemp/f_new.pdf");
	}

	public static boolean getLicense() throws Exception {
		boolean result = false;
		try {

			InputStream is = com.aspose.words.Document.class
					.getResourceAsStream("/com.aspose.words.lic_2999.xml");
			License aposeLic = new License();
			aposeLic.setLicense(is);
			result = true;
			is.close();
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		return result;
	}

	public static void doc2pdf(String inPath, String outPath) throws Exception {
		if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档有水印
			throw new Exception("com.aspose.words lic ERROR!");
		}

		System.out.println(inPath + " -> " + outPath);

		try {
			long old = System.currentTimeMillis();
			File file = new File(outPath);
			FileOutputStream os = new FileOutputStream(file);
			Document doc = new Document(inPath); // word文档
			// 支持RTF HTML,OpenDocument, PDF,EPUB, XPS转换
			doc.save(os, SaveFormat.PDF);
			long now = System.currentTimeMillis();
			System.out.println("convert OK! " + ((now - old) / 1000.0) + "秒");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

注意:此教程及下载文件只允许学习使用,不得用于商业用途,请购买授权正版 aspose官网。

--------------------------------------------------------------------------------------------------

下载: 

aspose-words-18.6-jdk16-crack.jar

JByteMod-Beta-master编译版

jboss-javassist-javassist-rel_3_23_0_ga 


你可能感兴趣的:(编程技术)