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

ArrayIndexOutOfBoundsException (getUtf8) #2378

Closed
JaredTamana opened this issue Jul 18, 2020 · 6 comments
Closed

ArrayIndexOutOfBoundsException (getUtf8) #2378

JaredTamana opened this issue Jul 18, 2020 · 6 comments

Comments

@JaredTamana
Copy link

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.

@iBotPeaches
Copy link
Owner

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.

@JaredTamana
Copy link
Author

@iBotPeaches
Copy link
Owner

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

@iBotPeaches iBotPeaches reopened this Sep 13, 2020
@iBotPeaches
Copy link
Owner

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 iBotPeaches changed the title ArrayIndexOutOfBounds on ArriveCAN Decompilation ArrayIndexOutOfBoundsException (getUtf8) Nov 29, 2020
@MrIkso
Copy link
Contributor

MrIkso commented Nov 30, 2020

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

@iBotPeaches
Copy link
Owner

This was resolved when I restructured the StringBlock parser in here: #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 iBotPeaches added this to the v2.8.2 milestone Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants