Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

简单拆XJar壳

2026-01-04, 杭州

搞安全开发的人一定要懂安全。

XJar是一个SpringBoot的壳,但他这个壳保护了个什么我暂且蒙古。

我在试图分析一个企业级jar程序的时候,Vineflower装载第一个类时即报错了。使用hex编辑器可以看到jar中的class文件非常乱,不像是普通的class。此时注意到其中的POM有:

            <plugin>
                <groupId>com.github.core-lib</groupId>
                <artifactId>xjar-maven-plugin</artifactId>
                <version>4.0.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                        <phase>package</phase>
                        <configuration>
                            <includes>
                                <include>[redacted]</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

那这个xjar就是开头提到的壳了。看xjar的源码,会用模板加密码动态编译一个golang程序作为bootstrap,密码和加密方式都写在这个go binary里。

有人已经提出了简单的找密码的办法,也就是strings xjar |grep -B 10 "AES/CBC/PKCS5Padding",很无脑方便。不过需要注意他可能还采取其他加密方式,比如说DES/CBC/PKCS5Padding

然后起个maven加依赖项

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>com.github.core-lib</groupId>
            <artifactId>xjar</artifactId>
            <version>4.0.2</version>
        </dependency>
    </dependencies>

再解密就完事了。

        try {
            XBoot.decrypt("[redacted].jar", "[redacted]-dec.jar", "[redacted]");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

可能会遇到部分类解开不成功的情况,手动解开的事情稍后再更新。