diff --git a/androscalpel/src/dex_writer.rs b/androscalpel/src/dex_writer.rs index 2fa9509..59c2e4c 100644 --- a/androscalpel/src/dex_writer.rs +++ b/androscalpel/src/dex_writer.rs @@ -1662,13 +1662,13 @@ impl DexWriter { let mut static_fields: Vec = class.static_fields.keys().cloned().collect(); static_fields.sort(); let mut array = vec![]; - let mut last_defined_field_idx = 0; + let mut last_defined_field_index = 0; for (idx, f) in static_fields.iter().enumerate() { if class.static_fields.get(f).unwrap().value.is_some() { - last_defined_field_idx = idx; + last_defined_field_index = idx; } } - for f in &static_fields[..last_defined_field_idx] { + for f in &static_fields[..=last_defined_field_index] { let field = class.static_fields.get(f).unwrap(); if let Some(val) = field.value.as_ref() { array.push(val.clone()); diff --git a/test.py b/test.py index cb3417a..4206ca8 100644 --- a/test.py +++ b/test.py @@ -67,12 +67,13 @@ classes = list( IdType("Lcom/example/testapplication/ui/home/HomeViewModel;"), IdType("Landroidx/navigation/NavDeepLink$Builder;"), IdType("Landroidx/constraintlayout/core/widgets/ConstraintWidget$1;"), + IdType("Landroidx/appcompat/app/ActionBar;"), ], apk.classes.keys(), ) ) -for cls in classes: - apk.remove_class(cls) +# for cls in classes: +# apk.remove_class(cls) print("[+] Recompile") @@ -94,9 +95,13 @@ for dex in dex_raw: # apksigner=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "apksigner", # ) +last_id = None + +MAX_REQ = 1 + def cmp(a, b, req=0): - if req > 6: + if req > MAX_REQ: return if type(a) == dict: cmp_dict(a, b, req) @@ -116,10 +121,15 @@ def nice_bool(b) -> str: def cmp_other(a, b, req=0): ident = " " * req for f in dir(a): - if getattr(getattr(a, f), "__call__", None) is None: + if getattr(getattr(a, f), "__call__", None) is None and ( + len(f) < 2 or f[:2] != "__" + ): eq = getattr(a, f) == getattr(b, f) print(f"{f'{ident}{f}: ':<150}{nice_bool(eq)}") if not eq: + if "descriptor" in dir(a): + global last_id + last_id = a.descriptor cmp(getattr(a, f), getattr(b, f), req + 1) @@ -133,6 +143,8 @@ def cmp_dict(a, b, req=0): eq = a[key] == b[key] print(f"{f'{ident}{str(key)}: ':<150}{nice_bool(eq)}") if not eq: + global last_id + last_id = a.descriptor cmp(a[key], b[key], req + 1)