涉及到的工具
JByteMod-1.8.2
luyten-0.5.3
javassist-3.24.1-GA
crack思路
从aspose-words-java.jar使用,可以反推License认证过程
License.java -> zzZLJ.java
InputStream is = com.aspose.words.Document.class
.getResourceAsStream("/com.aspose.words.lic_2999.xml");
License asposeLicense = new License();
asposeLicense.setLicense(is);
System.out.println("Aspose isLicensed: " + asposeLicense.isLicensed());
crack过程
-
先用JByteMod清除掉zzZ(final Node node, final Node node2, final String s)方法体中的内容
使用javassist动态生成新class
引入javassist依赖
<dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.24.1-GA</version>
</dependency>
public class AsposeWordsCrack191 {
public static void changeMethod() throws Exception {
System.out.println("开始破解!");
ClassPool.getDefault().insertClassPath("d:\\aspose-words-19.1-jdk16.jar");
CtClass c2 = ClassPool.getDefault()
.getCtClass("com.aspose.words.zzZLJ");
CtMethod[] ms = c2.getDeclaredMethods();
for (CtMethod c : ms) {
System.out.println("method name:" + c.getName() + "() ,Parameter:");
CtClass[] ps = c.getParameterTypes();
for (CtClass cx : ps) {
System.out.println("\t" + cx.getName());
}
if (c.getName().equals("zzZ") && ps.length == 3
&& ps[0].getName().equals("org.w3c.dom.Node")
&& ps[1].getName().equals("org.w3c.dom.Node")
&& ps[2].getName().equals("java.lang.String")) {
System.err.println("find it!!!!!!!!!!!!!!!!!");
c.insertBefore("{return;}");
}
if (c.getName().equals("zzZI1")) {
System.err.println("find it!!!!!!!!!!!!!!!!!" + c.getName());
c.insertBefore("{return 1;}");
}
if (c.getName().equals("zzZI0")) {
System.err.println("find it!!!!!!!!!!!!!!!!!" + c.getName());
c.insertBefore("{return 1;}");
}
}
//输出到当前目录下
c2.writeFile();
}
public static void main(String[] args) {
try {
AsposeWordsCrack191.changeMethod();
} catch (Exception e) {
e.printStackTrace();
}
}
}
生成一个zzZLJ.class
-
替换原zzZLJ.class
-
新旧zzZLJ类不同
- 删除META-INF目录,增加认证文件com.aspose.words.lic_2999.xml
认证文件com.aspose.words.lic_2999.xml
<License>
<Data>
<Products>
<Product>Aspose.Words for Java</Product>
</Products>
<EditionType>Enterprise</EditionType>
<SubscriptionExpiry>29991231</SubscriptionExpiry>
<LicenseExpiry>29991231</LicenseExpiry>
<SerialNumber>---</SerialNumber>
</Data>
<Signature>---</Signature>
</License>
测试新crack.jar
可以用aspose-words-19.1-crack.jar命名,或直接替换aspose-words-19.1-jdk16.jar
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>19.1</version>
<classifier>crack</classifier>
</dependency>
在本地maven目录下
- 测试代码
public class CrackSample {
public static void main(String[] args) throws Exception {
String baseDir = "D:\\testAspose\\";
doc2pdf(baseDir + "工程文档.docx", baseDir + "工程文档.pdf");
}
/**
* 使用Aspose.Words前都要验证License 若不验证则转化出的pdf文档有水印
* @return
* @throws Exception
*/
public static boolean checkLicense() throws Exception {
boolean result = false;
try {
InputStream is = com.aspose.words.Document.class
.getResourceAsStream("/com.aspose.words.lic_2999.xml");
License asposeLicense = new License();
asposeLicense.setLicense(is);
System.out.println("Aspose isLicensed: " + asposeLicense.isLicensed());
result = true;
is.close();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
return result;
}
public static void doc2pdf(String inPath, String outPath) throws Exception {
// 验证License 若不验证则转化出的pdf文档有水印
if (!checkLicense()) {
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-words-18.6 java版破解