Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

ArrayIndexOutOfBoundsException (getUtf8)

Open JaredTamana opened this issue 5 years ago • 5 comments

Information

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

Stacktrace/Logcat

I: Using Apktool 2.4.1 on ArriveCAN_ca.gc.cbsa.coronavirus.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\jared\AppData\Local\apktool\framework\1.apk
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1741 out of bounds for length 1732
        at brut.androlib.res.decoder.StringBlock.getUtf8(StringBlock.java:317)
        at brut.androlib.res.decoder.StringBlock.getString(StringBlock.java:102)
        at brut.androlib.res.decoder.AXmlResourceParser.getName(AXmlResourceParser.java:176)
        at org.xmlpull.v1.wrapper.classic.XmlPullParserDelegate.getName(XmlPullParserDelegate.java:57)
        at brut.androlib.res.decoder.XmlPullStreamDecoder$1.event(XmlPullStreamDecoder.java:64)
        at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:142)
        at brut.androlib.res.decoder.XmlPullStreamDecoder.decodeManifest(XmlPullStreamDecoder.java:154)
        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:170)
        at brut.apktool.Main.main(Main.java:76)

Steps to Reproduce

  1. apktool d path\to\ArriveCAN.apk

Frameworks

APK is frameworkless

APK

https://drive.google.com/file/d/1LEPvU0LMp2AoBNHunoE4_xu4C809oppi/view?usp=sharing

Questions to ask before submission

1. Have you tried apktool d, apktool b without changing anything?

Not relevant as apktool d is the issue

2. If you are trying to install a modified apk, did you resign it?

Not relevant

3. Are you using the latest apktool version?

Yes


Attempting to do some decompilation of this app to see how it does system modification detection.

JaredTamana avatar Jul 18 '20 02:07 JaredTamana

Sorry for the delay. Took some time off. This file is no longer available and it looks like a crash in our UTF-8 parser and that won't be patchable without the example.

If you re-upload, just ping and I'll try and triage quicker.

Sorry.

iBotPeaches avatar Sep 13 '20 16:09 iBotPeaches

@iBotPeaches Sorry about that, here's a re-upload. https://drive.google.com/file/d/1ThMMW8SW_hYTqOU95mvZrY4TxSMu7zzc/view?usp=drivesdk

JaredTamana avatar Sep 13 '20 20:09 JaredTamana

Thanks, I got download. I will re-open till I can triage.

iBotPeaches avatar Sep 13 '20 20:09 iBotPeaches

I replicate. Adding "bug"

➜  2378 apktool d ArriveCAN_base.apk 
I: Using Apktool 2.4.2-987220-SNAPSHOT on ArriveCAN_base.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/1.apk
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3361
	at brut.androlib.res.decoder.StringBlock.getUtf8(StringBlock.java:317)
	at brut.androlib.res.decoder.StringBlock.getString(StringBlock.java:102)
	at brut.androlib.res.decoder.AXmlResourceParser.getAttributeValue(AXmlResourceParser.java:387)
	at org.xmlpull.v1.wrapper.classic.XmlPullParserDelegate.getAttributeValue(XmlPullParserDelegate.java:69)
	at org.xmlpull.v1.wrapper.classic.StaticXmlSerializerWrapper.writeStartTag(StaticXmlSerializerWrapper.java:267)
	at org.xmlpull.v1.wrapper.classic.StaticXmlSerializerWrapper.event(StaticXmlSerializerWrapper.java:211)
	at brut.androlib.res.decoder.XmlPullStreamDecoder$1.event(XmlPullStreamDecoder.java:84)
	at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:143)
	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:171)
	at brut.apktool.Main.main(Main.java:77)
➜  2378 

iBotPeaches avatar Nov 27 '20 15:11 iBotPeaches

Resources in this file obfuscated... it is not strange that an error occurs.

MrIkso avatar Nov 30 '20 20:11 MrIkso

This was resolved when I restructured the StringBlock parser in here: https://github.com/iBotPeaches/Apktool/pull/3239

➜  2378 apktool d ArriveCAN_base.apk -s -f
I: Using Apktool v2.8.1-38-e6e577fa-SNAPSHOT on ArriveCAN_base.apk
I: Loading resource table...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/1.apk
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
➜  2378 

Will be resolved in 2.8.2 release

iBotPeaches avatar Aug 08 '23 10:08 iBotPeaches