import re


def rule(event):
    if all(
        [
            event.deep_get("TargetImage", default="").endswith("\\lsass.exe"),
            "_ctypes.pyd+" in event.deep_get("CallTrace", default=""),
            ":\\Windows\\System32\\KERNELBASE.dll+" in event.deep_get("CallTrace", default=""),
            ":\\Windows\\SYSTEM32\\ntdll.dll+" in event.deep_get("CallTrace", default=""),
            any(
                [
                    "python27.dll+" in event.deep_get("CallTrace", default=""),
                    re.match(r"^.*python3.*.dll+.*$", event.deep_get("CallTrace", default="")),
                ]
            ),
            event.deep_get("GrantedAccess", default="") == "0x1FFFFF",
        ]
    ):
        return True
    return False
