def rule(event):
    if all(
        [
            any(
                [
                    all(
                        [
                            any(
                                [
                                    event.deep_get("Image", default="").endswith("\\cacls.exe"),
                                    event.deep_get("Image", default="").endswith("\\icacls.exe"),
                                    event.deep_get("Image", default="").endswith("\\net.exe"),
                                    event.deep_get("Image", default="").endswith("\\net1.exe"),
                                ]
                            ),
                            any(
                                [
                                    "/grant" in event.deep_get("CommandLine", default=""),
                                    "/setowner" in event.deep_get("CommandLine", default=""),
                                    "/inheritance:r" in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("Image", default="").endswith("\\attrib.exe"),
                            "-r" in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                    event.deep_get("Image", default="").endswith("\\takeown.exe"),
                ]
            ),
            not any(
                [
                    event.deep_get("CommandLine", default="").endswith(
                        "ICACLS C:\\ProgramData\\dynatrace\\gateway\\config\\connectivity.history /reset"
                    ),
                    all(
                        [
                            "ICACLS C:\\ProgramData\\dynatrace\\gateway\\config\\config.properties /grant :r "
                            in event.deep_get("CommandLine", default=""),
                            "S-1-5-19:F" in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                    any(
                        [
                            "\\AppData\\Local\\Programs\\Microsoft VS Code"
                            in event.deep_get("CommandLine", default=""),
                            ":\\Program Files\\Microsoft VS Code"
                            in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                    any(
                        [
                            ":\\Program Files (x86)\\Avira"
                            in event.deep_get("CommandLine", default=""),
                            ":\\Program Files\\Avira" in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
