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

Issues with Dexguarded application(s) #913

Closed
Fuzion24 opened this Issue Apr 17, 2015 · 8 comments

Comments

Projects
None yet
3 participants
@Fuzion24

Fuzion24 commented Apr 17, 2015

tested on 2.0.0rc4 ::

W: Could not decode attr value, using undecoded value instead: ns=, name=name, value=0x0000000b
Exception in thread "main" java.lang.NullPointerException
    at java.io.Writer.write(Writer.java:157)
    at brut.androlib.res.util.ExtMXSerializer.writeAttributeValue(ExtMXSerializer.java:38)
    at org.xmlpull.mxp1_serializer.MXSerializer.attribute(MXSerializer.java:673)
    at org.xmlpull.v1.wrapper.classic.XmlSerializerDelegate.attribute(XmlSerializerDelegate.java:106)
    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:83)
    at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:141)
    at brut.androlib.res.decoder.ResStreamDecoderContainer.decode(ResStreamDecoderContainer.java:33)
    at brut.androlib.res.decoder.ResFileDecoder.decode(ResFileDecoder.java:114)
    at brut.androlib.res.decoder.ResFileDecoder.decode(ResFileDecoder.java:99)
    at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:339)
    at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:133)
    at brut.androlib.ApkDecoder.decode(ApkDecoder.java:104)
    at brut.apktool.Main.cmdDecode(Main.java:165)
    at brut.apktool.Main.main(Main.java:81)

androguard had similar issues that were patched here: androguard/androguard#85

This results in apktool not being able to properly decode versionCode/versionName for these apps

@dweinstein

This comment has been minimized.

Show comment
Hide comment
@dweinstein

dweinstein Apr 18, 2015

👍 would be nice

dweinstein commented Apr 18, 2015

👍 would be nice

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Apr 18, 2015

Owner

I had fixed this exact issue already - e126a51

Can you email me an apk that still experiences this? ibotpeaches @ gmail .com

Owner

iBotPeaches commented Apr 18, 2015

I had fixed this exact issue already - e126a51

Can you email me an apk that still experiences this? ibotpeaches @ gmail .com

@Fuzion24

This comment has been minimized.

Show comment
Hide comment
@Fuzion24

Fuzion24 Apr 19, 2015

e-mail sent.

Fuzion24 commented Apr 19, 2015

e-mail sent.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Apr 19, 2015

Owner

Hmm. Same issue as #882

Don't think it has anything to do with versionCode / versionName. Those seem fine to me. This is something else.

Owner

iBotPeaches commented Apr 19, 2015

Hmm. Same issue as #882

Don't think it has anything to do with versionCode / versionName. Those seem fine to me. This is something else.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches May 8, 2015

Owner

There is a huge influx of apps failing with this same error. Either a massive regression by my part or something else.

This has top priority now.

Owner

iBotPeaches commented May 8, 2015

There is a huge influx of apps failing with this same error. Either a massive regression by my part or something else.

This has top priority now.

@dweinstein

This comment has been minimized.

Show comment
Hide comment
@dweinstein

dweinstein May 9, 2015

did you see how I patched this on androguard? androguard/androguard#85

dweinstein commented May 9, 2015

did you see how I patched this on androguard? androguard/androguard#85

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches May 9, 2015

Owner

@dweinstein

This is a slightly different problem. I already handle the issue you encountered, by referencing the framework(s) if and when a Manifest entry is missing the value. You can see this here: https://github.com/iBotPeaches/Apktool/blob/master/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResAttrDecoder.java#L44

Instead of relying on a hardcoded list of values, we simply trust the frameworks the user has installed, so the user can update it, if need be, on a new AOSP release.

The problem at hand here, is quite weird. Lets take the Facebook APK for example. We get these two warnings

W: Could not decode attr value, using undecoded value instead: ns=internal, name=layout_maxHeight, value=0x00004001
W: Could not decode attr value, using undecoded value instead: ns=internal, name=layout_minHeight, value=0x00004001

Then a crash with.

Exception in thread "main" brut.androlib.err.UndefinedResObject: resource spec: 0x0101055c

Placing a breakpoint, it fails on this file - orca_chat_head_custom_notification.xml

We can leverage aapt and xmltree to see the file.

ibotpeaches@raganok:~/Downloads/Apktool/Bug913$ aapt d xmltree com.facebook.katana-34.0.0.0.242-10009638-minAPI14.apk res/layout/orca_chat_head_custom_notification.xml
N: android=http://schemas.android.com/apk/res/android
  N: internal=http://schemas.android.com/apk/prv/res/android
    E: FrameLayout (line=3)
      A: android:id(0x010100d0)=@0x7f090f1d
      A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
      A: android:layout_height(0x010100f5)=(type 0x5)0x4001
      A: internal:layout_maxHeight(0x0101055c)=(type 0x5)0x4001
      A: internal:layout_minHeight(0x0101055d)=(type 0x5)0x4001
      E: ImageView (line=11)

Theres our resources, but they are internal and not android namespaced. So it is encountering a warning when decoding the first internal resource. This is because it is trying to an attr decode on them, when they are internal attributes thus not needed to be looked up.

Owner

iBotPeaches commented May 9, 2015

@dweinstein

This is a slightly different problem. I already handle the issue you encountered, by referencing the framework(s) if and when a Manifest entry is missing the value. You can see this here: https://github.com/iBotPeaches/Apktool/blob/master/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResAttrDecoder.java#L44

Instead of relying on a hardcoded list of values, we simply trust the frameworks the user has installed, so the user can update it, if need be, on a new AOSP release.

The problem at hand here, is quite weird. Lets take the Facebook APK for example. We get these two warnings

W: Could not decode attr value, using undecoded value instead: ns=internal, name=layout_maxHeight, value=0x00004001
W: Could not decode attr value, using undecoded value instead: ns=internal, name=layout_minHeight, value=0x00004001

Then a crash with.

Exception in thread "main" brut.androlib.err.UndefinedResObject: resource spec: 0x0101055c

Placing a breakpoint, it fails on this file - orca_chat_head_custom_notification.xml

We can leverage aapt and xmltree to see the file.

ibotpeaches@raganok:~/Downloads/Apktool/Bug913$ aapt d xmltree com.facebook.katana-34.0.0.0.242-10009638-minAPI14.apk res/layout/orca_chat_head_custom_notification.xml
N: android=http://schemas.android.com/apk/res/android
  N: internal=http://schemas.android.com/apk/prv/res/android
    E: FrameLayout (line=3)
      A: android:id(0x010100d0)=@0x7f090f1d
      A: android:layout_width(0x010100f4)=(type 0x10)0xffffffff
      A: android:layout_height(0x010100f5)=(type 0x5)0x4001
      A: internal:layout_maxHeight(0x0101055c)=(type 0x5)0x4001
      A: internal:layout_minHeight(0x0101055d)=(type 0x5)0x4001
      E: ImageView (line=11)

Theres our resources, but they are internal and not android namespaced. So it is encountering a warning when decoding the first internal resource. This is because it is trying to an attr decode on them, when they are internal attributes thus not needed to be looked up.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches May 9, 2015

Owner

Okay, so doing attribute decoding on internal attributes is the problem.

A hacky patch later.

ibotpeaches@raganok:~/Downloads/Apktool/Bug913$ apktool d com.facebook.katana-34.0.0.0.242-10009638-minAPI14.apk -f
I: Using Apktool 2.0.1-1fb87e-SNAPSHOT on com.facebook.katana-34.0.0.0.242-10009638-minAPI14.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/ibotpeaches/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...
ibotpeaches@raganok:~/Downloads/Apktool/Bug913$ apktool b com.facebook.katana-34.0.0.0.242-10009638-minAPI14
I: Using Apktool 2.0.1-1fb87e-SNAPSHOT
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Copying libs... (/lib)
I: Building apk file...
I: Copying unknown files/dir...
ibotpeaches@raganok:~/Downloads/Apktool/Bug913$ 

:)

Have to clean it up (the patch) and make sure it works with ALL the apks that were submitted related to this bug.

Owner

iBotPeaches commented May 9, 2015

Okay, so doing attribute decoding on internal attributes is the problem.

A hacky patch later.

ibotpeaches@raganok:~/Downloads/Apktool/Bug913$ apktool d com.facebook.katana-34.0.0.0.242-10009638-minAPI14.apk -f
I: Using Apktool 2.0.1-1fb87e-SNAPSHOT on com.facebook.katana-34.0.0.0.242-10009638-minAPI14.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/ibotpeaches/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...
ibotpeaches@raganok:~/Downloads/Apktool/Bug913$ apktool b com.facebook.katana-34.0.0.0.242-10009638-minAPI14
I: Using Apktool 2.0.1-1fb87e-SNAPSHOT
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Copying libs... (/lib)
I: Building apk file...
I: Copying unknown files/dir...
ibotpeaches@raganok:~/Downloads/Apktool/Bug913$ 

:)

Have to clean it up (the patch) and make sure it works with ALL the apks that were submitted related to this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment