aspose-cells-20.7.jar 去除水印及次数限制

1.使用 jd-gui.exe 反编译查看,直接搜索 License

1.修改

csharp 复制代码
  public static boolean isLicenseSet() {
    return (a != null);
  }

改成

csharp 复制代码
  public static boolean isLicenseSet() {
    return true;
  }

2.修改

csharp 复制代码
  public void setLicense(InputStream stream) {
    Document document = null;
    if (stream != null)
      try {
        DocumentBuilder documentBuilder = zad.b();
        document = documentBuilder.parse(stream);
      } catch (Exception exception) {
        throw new CellsException(9, zf.a(new byte[] { 
                -20, 93, -23, 54, -20, -49, -59, 86, -9, -86, 
                49, 44, -59, 71, -52, -86, -90, 6, -90, -25, 
                -86, 1, -1, -92, -91, -126, 7, 113, -66, -95, 
                -121, 16, -122, -126, 7, 104, -40, -70, -10, -37, 
                126, 7, -111, -121, -121 }) + exception.getMessage());
      }  
    a(document);
  }

改成

csharp 复制代码
  public void setLicense(InputStream paramInputStream){
    a = new License();
    zbiw.a();
  }

3.修改

csharp 复制代码
  private static Date k(String paramString) {
    if (paramString == null || paramString.length() < 8)
      return null; 
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(zf.a(new byte[] { 
            79, 89, 33, -52, 79, -121, -125, 33, 71, -126, 
            105, -121 }));
    try {
      return simpleDateFormat.parse(paramString);
    } catch (ParseException parseException) {
      throw new IllegalArgumentException(zf.a(new byte[] { 
              -21, -113, -77, 13, -115, 27, Byte.MIN_VALUE, 35, 103, -52, 
              -20, -106, 71, 95, 31, -73, -76, -38, 13, 31, 
              -91, -97, -102, 85, -68, -33, -19, -87, -127, -14, 
              78, -23, 6, -25, -94, 1, -97, -95, -57, -121 }));
    } 
  }

改成

csharp 复制代码
  private static Date k(String paramString){
    return new Date(Long.MAX_VALUE);
  }

2.生成 aspose-cells-20.7-crack.jar

修改 class 这里使用 javassist:

新建一个 Spring boot 项目:

pom 文件中引用 javassist

csharp 复制代码
        <dependency><!--aspose的jar破解工具-->
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.20.0-GA</version>
        </dependency>

启动类中创建一个静态方法 crackAspose

csharp 复制代码
    public static void crackAspose(String JarPath) throws Exception {
        // 这个是得到反编译的池
        ClassPool pool = ClassPool.getDefault();

        // 取得需要反编译的jar文件,设定路径
        pool.insertClassPath(JarPath);

        CtClass cc_License = pool.get("com.aspose.cells.License");

        CtMethod method_isLicenseSet = cc_License.getDeclaredMethod("isLicenseSet");
        method_isLicenseSet.setBody("return true;");

        CtClass cc_License2 = pool.get("com.aspose.cells.License");
        CtMethod method_setLicense = cc_License2.getDeclaredMethod("setLicense");
        method_setLicense.setBody("{    a = new com.aspose.cells.License();\n" +
                "    com.aspose.cells.zbiw.a();}");

        CtMethod method_k = cc_License.getDeclaredMethod("k");
        method_k.setBody("return new java.util.Date(Long.MAX_VALUE);");


        cc_License.writeFile("F:\\441\\1");
    }

在 main 方法中执行 crackAspose

csharp 复制代码
        try{
            crackAspose("F:\\441\\aspose-cells-20.7.jar");
            System.out.println("Success!");
        }catch (Exception e){
            e.printStackTrace();
        }

复制一个 aspose-cells-20.7.jar 改名为 aspose-cells-20.7-crack.zip 然后解压

把刚才生成的 License.class 文件 替换到解压的源代码中。

造一个 License xml 文件,这里文件名为 com.aspose.cells.lic_2999.xml, 位置直接放源代码解压的根目录:

文件内容为:

csharp 复制代码
<License>
  <Data>
    <Products>
      <Product>Aspose.Cells for Java</Product>
    </Products>
    <EditionType>Enterprise</EditionType>
    <SubscriptionExpiry>29991231</SubscriptionExpiry>
    <LicenseExpiry>29991231</LicenseExpiry>
    <SerialNumber>evilrule</SerialNumber>
  </Data>
  <Signature>evilrule</Signature>
</License>

防止文件指纹校验,我们需要删除掉源代码解压包中的 META_INF 文件夹。

最后的根目录:

压缩源代码(注意要是 zip 格式)

然后重命名为:

完成!

3.测试 aspose-cells-20.7-crack.jar 使用

封装一个 License 验证方法:

csharp 复制代码
public static boolean authrolizeLicense() {
    boolean result = false;
    try {
        InputStream is = com.aspose.cells.License.class.getResourceAsStream("/com.aspose.cells.lic_2999.xml");
        License asposeLicense = new License();
        asposeLicense.setLicense(is);
        is.close();
        result = true;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

修改 main 方法测试使用:

csharp 复制代码
    public static void main(String[] args) {

    /*
    // 修改 License.class
    try{
        crackAspose("C:\\Users\\DYG\\Desktop\\1\\aspose-cells-20.7.jar");
        System.out.println("Success!");
    }catch (Exception e){
        e.printStackTrace();
    }
    */



        // 测试破解后的 aspose-cells-20.7-crack.jar
        boolean auth = authrolizeLicense();
        if (!auth) {
            System.out.println("aspose 许可无效!");
            return;
        }


        System.out.println("aspose 已就绪!");


        try{
            Workbook wb = new Workbook("F:\\aaa123.xlsx");
            Worksheet ws = wb.getWorksheets().get(0);

            ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
            imgOptions.setImageFormat(ImageFormat.getPng());
            imgOptions.setCellAutoFit(true);
            imgOptions.setOnePagePerSheet(true);
            SheetRender render = new SheetRender(ws, imgOptions);

            render.toImage(0, "F:\\aaa\\123.png");

        }
        catch (Exception e){
            e.printStackTrace();
        }
    }

运行:

样板图

生成图片

相关推荐
ragnwang6 小时前
Notes: Python pybind11 import C++ module
开发语言·c++·python
王中阳Go6 小时前
后端转 Agent 岗面试怎么答:8 个高频问题与应答口径
人工智能·后端·python·大语言模型
weixin_307779137 小时前
RAG 面试陷阱——混合检索并非无条件优越:一个条件反转实验
人工智能·python·面试·职场和发展
云和数据.ChenGuang8 小时前
深入解析 Python 的 dir():从用法到 CPython 源码实现
开发语言·人工智能·python·langchain
荣码10 小时前
长上下文与大文档处理:200页PDF怎么喂给AI,我踩了4个坑
java·python
databook11 小时前
Pandas 与 Polars:语法、性能和资源占用方面的对比
python·数据分析·pandas
威哥爱编程11 小时前
Python 智能体开发实战 10:本地跑得好好的,一并发就崩?把它做成一个能上线的服务
python·agent
威哥爱编程11 小时前
Python 智能体开发实战 09:改了提示词,到底是变好还是变坏?搭一套能打分的离线评测
python·agent
meiying883812 小时前
多快递公司快递单号批量查询接口怎么对接?Python 聚合查询实现
java·大数据·python
Hello_Pyhx12 小时前
Deep-Live-Cam 源码配置思路:环境、模型与执行后端分开排查
python