Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

[BUG] APK doesn't decompile

Open timea-techgirl opened this issue 4 years ago • 3 comments

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

timea-techgirl avatar Jun 14 '21 20:06 timea-techgirl

Confirmed. Marking as bug.

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

iBotPeaches avatar Jun 20 '21 11:06 iBotPeaches

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

ghost avatar Sep 06 '21 10:09 ghost

Same issue here

https://files.vmos.cn/vmospro/version/2022021911283769073_Overseas.apk

jnyavo avatar Apr 14 '22 17:04 jnyavo

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

AndroidManifest.xml.txt

parkerlreed avatar Feb 28 '23 22:02 parkerlreed

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 https://github.com/iBotPeaches/Apktool/pull/3210

iBotPeaches avatar Jul 24 '23 00:07 iBotPeaches