import re


def rule(event):
    if all(
        [
            any(
                [
                    re.match(r"^7z.*.exe$", event.deep_get("OriginalFileName", default="")),
                    event.deep_get("OriginalFileName", default="").endswith("rar.exe"),
                    re.match(
                        r"^.*Command.*Line.*RAR.*$", event.deep_get("OriginalFileName", default="")
                    ),
                ]
            ),
            any(
                [
                    " -p" in event.deep_get("CommandLine", default=""),
                    " -ta" in event.deep_get("CommandLine", default=""),
                    " -tb" in event.deep_get("CommandLine", default=""),
                    " -sdel" in event.deep_get("CommandLine", default=""),
                    " -dw" in event.deep_get("CommandLine", default=""),
                    " -hp" in event.deep_get("CommandLine", default=""),
                ]
            ),
            not any(
                [
                    ":\\Program Files\\" in event.deep_get("ParentImage", default=""),
                    ":\\Program Files (x86)\\" in event.deep_get("ParentImage", default=""),
                ]
            ),
        ]
    ):
        return True
    return False
