Ayrx / axmldecoder

Decoder for the binary XML format used by Android.
Apache License 2.0
20 stars 10 forks source link

malformed `uses-permission` element #6

Closed ghost closed 2 years ago

ghost commented 2 years ago
doc: &XmlDocument
...
let root = doc.get_root().as_ref().unwrap();
...
for child in root.get_children() {
...
match child.get_tag() {
                "uses-permission" => {
...
        let permission = element
            .get_attributes()
            .get("android:name")  // here it crashes that the element have no android:name attribute

It says that parsed uses-permission tag have no android:name attribute but I tested the sample with jadx-gui and there all have the attribute.

sample: app.zip

Ayrx commented 2 years ago

I think jadx-gui does some normalisation on the attribute names because the attribute is actually encoded as name instead of android-name in the binary XML. You can use the axmldecoder-printer binary to confirm this.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="3110600" versionName="3.11.6" package="com.actionlauncher.playstore" platformBuildVersionCode="25" platformBuildVersionName="7.1.1">
  <uses-sdk minSdkVersion="16" targetSdkVersion="25"/>
  <uses-feature name="android.hardware.telephony" required="false"/>
  <uses-feature name="android.hardware.wifi" required="false"/>
  <uses-permission name="android.permission.INTERNET"/>
  <uses-permission name="android.permission.ACCESS_NETWORK_STATE"/>
  <uses-permission name="android.permission.CALL_PHONE"/>
  <uses-permission name="android.permission.SET_WALLPAPER"/>

Other parses like https://github.com/ytsutano/axmldec also confirm the same thing.

I'm gonna close this as a "won't fix" because I think I'd want an accurate representation of the binary format instead of adding in normalisation rules. Let me know if you disagree!

ghost commented 2 years ago

Why the android:name works for other samples?

Ayrx commented 2 years ago

Other samples had the ns field of the element set to android.