import ipaddress


def rule(event):
    if all(
        [
            event.deep_get("EventID", default="") == 4000,
            any(
                [
                    "IPC$" in event.deep_get("ShareName", default=""),
                    "ADMIN$" in event.deep_get("ShareName", default=""),
                    "C$" in event.deep_get("ShareName", default=""),
                ]
            ),
            any(
                [
                    event.deep_get("SigningUsed", default="") == "false",
                    event.deep_get("EncyptionUsed", default="") == "false",
                ]
            ),
            not any(
                [
                    any(
                        [
                            ipaddress.ip_address(event.deep_get("ClientAddress", default=""))
                            in ipaddress.ip_network("127.0.0.0/8"),
                            ipaddress.ip_address(event.deep_get("ClientAddress", default=""))
                            in ipaddress.ip_network("169.254.0.0/16"),
                            ipaddress.ip_address(event.deep_get("ClientAddress", default=""))
                            in ipaddress.ip_network("::1/128"),
                            ipaddress.ip_address(event.deep_get("ClientAddress", default=""))
                            in ipaddress.ip_network("fe80::/10"),
                            ipaddress.ip_address(event.deep_get("ClientAddress", default=""))
                            in ipaddress.ip_network("fc00::/7"),
                        ]
                    ),
                    any(
                        [
                            "00000000000000000000000000000001"
                            in event.deep_get("ClientAddress", default=""),
                            "FE80000000000000" in event.deep_get("ClientAddress", default=""),
                            "FC00000000000000" in event.deep_get("ClientAddress", default=""),
                            "0200????7F" in event.deep_get("ClientAddress", default=""),
                            "0200????A9FE" in event.deep_get("ClientAddress", default=""),
                        ]
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
