import ipaddress


def rule(event):
    if all(
        [
            "wuauclt" in event.deep_get("Image", default=""),
            " /RunHandlerComServer" in event.deep_get("CommandLine", default=""),
            not any(
                [
                    any(
                        [
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("127.0.0.0/8"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("10.0.0.0/8"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("169.254.0.0/16"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("172.16.0.0/12"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("192.168.0.0/16"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("::1/128"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("fe80::/10"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("fc00::/7"),
                        ]
                    ),
                    any(
                        [
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("20.184.0.0/13"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("20.192.0.0/10"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("23.79.0.0/16"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("51.10.0.0/15"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("51.103.0.0/16"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("51.104.0.0/15"),
                            ipaddress.ip_address(event.deep_get("DestinationIp", default=""))
                            in ipaddress.ip_network("52.224.0.0/11"),
                        ]
                    ),
                    any(
                        [
                            ":\\Windows\\UUS\\Packages\\Preview\\amd64\\updatedeploy.dll /ClassId"
                            in event.deep_get("CommandLine", default=""),
                            ":\\Windows\\UUS\\amd64\\UpdateDeploy.dll /ClassId"
                            in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                    all(
                        [
                            ":\\Windows\\WinSxS\\" in event.deep_get("CommandLine", default=""),
                            "\\UpdateDeploy.dll /ClassId "
                            in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                    event.deep_get("CommandLine", default="") == "",
                    event.deep_get("CommandLine", default="") == "",
                ]
            ),
        ]
    ):
        return True
    return False
