import re


def rule(event):
    if all(
        [
            event.deep_get("ParentImage", default="").endswith("\\WinRAR.exe"),
            "\\AppData\\Local\\Temp\\Rar$" in event.deep_get("CommandLine", default=""),
            re.match(r"\\.[a-zA-Z0-9]{1,4} \\.", event.deep_get("CommandLine", default="")),
            any(
                [
                    any(
                        [
                            event.deep_get("Image", default="").endswith("\\cmd.exe"),
                            event.deep_get("Image", default="").endswith("\\cscript.exe"),
                            event.deep_get("Image", default="").endswith("\\powershell.exe"),
                            event.deep_get("Image", default="").endswith("\\pwsh.exe"),
                            event.deep_get("Image", default="").endswith("\\wscript.exe"),
                        ]
                    ),
                    event.deep_get("OriginalFileName", default="")
                    in ["Cmd.Exe", "cscript.exe", "PowerShell.EXE", "pwsh.dll", "wscript.exe"],
                ]
            ),
        ]
    ):
        return True
    return False
