Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

[BUG] Resource decoding error.

Open Anonymous2716 opened this issue 3 years ago • 1 comments

Information

  1. Apktool Version (apktool -version) - 2.6.1
  2. Operating System (Mac, Linux, Windows) - Windows / Linux
  3. APK From? (Playstore, ROM, Other) - vmos.com

Stacktrace/Logcat

❯ apktool d base.apk -v -f --no-src
Aug 07, 2022 10:34:23 PM brut.androlib.ApkDecoder decode
INFO: Using Apktool 2.6.1-dirty on base.apk
Aug 07, 2022 10:34:24 PM brut.androlib.res.AndrolibResources loadMainPkg
INFO: Loading resource table...
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:24 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:25 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.decoder.ARSCDecoder readConfigFlags
FINE: Config flags size > 56, but exceeding bytes are all zero, so it should be ok.
Aug 07, 2022 10:34:26 PM brut.androlib.res.AndrolibResources decodeManifestWithResources
INFO: 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:141)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:109)
        at brut.apktool.Main.cmdDecode(Main.java:175)
        at brut.apktool.Main.main(Main.java:79)
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

APK

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

It happens only on resource decoding . with --no-res it decodes fine.

Anonymous2716 avatar Aug 07 '22 22:08 Anonymous2716

Odd. I replicate, but this is such a low level issue that suggests a new XML node type.

iBotPeaches avatar Aug 21 '22 17:08 iBotPeaches

Also seen here https://github.com/iBotPeaches/Apktool/issues/2587

Seems VMOS may be obfuscating their XML file?

parkerlreed avatar Feb 28 '23 22:02 parkerlreed

Same issue

I: Using Apktool 2.7.0 on Env145-Vip.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:164)
	at brut.androlib.res.AndrolibResources.decodeManifestWithResources(AndrolibResources.java:196)
	at brut.androlib.Androlib.decodeManifestWithResources(Androlib.java:145)
	at brut.androlib.ApkDecoder.decode(ApkDecoder.java:109)
	at brut.apktool.Main.cmdDecode(Main.java:175)
	at brut.apktool.Main.main(Main.java:79)
Caused by: java.io.IOException: Expected: 0x00080003 or 0x00080001, got: 0x0008b800
	at brut.util.ExtDataInput.skipCheckInt(ExtDataInput.java:45)
	at brut.androlib.res.decoder.AXmlResourceParser.doNext(AXmlResourceParser.java:834)
	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

apk

https://drive.google.com/file/d/1RqHKPlc_lQSQpgC5o8zU4p1ErWdM-eNQ/view

7z pass: apktool

4ft35t avatar Apr 20 '23 01:04 4ft35t

For the original issue - the decoding works now after

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

This was fixed during merge of: https://github.com/iBotPeaches/Apktool/pull/3210. It looks like decoding is the goal here as rebuilding with this malformed attributes is another effort, but at least for static analysis you can review application without Apktool crashing.

I'll make a new issue for comment here: https://github.com/iBotPeaches/Apktool/issues/2863#issuecomment-1515601225 as it continues to crash and is unrelated to this technique.

iBotPeaches avatar Jul 30 '23 17:07 iBotPeaches