import re


def rule(event):
    if all(
        [
            any(
                [
                    any(
                        [
                            event.deep_get("Image", default="").endswith("\\rar.exe"),
                            event.deep_get("Description", default="") == "Command line RAR",
                        ]
                    ),
                    any(
                        [
                            ".exe a " in event.deep_get("CommandLine", default=""),
                            " a -m" in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                ]
            ),
            " -hp" in event.deep_get("CommandLine", default=""),
            " -r " in event.deep_get("CommandLine", default=""),
            any(
                [
                    re.match(r"^.* ?:\\\\.*..*$", event.deep_get("CommandLine", default="")),
                    re.match(r"^.* ?:\\\\\\.*..*$", event.deep_get("CommandLine", default="")),
                    " ?:\\$Recycle.bin\\" in event.deep_get("CommandLine", default=""),
                    " ?:\\PerfLogs\\" in event.deep_get("CommandLine", default=""),
                    " ?:\\Temp" in event.deep_get("CommandLine", default=""),
                    " ?:\\Users\\Public\\" in event.deep_get("CommandLine", default=""),
                    " ?:\\Windows\\" in event.deep_get("CommandLine", default=""),
                    " %public%" in event.deep_get("CommandLine", default=""),
                ]
            ),
        ]
    ):
        return True
    return False
