import re


def rule(event):
    if all(
        [
            any(
                [
                    event.deep_get("Image", default="").endswith("\\attrib.exe"),
                    event.deep_get("OriginalFileName", default="") == "ATTRIB.EXE",
                ]
            ),
            " +h " in event.deep_get("CommandLine", default=""),
            not "\\desktop.ini " in event.deep_get("CommandLine", default=""),
            not all(
                [
                    event.deep_get("ParentImage", default="").endswith("\\cmd.exe"),
                    re.match(
                        r"^+R +H +S +A \\\\.*.cui$", event.deep_get("CommandLine", default="")
                    ),
                    re.match(
                        r"^C:\\WINDOWS\\system32\\\\.*.bat$",
                        event.deep_get("ParentCommandLine", default=""),
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
