iBotPeaches / Apktool

A tool for reverse engineering Android apk files
https://apktool.org/
Apache License 2.0
20.27k stars 3.59k forks source link

[BUG] Chunk [end] is not a valid entry #2890

Open Skylled opened 2 years ago

Skylled commented 2 years ago

Information

  1. Apktool Version (apktool -version) - 2.6.1
  2. Operating System (Mac, Linux, Windows) - Mac (also reproduced on Windows)
  3. APK From? (Playstore, ROM, Other) - Play Store

Stacktrace/Logcat

I: Using Apktool 2.6.1 on com.google.android.googlequicksearchbox_13.36.8.29.arm64.apk
I: Loading resource table...
Exception in thread "main" java.lang.IllegalArgumentException: Chunk [end] is not a valid entry
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:220)
    at com.google.common.base.Splitter$MapSplitter.split(Splitter.java:528)
    at brut.androlib.res.decoder.StringBlock$Tag.toString(StringBlock.java:167)
    at java.base/java.lang.String.valueOf(String.java:4213)
    at java.base/java.lang.StringBuilder.append(StringBuilder.java:173)
    at brut.androlib.res.decoder.StringBlock.processStyledString(StringBlock.java:260)
    at brut.androlib.res.decoder.StringBlock.getHTML(StringBlock.java:288)
    at brut.androlib.res.decoder.ARSCDecoder.readValue(ARSCDecoder.java:366)
    at brut.androlib.res.decoder.ARSCDecoder.readEntryData(ARSCDecoder.java:285)
    at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:261)
    at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:184)
    at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:135)
    at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:84)
    at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:50)
    at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:783)
    at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:64)
    at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:56)
    at brut.androlib.Androlib.getResTable(Androlib.java:70)
    at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:247)
    at brut.androlib.ApkDecoder.decode(ApkDecoder.java:109)
    at brut.apktool.Main.cmdDecode(Main.java:175)
    at brut.apktool.Main.main(Main.java:79)

Steps to Reproduce

  1. apktool d google-app.apk

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files (.apks that live in /system/framework or /system/priv-app)

APK

If this APK can be freely shared, please upload/attach a link to it. We've only reproduced the issue on the latest builds of the Google Search app, and only on the 13.x.x.29 builds used by Pixel phones which presumably have different resources.

Last known-good version: https://www.apkmirror.com/apk/google-inc/google-search/google-search-13-35-9-release/google-app-13-35-9-29-arm64-2-android-apk-download/

Most recent known-bad version: https://www.apkmirror.com/apk/google-inc/google-search/google-search-13-37-9-release/google-app-13-37-9-29-arm64-2-android-apk-download/

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? - Yes
  2. If you are trying to install a modified apk, did you resign it? - N/A
  3. Are you using the latest apktool version? - Yes

Debugging details

My colleague was able to trace the string resource at fault to this one. However, we're not sure why there's now a problem as the same string also appears in the known-good version.

<string name="assistant_dictation_ineligible_android_old_version">To use Assistant voice typing, update your Android System. <a href=intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end> Update </a> <br/><br/><a href=https://support.google.com/gboard/answer/11197787#update_app> Learn more </a></string>
Skylled commented 2 years ago

Possible duplicate of #2675

iBotPeaches commented 2 years ago

thanks - I took a look and the actual string affected is this:

a;href=intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end

This is double ;end is messing up the parser - going to have to research why that is.

iBotPeaches commented 2 years ago

O apologies. That is literally the string you posted. I didn't scroll it left/right.

iBotPeaches commented 2 years ago

Working app

➜  2890 aapt2 dump resources 2890-good.apk | grep 'SYSTEM_UPDATE'
      () "To use Assistant voice typing, update your Android System. <a href=intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end>Update</a> <br> <br><a href=https://support.google.com/gboard/answer/11197787#update_app>Learn more</a>"
      (ca) "Per utilitzar l'escriptura per veu amb l'Assistent, actualitza el teu sistema Android. <a href="intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end">Actualitza</a> <br> <br><a href="https://support.google.com/gboard/answer/11197787#update_app">Més informació</a>"

Broken app

➜  2890 aapt2 dump resources 2890.apk | grep 'SYSTEM_UPDATE'  
      () "To use Assistant voice typing, update your Android System. <a href=intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end> Update </a> <br/><br/><a href=https://support.google.com/gboard/answer/11197787#update_app> Learn more </a>"
      (ca) (styled string) "Per utilitzar l'escriptura per veu amb l'Assistent, actualitza el teu sistema Android.  Actualitza   Més informació " a;href=intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end:87,98 br:100,99 br:100,99 a;href=https://support.google.com/gboard/answer/11197787#update_app:100,115

Lots o differences. @IgorEisberg any idea how we could patch the splitter to handle basically intent based urls? Sadly I noticed the test suite has basically no coverage for these type of URLs.

egor-eremeev commented 1 year ago

Got the same issue, got any progress?

0x4c756e61 commented 8 months ago

Any progress here ?

REAndroid commented 5 months ago

@iBotPeaches I checked both files I may miss something or files changed now ? Here is md5 for files i downloaded:

Here is what I get for string containing SYSTEM_UPDATE_SETTINGS

So this string on both files is NOT styled string, why are you trying to process it as styled string ?

BTW: Forgive me I am a strong hater of guava & kotlin, both useless worms.

iBotPeaches commented 5 months ago

@REAndroid - Good question, I guess you get so focused on something you might overlook the fact you are mistyping it as styled.