無廢話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:
<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>
為方便使用,我將此檔案放入了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
---------------------
作者:shadowkiss
來源:CSDN
原文:https://blog.csdn.net/shadowkiss/article/details/80868472
版權宣告:本文為博主原創文章,轉載請附上博文連結!