feat: specific files only using annotations
parent
efc9b54413
commit
c5f0a86501
|
@ -1 +1,2 @@
|
||||||
|
@FileName("dke")
|
||||||
.method public final run()V
|
.method public final run()V
|
|
@ -1 +1,2 @@
|
||||||
|
@FileName("sbd")
|
||||||
.method public final a(Lnje;Ljava/util/List;Lrbd;)V
|
.method public final a(Lnje;Ljava/util/List;Lrbd;)V
|
|
@ -1 +1,2 @@
|
||||||
|
@FileName("fl6")
|
||||||
.method public static e(Luz3;Ljava/util/List;)V
|
.method public static e(Luz3;Ljava/util/List;)V
|
|
@ -28,6 +28,23 @@ EXCLUDED_SNIPPETS = [
|
||||||
"NU_payload_parser.smali-snippet"
|
"NU_payload_parser.smali-snippet"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def parse_snippet_content(content):
|
||||||
|
target_filename = None
|
||||||
|
signature_lines = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for line in content.splitlines():
|
||||||
|
# regex to find @FileName("...")
|
||||||
|
match = re.compile(r'^@FileName\("([^"]+)"\)').match(line)
|
||||||
|
if match:
|
||||||
|
target_filename = match.group(1)
|
||||||
|
else:
|
||||||
|
signature_lines.append(line)
|
||||||
|
|
||||||
|
signature = "\n".join(signature_lines).strip()
|
||||||
|
return target_filename, signature
|
||||||
|
|
||||||
def apply_patches(experimental=True):
|
def apply_patches(experimental=True):
|
||||||
print("[I] Smali patching process...")
|
print("[I] Smali patching process...")
|
||||||
|
@ -56,12 +73,14 @@ def apply_patches(experimental=True):
|
||||||
name = os.path.basename(orig_path)
|
name = os.path.basename(orig_path)
|
||||||
try:
|
try:
|
||||||
with open(orig_path, 'r', encoding='utf-8') as f:
|
with open(orig_path, 'r', encoding='utf-8') as f:
|
||||||
original_signature = f.read().strip()
|
original_content = f.read()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[W] Could not read original snippet {name}: {e}")
|
print(f"[W] Could not read original snippet {name}: {e}")
|
||||||
read_errors_original.append(name)
|
read_errors_original.append(name)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
target_filename, original_signature = parse_snippet_content(original_content)
|
||||||
|
|
||||||
if not original_signature:
|
if not original_signature:
|
||||||
empty_originals.append(name)
|
empty_originals.append(name)
|
||||||
continue
|
continue
|
||||||
|
@ -85,7 +104,8 @@ def apply_patches(experimental=True):
|
||||||
patch_pairs.append({
|
patch_pairs.append({
|
||||||
'name': name,
|
'name': name,
|
||||||
'signature': original_signature,
|
'signature': original_signature,
|
||||||
'replacement': patched_block
|
'replacement': patched_block,
|
||||||
|
'target_file': target_filename
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,6 +163,9 @@ def apply_patches(experimental=True):
|
||||||
original_content = target_content
|
original_content = target_content
|
||||||
|
|
||||||
for pair in patch_pairs:
|
for pair in patch_pairs:
|
||||||
|
if pair['target_file'] and pair['target_file'] != os.path.basename(smali_fPath).replace('.smali', ''):
|
||||||
|
continue
|
||||||
|
|
||||||
name = pair['name']
|
name = pair['name']
|
||||||
signature = pair['signature']
|
signature = pair['signature']
|
||||||
replacement = pair['replacement']
|
replacement = pair['replacement']
|
||||||
|
|
Loading…
Reference in New Issue