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] APK doesn't decompile #2587

Closed
timea-techgirl opened this issue Jun 14, 2021 · 5 comments · Fixed by #3210
Closed

[BUG] APK doesn't decompile #2587

timea-techgirl opened this issue Jun 14, 2021 · 5 comments · Fixed by #3210
Milestone

Comments

@timea-techgirl
Copy link

timea-techgirl commented Jun 14, 2021

Information

  1. Apktool Version (apktool -version) - 2.5.0
  2. Operating System (Mac, Linux, Windows) - Windows 10 x64
  3. APK From? (Playstore, ROM, Other) - Other

Steps to Reproduce

  1. apktool d bug.apk

Stacktrace/Logcat

I: Using Apktool 2.5.0 on bug.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
Exception in thread "main" brut.androlib.err.RawXmlEncounteredException: Could not decode XML
        at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:149)
        at brut.androlib.res.decoder.XmlPullStreamDecoder.decodeManifest(XmlPullStreamDecoder.java:155)
        at brut.androlib.res.decoder.ResFileDecoder.decodeManifest(ResFileDecoder.java:162)
        at brut.androlib.res.AndrolibResources.decodeManifestWithResources(AndrolibResources.java:204)
        at brut.androlib.Androlib.decodeManifestWithResources(Androlib.java:134)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:122)
        at brut.apktool.Main.cmdDecode(Main.java:179)
        at brut.apktool.Main.main(Main.java:82)
Caused by: java.io.IOException: Invalid chunk type (1310976).
        at brut.androlib.res.decoder.AXmlResourceParser.doNext(AXmlResourceParser.java:906)
        at brut.androlib.res.decoder.AXmlResourceParser.next(AXmlResourceParser.java:102)
        at brut.androlib.res.decoder.AXmlResourceParser.nextToken(AXmlResourceParser.java:112)
        at org.xmlpull.v1.wrapper.classic.XmlPullParserDelegate.nextToken(XmlPullParserDelegate.java:105)
        at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:142)
        ... 7 more

APK

https://drive.google.com/file/d/1R41rqSgkO9LtTZIR0h-cVpmAzj8qLVHv/view?usp=sharing

@iBotPeaches
Copy link
Owner

Confirmed. Marking as bug.

aapt can still read the resources, so must be improper decoding.

@ghost
Copy link

ghost commented Sep 6, 2021

Getting same issue
APK file: APK.zip

I: Using Apktool 2.6.0 on xxxx.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
Exception in thread "main" brut.androlib.err.RawXmlEncounteredException: Could not decode XML
	at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:145)
	at brut.androlib.res.decoder.XmlPullStreamDecoder.decodeManifest(XmlPullStreamDecoder.java:151)
	at brut.androlib.res.decoder.ResFileDecoder.decodeManifest(ResFileDecoder.java:159)
	at brut.androlib.res.AndrolibResources.decodeManifestWithResources(AndrolibResources.java:193)
	at brut.androlib.Androlib.decodeManifestWithResources(Androlib.java:140)
	at brut.androlib.ApkDecoder.decode(ApkDecoder.java:109)
	at brut.apktool.Main.cmdDecode(Main.java:175)
	at brut.apktool.Main.main(Main.java:78)
Caused by: java.io.IOException: Invalid chunk type (1310976).
	at brut.androlib.res.decoder.AXmlResourceParser.doNext(AXmlResourceParser.java:856)
	at brut.androlib.res.decoder.AXmlResourceParser.next(AXmlResourceParser.java:98)
	at brut.androlib.res.decoder.AXmlResourceParser.nextToken(AXmlResourceParser.java:108)
	at org.xmlpull.v1.wrapper.classic.XmlPullParserDelegate.nextToken(XmlPullParserDelegate.java:105)
	at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:138)
	... 7 more

@jnyavo
Copy link

jnyavo commented Apr 14, 2022

@parkerlreed
Copy link

Also seeing this with VMOS. Here's the manifest XML by itself.

AndroidManifest.xml.txt

@iBotPeaches
Copy link
Owner

Sorry for the few year delay. I dug into this with a fresher knowledge set of axml/arsc and it appears in this situation we have a namespace header that has an extra 4 bytes. In 99.99% of applications we see, its always 16 bytes so this must be a size technique to prevent decompilation.

Since it appears AOSP just reads what it knows after reading the entire headerSize into memory.

➜  2587 apktool d bug.apk -f                                                                                                
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
I: Using Apktool 2.8.2-22eb80-SNAPSHOT on bug.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
W: AXML header larger than 0x10 bytes, skipping 4 bytes.
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
➜  2587 

PR is #3210

@iBotPeaches iBotPeaches added this to the v2.8.2 milestone Jul 24, 2023
iBotPeaches added a commit that referenced this issue Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants