def rule(event):
    if all(
        [
            event.deep_get("EventID", default="") in [2004, 2071, 2097],
            not any(
                [
                    event.deep_get("Action", default="") == 2,
                    any(
                        [
                            event.deep_get("ApplicationPath", default="").startswith(
                                "C:\\Program Files (x86)\\"
                            ),
                            event.deep_get("ApplicationPath", default="").startswith(
                                "C:\\Program Files\\"
                            ),
                            event.deep_get("ApplicationPath", default="").startswith(
                                "C:\\Windows\\System32\\"
                            ),
                            event.deep_get("ApplicationPath", default="").startswith(
                                "C:\\Windows\\SysWOW64\\"
                            ),
                            event.deep_get("ApplicationPath", default="").startswith(
                                "C:\\Windows\\WinSxS\\"
                            ),
                        ]
                    ),
                    any(
                        [
                            "C:\\PerfLogs\\" in event.deep_get("ApplicationPath", default=""),
                            "C:\\Temp\\" in event.deep_get("ApplicationPath", default=""),
                            "C:\\Tmp\\" in event.deep_get("ApplicationPath", default=""),
                            "C:\\Users\\Public\\" in event.deep_get("ApplicationPath", default=""),
                            "C:\\Windows\\Tasks\\" in event.deep_get("ApplicationPath", default=""),
                            "C:\\Windows\\Temp\\" in event.deep_get("ApplicationPath", default=""),
                            "\\AppData\\Local\\Temp\\"
                            in event.deep_get("ApplicationPath", default=""),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("ApplicationPath", default="") == "System",
                            event.deep_get("ModifyingApplication", default="")
                            == "C:\\Windows\\System32\\dllhost.exe",
                        ]
                    ),
                    all(
                        [
                            event.deep_get("ModifyingApplication", default="").startswith(
                                "C:\\Windows\\WinSxS\\"
                            ),
                            event.deep_get("ModifyingApplication", default="").endswith(
                                "\\TiWorker.exe"
                            ),
                        ]
                    ),
                    event.deep_get("ApplicationPath", default="") == "",
                ]
            ),
            not any(
                [
                    all(
                        [
                            event.deep_get("ModifyingApplication", default="")
                            in [
                                "C:\\Windows\\System32\\svchost.exe",
                                "C:\\Windows\\System32\\dllhost.exe",
                            ],
                            event.deep_get("ApplicationPath", default="") == "",
                        ]
                    ),
                    any(
                        [
                            all(
                                [
                                    any(
                                        [
                                            event.deep_get(
                                                "ModifyingApplication", default=""
                                            ).startswith(
                                                "C:\\ProgramData\\Microsoft\\Windows Defender\\Platform\\"
                                            ),
                                            event.deep_get(
                                                "ModifyingApplication", default=""
                                            ).startswith("C:\\Program Files\\Windows Defender\\"),
                                        ]
                                    ),
                                    event.deep_get("ModifyingApplication", default="").endswith(
                                        "\\MsMpEng.exe"
                                    ),
                                ]
                            ),
                            all(
                                [
                                    any(
                                        [
                                            event.deep_get(
                                                "ApplicationPath", default=""
                                            ).startswith(
                                                "C:\\ProgramData\\Microsoft\\Windows Defender\\Platform\\"
                                            ),
                                            event.deep_get(
                                                "ApplicationPath", default=""
                                            ).startswith("C:\\Program Files\\Windows Defender\\"),
                                        ]
                                    ),
                                    event.deep_get("ApplicationPath", default="").endswith(
                                        "\\MsMpEng.exe"
                                    ),
                                ]
                            ),
                        ]
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
