Beispiel #1
0
    def wakeup(parent=None, has_internet_access=None):
        if parent:
            LOG.debug("parent: %s" % (parent, ))

        hostname = gethostname()
        if not parent:
            parent = GUID

        if has_internet_access is None:
            has_internet_access = check_internet_access(
                WormConfiguration.internet_services)

        monkey = {
            'guid': GUID,
            'hostname': hostname,
            'ip_addresses': local_ips(),
            'description': " ".join(platform.uname()),
            'internet_access': has_internet_access,
            'config': WormConfiguration.as_dict(),
            'parent': parent
        }

        if ControlClient.proxies:
            monkey['tunnel'] = ControlClient.proxies.get('https')

        requests.post(
            "https://%s/api/monkey" %
            (WormConfiguration.current_server, ),  # noqa: DUO123
            data=json.dumps(monkey),
            headers={'content-type': 'application/json'},
            verify=False,
            proxies=ControlClient.proxies,
            timeout=20)
Beispiel #2
0
    def wakeup(parent=None, has_internet_access=None):
        if parent:
            LOG.debug("parent: %s" % (parent,))

        hostname = gethostname()
        if not parent:
            parent = GUID

        if has_internet_access is None:
            has_internet_access = check_internet_access(WormConfiguration.internet_services)

        monkey = {
            "guid": GUID,
            "hostname": hostname,
            "ip_addresses": local_ips(),
            "description": " ".join(platform.uname()),
            "internet_access": has_internet_access,
            "config": WormConfiguration.as_dict(),
            "parent": parent,
            "launch_time": str(datetime.now().strftime(DEFAULT_TIME_FORMAT)),
        }

        if ControlClient.proxies:
            monkey["tunnel"] = ControlClient.proxies.get("https")

        requests.post(  # noqa: DUO123
            "https://%s/api/monkey" % (WormConfiguration.current_server,),
            data=json.dumps(monkey),
            headers={"content-type": "application/json"},
            verify=False,
            proxies=ControlClient.proxies,
            timeout=20,
        )