Skip to content

Commit

Permalink
Support additional edge cases in binary XML decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Aug 27, 2023
1 parent cd1e726 commit b9bed89
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 475 deletions.
8 changes: 3 additions & 5 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
def asmVersion = '9.5'
def cafeDudeVersion = '1.10.2'
def junitVersion = '5.9.2'
def androidToolsVersion = '31.2.0-alpha09'

project.ext {
asm = "org.ow2.asm:asm:$asmVersion"
Expand All @@ -10,9 +9,8 @@ project.ext {
asm_tree = "org.ow2.asm:asm-tree:$asmVersion"
asm_util = "org.ow2.asm:asm-util:$asmVersion"

android_common = "com.android.tools:common:$androidToolsVersion"
apk_analyzer = "com.android.tools.apkparser:apkanalyzer:$androidToolsVersion"
binary_resources = "com.android.tools.apkparser:binary-resources:$androidToolsVersion"
// Use our fork of Android's release with fixes and less transitive dependencies
binary_resources = 'com.github.Col-E:binary-resources:31.3.0-alpha01.2'

atlantafx = 'io.github.mkpaz:atlantafx-base:2.0.0'

Expand All @@ -23,7 +21,7 @@ project.ext {
cdi_api = 'jakarta.enterprise:jakarta.enterprise.cdi-api:4.0.1'
cdi_impl = 'org.jboss.weld.se:weld-se-core:5.1.0.Final'

dex_translator = 'software.coley:dex-translator:1.1.0'
dex_translator = 'software.coley:dex-translator:1.1.1'

directories = 'dev.dirs:directories:26'
docking = 'com.github.Col-E:tiwulfx-dock:1.2.3'
Expand Down
13 changes: 1 addition & 12 deletions recaf-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,12 @@ apply plugin: 'java-library'
apply plugin: 'java-test-fixtures'

dependencies {
api(android_common) {
exclude group: 'net.java.dev.jna'
exclude group: 'org.jetbrains.kotlin'
exclude group: 'com.android.tools'
}
api(apk_analyzer) {
exclude group: 'com.android.tools.smali'
exclude group: 'com.android.tools'
}
api(binary_resources) {
exclude group: 'com.android.tools'
}
api asm
api asm_analysis
api asm_commons
api asm_tree
api asm_util
api binary_resources
api cafedude
api cdi_api
api(dex_translator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public BasicArscFileInfo(ArscFileInfoBuilder builder) {
@Override
public AndroidRes getResourceInfo() {
if (res == null)
res = AndroidRes.fromArsc(this);
res = AndroidRes.fromArsc(getChunkModel());
return res;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package software.coley.recaf.util.android;

import org.checkerframework.checker.units.qual.N;
import software.coley.recaf.util.ByteHeaderUtil;

/**
* Hacky utils for Android chunk utils.
*
* @author Matt Coley
*/
public class AndroidChunkUtil {
private static int[] EMPTY_HEADER = new int[2];
private static int[] ANDROID_PERMISSION = new int[]{
'a', 'n', 'd', 'r', 'o', 'i', 'd', '.',
'p', 'e', 'r', 'm', 'i', 's', 's', 'i', 'o', 'n'
};
private static int[] INTENT_FILTER = new int[]{
'i', 'n', 't', 'e', 'n', 't', '-',
'f', 'i', 'l', 't', 'e', 'r'
};

/**
* @param data
* Data to check.
*
* @return {@code true} if likely obscured XML chunk model.
*/
public static boolean isObscuredXml(@N byte[] data) {
return ByteHeaderUtil.match(data, EMPTY_HEADER) &&
(ByteHeaderUtil.matchAtAnyOffset(data, ANDROID_PERMISSION) ||
ByteHeaderUtil.matchAtAnyOffset(data, INTENT_FILTER));
}
}

This file was deleted.

Loading

0 comments on commit b9bed89

Please sign in to comment.