can not decoding resource #1170

Closed
refgd opened this Issue Feb 25, 2016 · 11 comments

Comments

Projects
None yet
4 participants
@refgd

refgd commented Feb 25, 2016

can not decoding resource after use AndResGuard

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Feb 25, 2016

Owner

Not a very helpful report here. You don't show what its crashing on nor provide a stacktrace, apk or anything.

If you attach more, we can re-open this.

Owner

iBotPeaches commented Feb 25, 2016

Not a very helpful report here. You don't show what its crashing on nor provide a stacktrace, apk or anything.

If you attach more, we can re-open this.

@refgd

This comment has been minimized.

Show comment
Hide comment
@refgd

refgd Feb 25, 2016

this is my apk http://dl-xda.xposed.info/modules/com.skyolin.helper_v103_b97429.apk (http://repo.xposed.info/module/com.skyolin.helper)
I have use AndResGuard encode the resource, just move resource package res/* to r/*.
apktool not decode "r" folder, it move them to unknow.
and I can not rebuilt it by apktool

refgd commented Feb 25, 2016

this is my apk http://dl-xda.xposed.info/modules/com.skyolin.helper_v103_b97429.apk (http://repo.xposed.info/module/com.skyolin.helper)
I have use AndResGuard encode the resource, just move resource package res/* to r/*.
apktool not decode "r" folder, it move them to unknow.
and I can not rebuilt it by apktool

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Feb 25, 2016

Owner

Does Android accept an application where the resource folder has been moved to /r? Is this a valid use case?

Owner

iBotPeaches commented Feb 25, 2016

Does Android accept an application where the resource folder has been moved to /r? Is this a valid use case?

@refgd

This comment has been minimized.

Show comment
Hide comment
@refgd

refgd Feb 25, 2016

Yes, I tried in different devices and android versions. The apk running prefect.
20160225141858

image

refgd commented Feb 25, 2016

Yes, I tried in different devices and android versions. The apk running prefect.
20160225141858

image

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Feb 25, 2016

Owner

Learning new things every day. Had no idea that was supported.

Owner

iBotPeaches commented Feb 25, 2016

Learning new things every day. Had no idea that was supported.

@iBotPeaches iBotPeaches reopened this Feb 25, 2016

@iBotPeaches iBotPeaches added the Bug label Feb 25, 2016

@quangteo0801

This comment has been minimized.

Show comment
Hide comment
@quangteo0801

quangteo0801 Feb 27, 2016

File not found: framework-res_source_from_JADX/classes.dexframework-res_source_from_JADX/classes.dex
Why?/?/ Can you help me?

File not found: framework-res_source_from_JADX/classes.dexframework-res_source_from_JADX/classes.dex
Why?/?/ Can you help me?

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Feb 27, 2016

Owner

Confirmed on my Nexus 5. This APK installs fine. Need to add support for res & r at the same time. Much like what we do for libs & lib expect more complicated.

@quangteo0801 Please open your own report with more details.

Owner

iBotPeaches commented Feb 27, 2016

Confirmed on my Nexus 5. This APK installs fine. Need to add support for res & r at the same time. Much like what we do for libs & lib expect more complicated.

@quangteo0801 Please open your own report with more details.

@iBotPeaches iBotPeaches added this to the 2.1.0 milestone Mar 9, 2016

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 9, 2016

Owner

Did some testing to under AndroResGuard. Besides a sad fact that the Sourcecode is Apktool's with the copyright removed :(

I made a test apk and ran it through.

res path mapping:
    res/mipmap-xxhdpi-v4 -> r/a
    res/xml -> r/b
    res/mipmap-xhdpi-v4 -> r/c
    res/mipmap-mdpi-v4 -> r/d
    res/mipmap-hdpi-v4 -> r/e
    res/mipmap-xxxhdpi-v4 -> r/f


res id mapping:
    com.ibotpeaches.issue1170.R.attr.bar -> com.ibotpeaches.issue1170.R.attr.a
    com.ibotpeaches.issue1170.R.attr.bat -> com.ibotpeaches.issue1170.R.attr.b
    com.ibotpeaches.issue1170.R.attr.baz -> com.ibotpeaches.issue1170.R.attr.c
    com.ibotpeaches.issue1170.R.mipmap.ic_launcher -> com.ibotpeaches.issue1170.R.mipmap.a
    com.ibotpeaches.issue1170.R.xml.custom -> com.ibotpeaches.issue1170.R.xml.a
    com.ibotpeaches.issue1170.R.string.app_name -> com.ibotpeaches.issue1170.R.string.a

Or easier to see

➜  outapk git:(master) ✗ aapt d strings input.apk 
String pool of 7 unique UTF-8 non-sorted strings, 7 entries and 0 styles using 280 bytes:
String #0: res/xml/custom.xml
String #1: res/mipmap-mdpi-v4/ic_launcher.png
String #2: res/mipmap-hdpi-v4/ic_launcher.png
String #3: res/mipmap-xhdpi-v4/ic_launcher.png
String #4: res/mipmap-xxhdpi-v4/ic_launcher.png
String #5: res/mipmap-xxxhdpi-v4/ic_launcher.png
String #6: Issue1157
➜  outapk git:(master) ✗ aapt d strings input_unsigned.apk 
String pool of 7 unique UTF-8 non-sorted strings, 7 entries and 0 styles using 140 bytes:
String #0: r/b/a.xml
String #1: r/d/a.png
String #2: r/e/a.png
String #3: r/c/a.png
String #4: r/a/a.png
String #5: r/f/a.png
String #6: Issue1157
➜  outapk git:(master) ✗ 

It works by simply renaming the expected filepath of a resource. Apktool fails because it expects them at res/. Apktool will decode the resources, but in doing so moves them back to res/. Apktool cannot rebuild the application with them at /r. However, this breaks apktool mantra of matching the original application as close as possible.

This means I need to keep the original broken behaviour under -m. I also need a unit test.

Owner

iBotPeaches commented Mar 9, 2016

Did some testing to under AndroResGuard. Besides a sad fact that the Sourcecode is Apktool's with the copyright removed :(

I made a test apk and ran it through.

res path mapping:
    res/mipmap-xxhdpi-v4 -> r/a
    res/xml -> r/b
    res/mipmap-xhdpi-v4 -> r/c
    res/mipmap-mdpi-v4 -> r/d
    res/mipmap-hdpi-v4 -> r/e
    res/mipmap-xxxhdpi-v4 -> r/f


res id mapping:
    com.ibotpeaches.issue1170.R.attr.bar -> com.ibotpeaches.issue1170.R.attr.a
    com.ibotpeaches.issue1170.R.attr.bat -> com.ibotpeaches.issue1170.R.attr.b
    com.ibotpeaches.issue1170.R.attr.baz -> com.ibotpeaches.issue1170.R.attr.c
    com.ibotpeaches.issue1170.R.mipmap.ic_launcher -> com.ibotpeaches.issue1170.R.mipmap.a
    com.ibotpeaches.issue1170.R.xml.custom -> com.ibotpeaches.issue1170.R.xml.a
    com.ibotpeaches.issue1170.R.string.app_name -> com.ibotpeaches.issue1170.R.string.a

Or easier to see

➜  outapk git:(master) ✗ aapt d strings input.apk 
String pool of 7 unique UTF-8 non-sorted strings, 7 entries and 0 styles using 280 bytes:
String #0: res/xml/custom.xml
String #1: res/mipmap-mdpi-v4/ic_launcher.png
String #2: res/mipmap-hdpi-v4/ic_launcher.png
String #3: res/mipmap-xhdpi-v4/ic_launcher.png
String #4: res/mipmap-xxhdpi-v4/ic_launcher.png
String #5: res/mipmap-xxxhdpi-v4/ic_launcher.png
String #6: Issue1157
➜  outapk git:(master) ✗ aapt d strings input_unsigned.apk 
String pool of 7 unique UTF-8 non-sorted strings, 7 entries and 0 styles using 140 bytes:
String #0: r/b/a.xml
String #1: r/d/a.png
String #2: r/e/a.png
String #3: r/c/a.png
String #4: r/a/a.png
String #5: r/f/a.png
String #6: Issue1157
➜  outapk git:(master) ✗ 

It works by simply renaming the expected filepath of a resource. Apktool fails because it expects them at res/. Apktool will decode the resources, but in doing so moves them back to res/. Apktool cannot rebuild the application with them at /r. However, this breaks apktool mantra of matching the original application as close as possible.

This means I need to keep the original broken behaviour under -m. I also need a unit test.

iBotPeaches added a commit to iBotPeaches/TestApks that referenced this issue Mar 10, 2016

@refgd

This comment has been minimized.

Show comment
Hide comment
@refgd

refgd Mar 10, 2016

Can you add a command option for this or read the mapping from layouts.xml? because it is a mapping, this mean can change "r" to anything. Thank you.

refgd commented Mar 10, 2016

Can you add a command option for this or read the mapping from layouts.xml? because it is a mapping, this mean can change "r" to anything. Thank you.

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 10, 2016

Owner

I don't want to add a parameter that is specific to a type of obfuscation. So currently that is not on my radar of things to add.

Owner

iBotPeaches commented Mar 10, 2016

I don't want to add a parameter that is specific to a type of obfuscation. So currently that is not on my radar of things to add.

@simpleton

This comment has been minimized.

Show comment
Hide comment
@simpleton

simpleton Nov 11, 2016

@iBotPeaches I'm the maintainer of AndResGuard,sorry for removing license. I'm not very familiar with open source license rules when I copy the source from Apktool. I hope you will accept my sincere apologies. I'll add your license in the files which copy from Apktool immediately.

Feel free to contact me if there's any problem with your copyright.

BTW, thanks for your repo, it help me a lot.

@iBotPeaches I'm the maintainer of AndResGuard,sorry for removing license. I'm not very familiar with open source license rules when I copy the source from Apktool. I hope you will accept my sincere apologies. I'll add your license in the files which copy from Apktool immediately.

Feel free to contact me if there's any problem with your copyright.

BTW, thanks for your repo, it help me a lot.

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