import ipaddress


def rule(event):
    if all(
        [
            event.deep_get("Initiated", default="") == "true",
            event.deep_get("DestinationPort", default="")
            in [
                100,
                198,
                200,
                243,
                473,
                666,
                700,
                743,
                777,
                1443,
                1515,
                1777,
                1817,
                1904,
                1960,
                2443,
                2448,
                3360,
                3675,
                3939,
                4040,
                4433,
                4438,
                4443,
                4444,
                4455,
                5445,
                5552,
                5649,
                6625,
                7210,
                7777,
                8143,
                8843,
                9631,
                9943,
                10101,
                12102,
                12103,
                12322,
                13145,
                13394,
                13504,
                13505,
                13506,
                13507,
                14102,
                14103,
                14154,
                49180,
                65520,
                65535,
            ],
            not 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("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("169.254.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"),
                ]
            ),
            not any(
                [
                    event.deep_get("Image", default="").startswith("C:\\Program Files\\"),
                    event.deep_get("Image", default="").startswith("C:\\Program Files (x86)\\"),
                ]
            ),
        ]
    ):
        return True
    return False
