broo2s / brut.apktool

A tool for reverse engineering Android apk files
http://code.google.com/p/android-apktool/
351 stars 118 forks source link

ResFileDecoder is incorrectly parsing attributes for some APKs #27

Open Fuzion24 opened 10 years ago

Fuzion24 commented 10 years ago

As you can see below some of the attribute names are missing:

    <application ="@android:style/Theme.NoTitleBar" ="@com.margenelampson85.MusicBillboardTop100:string/app_name" ="@com.margenelampson85.MusicBillboardTop100:drawable/icon" ="orientation" ="true" ="true">
        <activity ="ZyAlUlOyFBtFPeJaoSTaHxcbnjdosjFs" />
        <activity ="gDCrrbXTuDJymJMfDNMaQOnZRCsaiKIo" />
        <activity ="kGFmEzGhiftSSyvFlwvZJvQmNRuxAJLL" />
        <activity ="rXTQEaZJuSBTnheKCdtXUGLMajnKUYZm" />
        <activity ="TdzUdjoVKhjRmTuqnslTeYUnlEijDufx" />
        <activity ="FrBOGwzNGrazMqMfBGjzAwLeFVIZafxG" />
        <activity ="YvdvVRbmRBZhneJTnjuKUypPhpQnNwKM" />

The above is the result of this decoding the following apk: 00fc1fb656155bde989ae0391041de5a41185e27 (I just named it as a .png, so github will let me upload it; it's a .zip)

This is a valid APK that installs.

Jeb also seems to handle it properly (although the attributes are not namespaced properly):

    <application allowBackup="true" configChanges="orientation" hardwareAccelerated="true" icon="@drawable/icon" label="@string/app_name" theme="@android:style/Theme.NoTitleBar">
        <activity name="ZyAlUlOyFBtFPeJaoSTaHxcbnjdosjFs" />
        <activity name="gDCrrbXTuDJymJMfDNMaQOnZRCsaiKIo" />
        <activity name="kGFmEzGhiftSSyvFlwvZJvQmNRuxAJLL" />
        <activity name="rXTQEaZJuSBTnheKCdtXUGLMajnKUYZm" />
        <activity name="TdzUdjoVKhjRmTuqnslTeYUnlEijDufx" />
        <activity name="FrBOGwzNGrazMqMfBGjzAwLeFVIZafxG" />
        <activity name="YvdvVRbmRBZhneJTnjuKUypPhpQnNwKM" />
        <activity name="NhNEjZvKZDYdnSrwmcrLsgSHXgvuQhmE" />
        <activity name="ZiyZEjYiicvauSnwjZPqSwnYSHOZUspT" />
        <activity name="OSgXRpfTKgoDuKMtzclWqjOYYOSrdMTR" />
        <activity name="aPwpVqZbECwppPPsbLIlAGjpzBtlvlQv" />
iBotPeaches commented 10 years ago

I believe its a duplicate of this: http://code.google.com/p/android-apktool/issues/detail?id=512

I wonder if JEB still uses Apktool internally, or if its modified so much that it doesn't match upstream apktool anymore.

Point being, I started investigating this. When it pulls the length from the next attribute it gets 0. The length it wants is +- 4 bytes from the location it is currently reading at. This only happens on certain APKs so not sure where the mistake is occurring, but I'm getting closer to fixing this.