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

Commit 31ee0f9

Browse files
committed
const_string_encryption: Fix problem where static constructor not correctly found
The current code expects that static constructors are declared as: .method static constructor <clinit>()V However, static constructors in smali files may contain the "public" keyword so the static constructor has the form: .method public static constructor <clinit>()V The current code doesn't find such constructors and inserts another static constructor to the code instead so there are 2 static constructors. Smali seems to use only the first declared constructor (with the string initializers) and ignores the second one with the original initialization code which leads to uninitialized static members. This patch simply relaxes the check of static constructors so there can be an arbitrary string (including empty string) between ".method" and "static".
1 parent 8637197 commit 31ee0f9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/obfuscapk/obfuscators/const_string_encryption/const_string_encryption.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def obfuscate(self, obfuscation_info: Obfuscation):
110110
direct_methods_line = line_number
111111
continue
112112

113-
if line.startswith(".method static constructor <clinit>()V"):
113+
if line.startswith(".method") and line.strip().endswith("static constructor <clinit>()V"):
114114
static_constructor_line = line_number
115115
continue
116116

0 commit comments

Comments
 (0)