一、Aspose.PDF简介
Aspose.PDF是一个Java组件,旨在允许开发人员以编程方式动态创建PDF文档,无论是简单还是复杂。Aspose.PDF for Java允许开发人员将表格,图形,图像,超链接,自定义字体等插入到PDF文档中。此外,还可以压缩PDF文档。Aspose.PDF for Java 提供了出色的安全功能来开发安全的 PDF 文档。Aspose.PDF java最显着的特点是它支持通过API和XML模板创建PDF文档。
来自官网的一个介绍,简单的说就是,让开发人员更方便的操作 PDF。
二、破解流程
下载Jar包
反编译修改要替换的class文件
重新打包
三、开始破解
1 2 3 4 5 <repository > <id > AsposeJavaAPI</id > <name > Aspose Java API</name > <url > https://repository.aspose.com/repo/</url > </repository >
但是就是没下载下来,估计是网络问题,所以我选择手动下载,如下图:
然后POM 使用 systemPath引入,因为最终你还是需要systemPath引入
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-pdf</artifactId> <version>22.7.1</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/aspose-pdf-22.7.1.jar</systemPath> </dependency> <!-- Java字节码的类库,破解需要--> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.29.0-GA</version> </dependency>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 import javassist.*;import java.io.*;import java.util.ArrayList;import java.util.Enumeration;import java.util.List;import java.util.jar.JarEntry;import java.util.jar.JarFile;import java.util.jar.JarOutputStream;public class PDFJarCrack { public static void main (String[] args) throws Exception { String property = System.getProperty("user.dir" ); String jarPath = property+ "/src/main/resources/lib/aspose-pdf-22.7.1.jar" ; crack(jarPath); } private static void crack (String jarName) { try { ClassPool.getDefault().insertClassPath(jarName); CtClass ctClass = ClassPool.getDefault().getCtClass("com.aspose.pdf.ADocument" ); CtMethod[] declaredMethods = ctClass.getDeclaredMethods(); int num = 0 ; for (int i = 0 ; i < declaredMethods.length; i++) { if (num == 2 ) { break ; } CtMethod method = declaredMethods[i]; CtClass[] ps = method.getParameterTypes(); if (ps.length == 2 && method.getName().equals("lI" ) && ps[0 ].getName().equals("com.aspose.pdf.ADocument" ) && ps[1 ].getName().equals("int" )) { System.out.println(method.getReturnType()); System.out.println(ps[1 ].getName()); method.setBody("{return false;}" ); num = 1 ; } if (ps.length == 0 && method.getName().equals("lt" )) { method.setBody("{return true;}" ); num = 2 ; } } File file = new File (jarName); ctClass.writeFile(file.getParent()); disposeJar(jarName, file.getParent() + "/com/aspose/pdf/ADocument.class" ); } catch (NotFoundException e) { e.printStackTrace(); } catch (CannotCompileException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } private static void disposeJar (String jarName, String replaceFile) { List<String> deletes = new ArrayList <>(); deletes.add("META-INF/37E3C32D.SF" ); deletes.add("META-INF/37E3C32D.RSA" ); File oriFile = new File (jarName); if (!oriFile.exists()) { System.out.println("######Not Find File:" + jarName); return ; } String bakJarName = jarName.substring(0 , jarName.length() - 3 ) + "cracked.jar" ; try { JarFile jarFile = new JarFile (jarName); JarOutputStream jos = new JarOutputStream (new FileOutputStream (bakJarName)); Enumeration entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = (JarEntry) entries.nextElement(); if (!deletes.contains(entry.getName())) { if (entry.getName().equals("com/aspose/pdf/ADocument.class" )) { System.out.println("Replace:-------" + entry.getName()); JarEntry jarEntry = new JarEntry (entry.getName()); jos.putNextEntry(jarEntry); FileInputStream fin = new FileInputStream (replaceFile); byte [] bytes = readStream(fin); jos.write(bytes, 0 , bytes.length); } else { jos.putNextEntry(entry); byte [] bytes = readStream(jarFile.getInputStream(entry)); jos.write(bytes, 0 , bytes.length); } } else { System.out.println("Delete:-------" + entry.getName()); } } jos.flush(); jos.close(); jarFile.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } private static byte [] readStream(InputStream inStream) throws Exception { ByteArrayOutputStream outSteam = new ByteArrayOutputStream (); byte [] buffer = new byte [1024 ]; int len = -1 ; while ((len = inStream.read(buffer)) != -1 ) { outSteam.write(buffer, 0 , len); } outSteam.close(); inStream.close(); return outSteam.toByteArray(); } }
代码执行结束后,没报错的话,会在jar包的同级目录下生成一个带有cracked
的jar
用这个包替换原来的 jar包即可。
POM引入:我的jar是放在 resources/lib
下面的。
1 2 3 4 5 6 7 <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-pdf</artifactId> <version>22.7.1</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/aspose-pdf-22.7.1.cracked.jar</systemPath> </dependency>