def rule(event):
    if all(
        [
            any(
                [
                    event.deep_get("Image", default="").endswith("\\sqlcmd.exe"),
                    any(
                        [
                            "sqlcmd " in event.deep_get("CommandLine", default=""),
                            "sqlcmd.exe" in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                ]
            ),
            " -S localhost " in event.deep_get("CommandLine", default=""),
            any(
                [
                    "sys.sysprocesses" in event.deep_get("CommandLine", default=""),
                    "master.dbo.sysdatabases" in event.deep_get("CommandLine", default=""),
                    "BACKUP DATABASE" in event.deep_get("CommandLine", default=""),
                ]
            ),
        ]
    ):
        return True
    return False
