Skip to content
This repository was archived by the owner on Jul 27, 2024. It is now read-only.

Commit f3feecc

Browse files
authored
Fix issue #60 + fix obfuscation res/xml folder (#61)
fix MethodRename invocations of ignored classes, add res/xml folder to ClassRename
1 parent f161304 commit f3feecc

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/obfuscapk/obfuscators/class_rename/class_rename.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def transform_package_name(self, manifest_xml_root: Element):
5454
self.encrypted_package_name = ".".join(
5555
[self.encrypt_identifier(token) for token in self.package_name.split(".")]
5656
)
57-
57+
5858
# Rename package name in manifest file.
5959
manifest_xml_root.set("package", self.encrypted_package_name)
6060
manifest_xml_root.set(
@@ -314,7 +314,7 @@ def obfuscate(self, obfuscation_info: Obfuscation):
314314
obfuscation_info.get_resource_directory()
315315
)
316316
for file_name in file_names
317-
if file_name.endswith(".xml") and "layout" in root # Only layout files.
317+
if file_name.endswith(".xml") and ("layout" in root or "xml" in root) # Only res/layout-*/ and res/xml-*/ folders.
318318
)
319319
xml_files.add(obfuscation_info.get_manifest_file())
320320

src/obfuscapk/obfuscators/method_rename/method_rename.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def rename_method_invocations(
166166
smali_files: List[str],
167167
methods_to_rename: Set[str],
168168
android_class_names: Set[str],
169+
classes_to_ignore: List[str],
169170
interactive: bool = False,
170171
):
171172
for smali_file in util.show_list_progress(
@@ -192,6 +193,7 @@ def rename_method_invocations(
192193
("direct" in invoke_type or "static" in invoke_type)
193194
and method in methods_to_rename
194195
and class_name not in android_class_names
196+
and not any(cls in class_name for cls in classes_to_ignore)
195197
):
196198
method_name = invoke_match.group("invoke_method")
197199
out_file.write(
@@ -233,7 +235,8 @@ def obfuscate(self, obfuscation_info: Obfuscation):
233235
obfuscation_info.get_smali_files(),
234236
renamed_methods,
235237
android_class_names,
236-
obfuscation_info.interactive,
238+
util.get_libs_to_ignore(),
239+
obfuscation_info.interactive
237240
)
238241

239242
except Exception as e:

0 commit comments

Comments
 (0)