0

When I run an obfuscator like allatori on my JAR file, it will add a comment to the archive saying something like Obfuscation by Allatori Obfuscator http://www.allatori.com

Using WinRAR, this comment can be removed by editing the archive comment.

However, I did not find a way to do this in a batch script or Java code to integrate into my build process.

How can it be done?

BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185

2 Answers2

3

This is how Archive File comments can be updated using WinRAR CLI:

for %I in ("E:\YOUR\JAR\LOCATION\*.jar") do @"%ProgramFiles%\WinRAR\WinRAR.exe" c -zBLANK_COMMENT_FILE.txt "%I"

Create one blank file named BLANK_COMMENT_FILE.txt where you run this command.

Run this command with administrator access.

Hope this will help you.

Rushi Daxini
  • 1,570
  • 1
  • 10
  • 14
2

I guess you could copy the zip file without copying the comment.

public static void removeComment(Path file) throws IOException {
    Path tempFile = Files.createTempFile("temp", ".zip");
    copyZipFile(file, tempFile, false);
    Files.move(tempFile, file, StandardCopyOption.REPLACE_EXISTING);
}

public static void copyZipFile(Path file, Path newFile, boolean copyComment) throws IOException {
    try (ZipFile zipFile = new ZipFile(file.toFile());
            ZipOutputStream outputStream = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(newFile)))) {
        if (copyComment) {
            outputStream.setComment(zipFile.getComment());
        }
        Enumeration<? extends ZipEntry> entries = zipFile.entries();
        while (entries.hasMoreElements()) {
            copyEntry(zipFile, outputStream, entries.nextElement());
        }
    }
}

private static void copyEntry(ZipFile zipFile, ZipOutputStream outputStream, ZipEntry entry) throws IOException {
    ZipEntry newEntry = (ZipEntry) entry.clone();
    outputStream.putNextEntry(newEntry);
    IOUtils.copy(zipFile.getInputStream(entry), outputStream);
}
Brecht Yperman
  • 1,209
  • 13
  • 27