def rule(event):
    if all(
        [
            event.deep_get("ImageLoaded", default="").endswith("\\amsi.dll"),
            not any(
                [
                    any(
                        [
                            event.deep_get("Image", default="").endswith(
                                ":\\Windows\\explorer.exe"
                            ),
                            event.deep_get("Image", default="").endswith(
                                ":\\Windows\\Sysmon64.exe"
                            ),
                        ]
                    ),
                    any(
                        [
                            ":\\Program Files (x86)\\" in event.deep_get("Image", default=""),
                            ":\\Program Files\\" in event.deep_get("Image", default=""),
                            ":\\Windows\\System32\\" in event.deep_get("Image", default=""),
                            ":\\Windows\\SysWOW64\\" in event.deep_get("Image", default=""),
                            ":\\Windows\\WinSxS\\" in event.deep_get("Image", default=""),
                        ]
                    ),
                    all(
                        [
                            any(
                                [
                                    ":\\Windows\\Microsoft.NET\\Framework\\"
                                    in event.deep_get("Image", default=""),
                                    ":\\Windows\\Microsoft.NET\\Framework64\\"
                                    in event.deep_get("Image", default=""),
                                    ":\\Windows\\Microsoft.NET\\FrameworkArm\\"
                                    in event.deep_get("Image", default=""),
                                    ":\\Windows\\Microsoft.NET\\FrameworkArm64\\"
                                    in event.deep_get("Image", default=""),
                                ]
                            ),
                            event.deep_get("Image", default="").endswith("\\ngentask.exe"),
                        ]
                    ),
                    event.deep_get("Image", default="") == "",
                    event.deep_get("Image", default="") == "",
                ]
            ),
            not all(
                [
                    ":\\ProgramData\\Microsoft\\Windows Defender\\Platform\\"
                    in event.deep_get("Image", default=""),
                    event.deep_get("Image", default="").endswith("\\MsMpEng.exe"),
                ]
            ),
        ]
    ):
        return True
    return False
