CrackSleeve icon indicating copy to clipboard operation
CrackSleeve copied to clipboard

脚本有点问题

Open netpr1s0ner opened this issue 2 years ago • 2 comments

那个originKey和加密key需要写死的,每个版本对应都有OrginKey; 4.0 1be5be52c6255c33558e8a1cb667cb06 4.1 80e32a742060b884419ba0c171c9aa76 4.2 b20d487addd4713418f2d5a3ae02a7a0 4.3 3a4425490f389aeec312bdd758ad2b99 4.4 5e98194a01c6b48fa582a6a9fcbb92d6 4.5 f38eb3d1a335b252b58bc2acde81b542

4.5 版本: private static byte[] OriginKey = {-13, -114, -77, -47, -93, 53, -78, 82, -75, -117, -62, -84, -34, -127, -75, 66};

脚本代码: `import java.util.Arrays;

public class Main { public static void main(String[] args) { String CsKey = "f38eb3d1a335b252b58bc2acde81b542"; System.out.println("private static byte[] OriginKey = " + Arrays.toString(Hex2Byte(CsKey)).replace("[", "{").replace("]", "}") + ";"); }

//16进制字符串转byte数组
public static byte[] Hex2Byte(String inHex) {

    String[] hex = stringToStringArray(inHex,2);
    byte[] byteArray = new byte[hex.length];

    for (int i = 0; i < hex.length; i++) {
        //parseInt()方法用于将字符串参数作为有符号的n进制整数进行解析
        byteArray[i] = (byte) Integer.parseInt(hex[i], 16);
    }

    return byteArray;
}

public static String[] stringToStringArray(String src, int length) {
    //检查参数是否合法
    if (null == src || src.equals("")) {return null;}
    if (length <= 0) {return null;}

    int n = (src.length() + length - 1) / length; //获取整个字符串可以被切割成字符子串的个数
    String[] split = new String[n];
    for (int i = 0; i < n; i++) {
        if (i < (n - 1)) {
            split[i] = src.substring(i * length, (i + 1) * length);
        } else {
            split[i] = src.substring(i * length);
        }
    }
    return split;
}

}`

netpr1s0ner avatar Jan 09 '23 10:01 netpr1s0ner

更改后的代码: `import common.; import dns.SleeveSecurity; import java.io.; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile;

public class CrackSleeve { // private static byte[] OriginKey = {27,-27,-66, 82,-58,37,92,51,85,-114,-118,28,-74,103,-53,6}; private static byte[] OriginKey = {-13, -114, -77, -47, -93, 53, -78, 82, -75, -117, -62, -84, -34, -127, -75, 66}; private static byte[] CustomizeKey = {-13, -114, -77, -47, -93, 53, -78, 82, -75, -117, -62, -84, -34, -127, -75, 66};

private String DecDir = "Resource/Decode/sleeve";
private String EncDir = "Resource/Encode/sleeve";

public static void main(String[] args) throws IOException {
    if (args.length == 0 || args[0].equals("-h") || args[0].equals("--help")) {
        System.out.println("UseAge: CrackSleeve OPTION [key]");
        System.out.println("Options:");
        System.out.println("\tdecode\t\tDecode sleeve files");
        System.out.println("\tencode\t\tEncode sleeve files");
        System.out.println("\tkey\t\tCustomize key string for encode sleeve files");
        System.exit(0);
    }
    String option = args[0].toLowerCase();

    CrackSleeve Cracker = new CrackSleeve();
    // 使用正版key初始化SleeveSecurity中的key
    if (option.equals("decode")){
        CrackSleevedResource.Setup(OriginKey);
        Cracker.DecodeFile();
    }else if (option.equals("encode")){
        CrackSleevedResource.Setup(CustomizeKey);
        Cracker.EncodeFile();
    }
}

private void DecodeFile() throws IOException {
    // 文件保存目录
    File saveDir = new File(this.DecDir);
    if (!saveDir.isDirectory())
        saveDir.mkdirs();

    // 获取jar文件中sleeve文件夹下的文件列表
    try {
        String path = this.getClass().getClassLoader().getResource("sleeve").getPath();
        String jarPath = path.substring(5,path.indexOf("!/"));
        Enumeration<JarEntry> jarEnum = new JarFile(new File(jarPath)).entries();
        while (jarEnum.hasMoreElements())
        {
            JarEntry Element = jarEnum.nextElement();
            String FileName = Element.getName();
            if (FileName.indexOf("sleeve")>=0 && !FileName.equals("sleeve/")) {
                System.out.print("[+] Decoding "+FileName+"......");
                byte[] decBytes = CrackSleevedResource.DecodeResource(FileName);
                if (decBytes.length > 0) {
                    System.out.println("Done.");
                    CommonUtils.writeToFile(new File(saveDir,"../"+FileName),decBytes);
                }
                else
                    System.out.println("Fail.");
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}

private void EncodeFile(){
    // 文件保存目录
    File saveDir = new File(this.EncDir);
    if (!saveDir.isDirectory())
        saveDir.mkdirs();

    // 获取解密文件列表
    File decDir = new File(this.DecDir);
    File[] decFiles = decDir.listFiles();
    if (decFiles.length == 0) {
        System.out.println("[-] There's no file to encode, please decode first.");
        System.exit(0);
    }

    for (File file : decFiles){
        String filename = decDir.getPath()+"/"+file.getName();
        System.out.print("[+] Encoding " + file.getName() + "......");
        byte[] encBytes = CrackSleevedResource.EncodeResource(filename);
        if (encBytes.length > 0) {
            System.out.println("Done.");
            CommonUtils.writeToFile(new File(saveDir,file.getName()),encBytes);
        }
        else
            System.out.println("Fail.");
    }
}

}

class CrackSleevedResource{ private static CrackSleevedResource singleton;

private SleeveSecurity data = new SleeveSecurity();

public static void Setup(byte[] paramArrayOfbyte) {
    singleton = new CrackSleevedResource(paramArrayOfbyte);
}

public static byte[] DecodeResource(String paramString) {
    return singleton._DecodeResource(paramString);
}

public static byte[] EncodeResource(String paramString) {
    return singleton._EncodeResource(paramString);
}

private CrackSleevedResource(byte[] paramArrayOfbyte) {
    this.data.registerKey(paramArrayOfbyte);
}

private byte[] _DecodeResource(String paramString) {
    byte[] arrayOfByte1 = CommonUtils.readResource(paramString);
    if (arrayOfByte1.length > 0) {
        long l = System.currentTimeMillis();
        return this.data.decrypt(arrayOfByte1);
    }
    byte[] arrayOfByte2 = CommonUtils.readResource(paramString);
    if (arrayOfByte2.length == 0) {
        CommonUtils.print_error("Could not find sleeved resource: " + paramString + " [ERROR]");
    } else {
        CommonUtils.print_stat("Used internal resource: " + paramString);
    }
    return arrayOfByte2;
}

private byte[] _EncodeResource(String paramString){
    try {
        File fileResource = new File(paramString);
        InputStream fileStream = new FileInputStream(fileResource);
        if (fileStream != null)
        {
            byte[] fileBytes = CommonUtils.readAll(fileStream);
            if (fileBytes.length > 0)
            {
                byte[] fileEncBytes = this.data.encrypt(fileBytes);
                return fileEncBytes;
            }
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

} `

netpr1s0ner avatar Jan 09 '23 10:01 netpr1s0ner