Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Invalid CEN header when unzipping apk #3198

Closed
scoliono opened this issue Jul 23, 2023 · 6 comments · Fixed by #3215
Closed

[BUG] Invalid CEN header when unzipping apk #3198

scoliono opened this issue Jul 23, 2023 · 6 comments · Fixed by #3215
Milestone

Comments

@scoliono
Copy link

Information

  1. Apktool Version (apktool -version) - 2.8.1
  2. Operating System (Mac, Linux, Windows) - Arch Linux
  3. APK From? (Playstore, ROM, Other) - Apkcombo
  4. Java Version (java --version) - openjdk 20.0.2 2023-07-18

Stacktrace/Logcat

I: Using Apktool 2.8.1 on HomeHawk_3.8_apkcombo.com.apk
Exception in thread "main" brut.androlib.exceptions.AndrolibException: brut.directory.DirectoryException: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
        at brut.androlib.res.ResourcesDecoder.hasManifest(ResourcesDecoder.java:70)
        at brut.androlib.res.ResourcesDecoder.decodeManifest(ResourcesDecoder.java:102)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:95)
        at brut.apktool.Main.cmdDecode(Main.java:190)
        at brut.apktool.Main.main(Main.java:93)
Caused by: brut.directory.DirectoryException: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
        at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:55)
        at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:38)
        at brut.directory.ExtFile.getDirectory(ExtFile.java:49)
        at brut.androlib.res.ResourcesDecoder.hasManifest(ResourcesDecoder.java:68)
        ... 4 more
Caused by: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
        at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1750)
        at java.base/java.util.zip.ZipFile$Source.checkExtraFields(ZipFile.java:1276)
        at java.base/java.util.zip.ZipFile$Source.checkAndAddEntry(ZipFile.java:1219)
        at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1689)
        at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1464)
        at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1427)
        at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:723)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:250)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:179)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:193)
        at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:53)
        ... 7 more

Steps to Reproduce

  1. Downloaded HomeHawk APK from ApkCombo
  2. java -jar ~/.apklab/apktool_2.8.1.jar d ~/Downloads/HomeHawk_3.8_apkcombo.com.apk -o ~/Downloads/HomeHawk_3.8_apkcombo.com --only-main-classes

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files
(.apks that live in /system/framework or /system/priv-app)

APK

HomeHawk app from the Play Store, downloaded with Apkcombo
Link: https://files.catbox.moe/m2uns4.apk

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? Yes
  2. If you are trying to install a modified apk, did you resign it? N/A
  3. Are you using the latest apktool version? Yes

Final Note: I was able to workaround this problem by manually unzipping the apk and rezipping it.
I noticed there was #3178, but it looks like it's still broken.

@scoliono scoliono changed the title [BUG] [BUG] Invalid CEN header when unzipping apk Jul 23, 2023
@iBotPeaches
Copy link
Owner

I guess your system may be rejecting system property sets? What happens when you manually set jdk.util.zip.disableZip64ExtraFieldValidation to true?

@brianly1003
Copy link

I got the same issue with the Apktool v2.8.1

Information

Apktool Version (apktool -version) - 2.8.1
Operating System (Mac, Linux, Windows) - Windows 11, MacOS Ventura 13.4.1
APK From? (Playstore, ROM, Other) - ROM
Java Version (java --version) - openjdk 20.0.2 2023-07-18

Stacktrace/Logcat

I: Using Apktool 2.8.1 on base.apk
Exception in thread "main" brut.androlib.exceptions.AndrolibException: brut.directory.DirectoryException: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
	at brut.androlib.res.ResourcesDecoder.hasManifest(ResourcesDecoder.java:70)
	at brut.androlib.res.ResourcesDecoder.decodeManifest(ResourcesDecoder.java:102)
	at brut.androlib.ApkDecoder.decode(ApkDecoder.java:95)
	at brut.apktool.Main.cmdDecode(Main.java:190)
	at brut.apktool.Main.main(Main.java:93)
Caused by: brut.directory.DirectoryException: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
	at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:55)
	at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:38)
	at brut.directory.ExtFile.getDirectory(ExtFile.java:49)
	at brut.androlib.res.ResourcesDecoder.hasManifest(ResourcesDecoder.java:68)
	... 4 more
Caused by: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
	at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1750)
	at java.base/java.util.zip.ZipFile$Source.checkExtraFields(ZipFile.java:1276)
	at java.base/java.util.zip.ZipFile$Source.checkAndAddEntry(ZipFile.java:1219)
	at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1689)
	at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1464)
	at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1427)
	at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:723)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:250)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:179)
	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:193)
	at brut.directory.ZipRODirectory.<init>(ZipRODirectory.java:53)
	... 7 more

@iBotPeaches
Copy link
Owner

May one of you try the upgraded helper scripts I've attached in this pr? #3215

To be honest - this doesn't make sense. The Security Manager reads as the only reason you wouldn't be allowed to set this at runtime, which has been deprecated for years.

@brianly1003
Copy link

May one of you try the upgraded helper scripts I've attached in this pr? #3215

To be honest - this doesn't make sense. The Security Manager reads as the only reason you wouldn't be allowed to set this at runtime, which has been deprecated for years.

Tested. This pr #3215 worked for me on both Windows and macOS platforms.

@iBotPeaches
Copy link
Owner

Tested. This pr #3215 worked for me on both Windows and macOS platforms.

Thanks. Since you can use the existing Apktool version you have w/ that patch. I'll do a bit more search why the System.setProperty didn't work and close this out.

@jpstotz
Copy link

jpstotz commented Jul 27, 2023

For the reason why System.setProperty does not work please see my comment here: #3174 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants