import re


def rule(event):
    if all(
        [
            any(
                [
                    all(
                        [
                            any(
                                [
                                    event.deep_get("Image", default="").endswith(
                                        "\\powershell_ise.exe"
                                    ),
                                    event.deep_get("Image", default="").endswith(
                                        "\\powershell.exe"
                                    ),
                                    event.deep_get("Image", default="").endswith("\\pwsh.exe"),
                                    event.deep_get("Image", default="").endswith("\\cmd.exe"),
                                ]
                            ),
                            any(
                                [
                                    "curl " in event.deep_get("CommandLine", default=""),
                                    "Invoke-RestMethod"
                                    in event.deep_get("CommandLine", default=""),
                                    "Invoke-WebRequest"
                                    in event.deep_get("CommandLine", default=""),
                                    "irm " in event.deep_get("CommandLine", default=""),
                                    "iwr " in event.deep_get("CommandLine", default=""),
                                    "wget " in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                            " -ur" in event.deep_get("CommandLine", default=""),
                            " -me" in event.deep_get("CommandLine", default=""),
                            " -b" in event.deep_get("CommandLine", default=""),
                            " POST " in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("Image", default="").endswith("\\curl.exe"),
                            "--ur" in event.deep_get("CommandLine", default=""),
                            any(
                                [
                                    " -d " in event.deep_get("CommandLine", default=""),
                                    " --data " in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("Image", default="").endswith("\\wget.exe"),
                            any(
                                [
                                    "--post-data" in event.deep_get("CommandLine", default=""),
                                    "--post-file" in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                        ]
                    ),
                ]
            ),
            any(
                [
                    any(
                        [
                            re.match(r"net\\s+view", event.deep_get("CommandLine", default="")),
                            re.match(r"sc\\s+query", event.deep_get("CommandLine", default="")),
                        ]
                    ),
                    any(
                        [
                            "Get-Content" in event.deep_get("CommandLine", default=""),
                            "GetBytes" in event.deep_get("CommandLine", default=""),
                            "hostname" in event.deep_get("CommandLine", default=""),
                            "ifconfig" in event.deep_get("CommandLine", default=""),
                            "ipconfig" in event.deep_get("CommandLine", default=""),
                            "netstat" in event.deep_get("CommandLine", default=""),
                            "nltest" in event.deep_get("CommandLine", default=""),
                            "qprocess" in event.deep_get("CommandLine", default=""),
                            "systeminfo" in event.deep_get("CommandLine", default=""),
                            "tasklist" in event.deep_get("CommandLine", default=""),
                            "ToBase64String" in event.deep_get("CommandLine", default=""),
                            "whoami" in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                    all(
                        [
                            "type " in event.deep_get("CommandLine", default=""),
                            " > " in event.deep_get("CommandLine", default=""),
                            " C:\\" in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
