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

null TypeSpec in resources.arsc #1185

Closed
DoctorQ opened this Issue Mar 7, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@DoctorQ

DoctorQ commented Mar 7, 2016

Msg

apktool d com.wuba_6.6.1.1_6611.apk 
I: Using Apktool 2.0.3 on com.wuba_6.6.1.1_6611.apk
I: Loading resource table...
Exception in thread "main" java.lang.NullPointerException
    at brut.androlib.res.data.ResTypeSpec.isString(ResTypeSpec.java:57)
    at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:226)
    at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:212)
    at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:154)
    at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:116)
    at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:78)
    at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:47)
    at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:544)
    at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:63)
    at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:55)
    at brut.androlib.Androlib.getResTable(Androlib.java:66)
    at brut.androlib.ApkDecoder.setTargetSdkVersion(ApkDecoder.java:198)
    at brut.androlib.ApkDecoder.decode(ApkDecoder.java:96)
    at brut.apktool.Main.cmdDecode(Main.java:165)
    at brut.apktool.Main.main(Main.java:81)

@iBotPeaches iBotPeaches changed the title from NullPointException to null TypeSpec in resources.arsc Mar 7, 2016

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Mar 7, 2016

Owner

Yeah this is a far bigger problem, the NPE on the String is just the outcome. The first TypeSpec read is NULL. This isn't a valid type according to apktool. I will have to cross reference AAPT and see if I'm missing a type.

OR

This is a new type of obfuscation in which case I should just ignore these NULL TypeSpecs. I haven't tested the APK yet though to see how Android reads it.

Owner

iBotPeaches commented Mar 7, 2016

Yeah this is a far bigger problem, the NPE on the String is just the outcome. The first TypeSpec read is NULL. This isn't a valid type according to apktool. I will have to cross reference AAPT and see if I'm missing a type.

OR

This is a new type of obfuscation in which case I should just ignore these NULL TypeSpecs. I haven't tested the APK yet though to see how Android reads it.

@iBotPeaches iBotPeaches added this to the 2.2.0 milestone Aug 1, 2016

@iBotPeaches

This comment has been minimized.

Show comment
Hide comment
@iBotPeaches

iBotPeaches Aug 1, 2016

Owner

Sorry for delay. Started working on this and the TypeSpec expected format is 0 and up, to max byte size. Though we can see the original property is an unsigned byte - https://github.com/android/platform_frameworks_base/blob/master/include/androidfw/ResourceTypes.h#L1278

So the first type index is 128, but then it improperly becomes -127 which doesn't exist in the index pool, thus becomes null thus crashes.

Need to convert calls to readUnsignedByte and update the tool to handle it for that property.

Owner

iBotPeaches commented Aug 1, 2016

Sorry for delay. Started working on this and the TypeSpec expected format is 0 and up, to max byte size. Though we can see the original property is an unsigned byte - https://github.com/android/platform_frameworks_base/blob/master/include/androidfw/ResourceTypes.h#L1278

So the first type index is 128, but then it improperly becomes -127 which doesn't exist in the index pool, thus becomes null thus crashes.

Need to convert calls to readUnsignedByte and update the tool to handle it for that property.

iBotPeaches added a commit that referenced this issue Aug 2, 2016

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