绿色版Aspose生成方法

绿色版Aspose生成方法

项目中加入我们的java工具包javassist

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.27.0-GA</version>
</dependency>

收集信息,分析源码

License.class中无论是setLicense(String licenseName)还是setLicense(InputStream stream)最终都用到了zzZK5这个类。

    public void setLicense(String licenseName) throws Exception {
        if (licenseName == null) {
            throw new NullPointerException(this.zzYIG.zzZw(new byte[]{108, 105, 99, 101, 110, 115, 101, 78, 97, 109, 101}));
        } else {
            (new zzZK5()).zzV(licenseName, zzZZS.zzlP());
        }
    }

    public void setLicense(InputStream stream) throws Exception {
        if (stream == null) {
            throw new NullPointerException(this.zzYIG.zzZw(new byte[]{115, 116, 114, 101, 97, 109}));
        } else {
            (new zzZK5()).zzV(stream);
        }
    }

而zzZK5这个类有两个方法暴露出来:zzZej和zzZei方法(估计是验证License方法),我们推测可以修改这两个方法,让他们都return 1

static int zzZej()
static int zzZei()

开始行动,获得修改后的class

//指明目标jar包
ClassPool.getDefault().insertClassPath("D:\\work\\apache-maven-3.0.4\\repository\\com\\aspose\\aspose-words\\19.12\\aspose-words-19.12-jdk17.jar");
//找到验证License的类
CtClass zzZJJClass = ClassPool.getDefault().getCtClass("com.aspose.words.zzZK5");
//两个目标方法
CtMethod zzZej = zzZJJClass.getDeclaredMethod("zzZej");
CtMethod zzZei = zzZJJClass.getDeclaredMethod("zzZei");
//修改方法
zzZej.setBody("{return 1;}");
zzZei.setBody("{return 1;}");
//这一步就是将破译完的class放在桌面上
zzZJJClass.writeFile("C:\\Users\\shower\\Desktop\\");

修改Aspose的jar包

然后需要替换jar包中对应的这个class,为防止文件指纹校验,删除META-INF中的 *.RSA 和 *.SF 文件

maven包含本地jar包的方法

        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-words</artifactId>
            <version>19.12</version>
            <classifier>jdk17</classifier>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/aspose-words-19.12-jdk17.jar</systemPath>
        </dependency>
		......
		 <plugin>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-maven-plugin</artifactId>
             <!-- 包含本地jar -->
             <configuration>
                 <includeSystemScope>true</includeSystemScope>
             </configuration>
         </plugin>

云上面使用绿色版jar包

将去掉后缀的jar包放在lib目录下,创建build.sh,在云部署脚本里执行该shell脚本

#! /bin/bash
pwd
mv ./lib/aspose-words-19.12-jdk17 ./lib/aspose-words-19.12-jdk17.jar
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值