def rule(event):
    if all(
        [
            any(
                [
                    event.deep_get("Image", default="").endswith("\\regsvr32.exe"),
                    event.deep_get("OriginalFileName", default="") == "REGSVR32.EXE",
                ]
            ),
            any(
                [
                    " /s " in event.deep_get("CommandLine", default=""),
                    " /e " in event.deep_get("CommandLine", default=""),
                ]
            ),
            not any(
                [
                    any(
                        [
                            any(
                                [
                                    ":\\Program Files (x86)"
                                    in event.deep_get("CommandLine", default=""),
                                    ":\\Program Files\\"
                                    in event.deep_get("CommandLine", default=""),
                                    ":\\Windows\\System32\\"
                                    in event.deep_get("CommandLine", default=""),
                                    ":\\Windows\\SysWOW64\\"
                                    in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                            any(
                                [
                                    ":\\Program Files (x86)"
                                    in event.deep_get("CurrentDirectory", default=""),
                                    ":\\Program Files\\"
                                    in event.deep_get("CurrentDirectory", default=""),
                                    ":\\Windows\\System32\\"
                                    in event.deep_get("CurrentDirectory", default=""),
                                    ":\\Windows\\SysWOW64\\"
                                    in event.deep_get("CurrentDirectory", default=""),
                                ]
                            ),
                        ]
                    ),
                    any(
                        [
                            " /i:" in event.deep_get("CommandLine", default=""),
                            "/U " in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("ParentCommandLine", default="").endswith(
                                ":\\Windows\\System32\\RpcProxy\\RpcProxy.dll"
                            ),
                            event.deep_get("CommandLine", default="") == "regsvr32 /s rpcproxy.dll",
                        ]
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
