33 lines
1.8 KiB
Python
33 lines
1.8 KiB
Python
"""Create a separate equal-length diagnostic loader; existing files stay untouched."""
|
|
from pathlib import Path
|
|
import hashlib
|
|
import json
|
|
|
|
root = Path(__file__).resolve().parents[2]
|
|
outdir = Path(__file__).parent
|
|
original = (root / "analysis/MYRDyd.swf").read_bytes()
|
|
assert hashlib.sha256(original).hexdigest() == "4728d0e23bdf0d6b1468e8cd39f97535e65a09bfa40044e7c73af7e1655af741"
|
|
code_start = 0x289f4
|
|
patch_start = code_start + 0x13
|
|
before = bytes.fromhex("60 05 46 0f 00 66 2f 80 14 d5 60 05 2c 80 02 46 2b 01 85 d6")
|
|
# File.applicationDirectory.resolvePath("MYRMain.app").url -> local2, followed by six real nop opcodes.
|
|
after = bytes.fromhex("60 3d 66 43 2c 80 02 46 3f 01 66 41 85 d6 02 02 02 02 02 02")
|
|
assert len(before) == len(after) == 20
|
|
assert original[patch_start:patch_start + 20] == before
|
|
candidate = bytearray(original)
|
|
candidate[patch_start:patch_start + 20] = after
|
|
assert len(original) == len(candidate)
|
|
assert candidate[:patch_start] == original[:patch_start]
|
|
assert candidate[patch_start + 20:] == original[patch_start + 20:]
|
|
path = outdir / "MYRDyd_explicit_package_diagnostic_20261107_01.swf"
|
|
with path.open("xb") as stream:
|
|
stream.write(candidate)
|
|
result = {"file": str(path.relative_to(root)), "original_sha256": hashlib.sha256(original).hexdigest(),
|
|
"candidate_sha256": hashlib.sha256(candidate).hexdigest(), "file_size": len(candidate),
|
|
"method_code_start_hex": hex(code_start), "method_offset_hex": "0x13", "file_offset_hex": hex(patch_start),
|
|
"before": before.hex(" "), "after": after.hex(" "),
|
|
"changed_byte_count": sum(a != b for a, b in zip(before, after)), "identical_outside_block": True}
|
|
with (outdir / "explicit_package_candidate_20261107_01.json").open("x", encoding="utf-8") as stream:
|
|
json.dump(result, stream, indent=2)
|
|
print(json.dumps(result, indent=2))
|