예제 #1
0
def test_search():
    YuleakClient.search('yuleak.com')
    dashboard = YuleakClient.dashboards()[-1]
    dashboard.search('yuleak.io')
    dashboard.delete()
    if len(dashboard.list_new_servers()) > 0:
        dashboard.searchall()
예제 #2
0
def test_views():
    dashboards = YuleakClient.dashboards()
    assert len(dashboards) > 0
    for dashboard in dashboards:
        # Display stats (similar to dashboard view in WebUI)
        stats = dashboard.stats()
        assert len(stats) > 0
        assert 'blacklist' in stats
        # Display map (similar to map widget in WebUI)
        map_ = dashboard.map()
        assert len(map_) > 0
        # Display graph (similar to graph view in WebUI)
        graph = dashboard.graph()
        assert len(graph) > 0
        for node in graph:
            assert len(node.neighbors) > 0
        # Display timeline (similar to timeline widget in WebUI)
        timeline = dashboard.timeline()
        assert len(timeline) > 0
        assert timeline[0].total > 0
        # Display details (similar to details view in WebUI)
        details = dashboard.details()
        assert len(details) > 0
        for server in details:
            assert server.geo.country_name is not None
            for domain in server.domains:
                if domain.screenshot is not None:
                    assert domain.screenshot.url is not None
                    assert domain.screenshot.url != ''
                    assert domain.screenshot.download('/tmp/{0}.png'.format(domain.value))
        assert details[0].geo.country_name is not None
예제 #3
0
def test_bookmark():
    dashboards = YuleakClient.dashboards()
    server = dashboards[0].details()[0]
    assert not server.bookmark
    assert server.add_bookmark()
    assert server.bookmark
    assert server.del_bookmark()
    assert not server.bookmark
예제 #4
0
    def delete(self):
        """Delete the current dashboard and all its data.

        See https://app.yuleak.com/apidoc#post-delete for endpoint details.

        Returns:
            (bool) True if the dashboard has been deleted
        """
        return YuleakClient.delete_request('dashboard/{0}'.format(self.id))
예제 #5
0
    def list_new_servers(self):
        """Get list of servers not in resources.

        See https://app.yuleak.com/apidoc#get-searchall for endpoint details.

        Returns:
            list of ip (string)
        """
        return YuleakClient.get_request('dashboard/{0}/searchall'.format(self.id))
예제 #6
0
    def searchall(self):
        """Search all servers not listed in resources (credits will be used).

        See https://app.yuleak.com/apidoc#post-searchall for endpoint details.

        Returns:
            (bool) True if the search has been launched
        """
        return YuleakClient.post_request('dashboard/{0}/searchall'.format(self.id))
예제 #7
0
    def renew_all(self):
        """Re-launch all resources of the current dashboard.

        See https://app.yuleak.com/apidoc#post-renewall for endpoint details.

        Returns:
            (bool) True if the search has been launched
        """
        return YuleakClient.post_request('dashboard/{0}/renewall'.format(self.id))
예제 #8
0
def test_resources():
    dashboards = YuleakClient.dashboards()
    assert len(dashboards) > 0
    dashboard = dashboards[0]
    resources = dashboard.resources()
    for resource in resources:
        if resource.type == 'server':
            assert resource.renew()
        else:
            assert resource.delete()
예제 #9
0
    def delete(self):
        """Delete the current resource and all data linked

        See https://app.yuleak.com/apidoc#delete-resources for endpoint details.

        Returns:
            (bool) True if the search has been launched
        """
        return YuleakClient.delete_request('dashboard/{0}/resources'.format(
            self.dashboard.id),
                                           params={'value': self.value})
예제 #10
0
    def renew(self):
        """Launch a new search for the current resource (credits will be consumed)

        See https://app.yuleak.com/apidoc#post-renew for endpoint details.

        Returns:
            (bool) True if the search has been launched
        """
        return YuleakClient.post_request('dashboard/{0}/renew'.format(
            self.dashboard.id),
                                         data={'value': self.value})
예제 #11
0
    def search(self, search):
        """Launch a new search (credits will be used) in the current dashboard.

        See https://app.yuleak.com/apidoc#post-search for endpoint details.

        Args:
            search (str): Expression to search

        Returns:
            (bool) True if the search has been launched
        """
        return YuleakClient.post_request('dashboard/{0}/search'.format(self.id), data={'value': search})
예제 #12
0
    def filters(self):
        """Get the current dashboard active filters (similar to filters list widget in WebUI).

        See https://app.yuleak.com/apidoc#get-filters for endpoint details.

        Returns:
            list of Filter items
        """
        results = []
        for d in YuleakClient.get_request('dashboard/{0}/filters'.format(self.id)):
            results.append(Filter.from_json(d, self))
        return results
예제 #13
0
    def renew_cost(self):
        """Get the cost to renew all resources

        See https://app.yuleak.com/apidoc#get-renewall for endpoint details.

        Returns:
            (int) Amount of credits
        """
        data = YuleakClient.get_request('dashboard/{0}/renewall'.format(self.id))
        if len(data) == 0:
            return 0
        return data[0].get('credits', 0)
예제 #14
0
    def statsdns(self):
        """Get the current dashboard DNS (Typosquatting) stats (similare to dns view in WebUI).

        See https://app.yuleak.com/apidoc#get-statsdns for endpoint details.

        Returns:
            dict containing statistics
        """
        data = YuleakClient.get_request('dashboard/{0}/statsdns'.format(self.id))
        if len(data) == 0:
            return []
        return data[0]
예제 #15
0
def test_filters():
    dashboards = YuleakClient.dashboards()
    dashboard = dashboards[0]
    # Add filter
    nb_old = len(dashboard.details())
    dashboard.add_filter('domain', 'all')
    assert len(dashboard.details()) < nb_old
    # Del filter
    for f in dashboard.filters():
        print(f)
        assert f.delete()
    assert len(dashboard.filters()) == 0
예제 #16
0
    def dns(self):
        """Get the current dashboard typosquatting dns entries (similar to dns view in WebUI).

        See https://app.yuleak.com/apidoc#get-dns for endpoint details.

        Returns:
            list of DNSEntry items
        """
        results = []
        for d in YuleakClient.get_request('dashboard/{0}/dns'.format(self.id)):
            results.append(DNSEntry.from_json(d))
        return results
예제 #17
0
    def map(self):
        """Get the current dashboard map markers (similar to map widget in WebUI).

        See https://app.yuleak.com/apidoc#get-map for endpoint details.

        Returns:
            list of Marker items
        """
        results = []
        for d in YuleakClient.get_request('dashboard/{0}/map'.format(self.id)):
            results.append(Marker.from_json(d))
        return results
예제 #18
0
    def timeline(self):
        """Get the current dashboard timeline (similar to timeline widget in WebUI).

        See https://app.yuleak.com/apidoc#get-timeline for endpoint details.

        Returns:
            list of Event items
        """
        results = []
        for d in YuleakClient.get_request('dashboard/{0}/timeline'.format(self.id)):
            results.append(Event.from_json(d))
        return results
예제 #19
0
    def details(self):
        """Get the current dashboard servers (similar to details view in WebUI).

        See https://app.yuleak.com/apidoc#get-details for endpoint details.

        Returns:
            list of Server items
        """
        results = []
        for d in YuleakClient.get_request('dashboard/{0}/details'.format(self.id)):
            results.append(Server.from_json(d, self))
        return results
예제 #20
0
    def resources(self):
        """Get the current dashboard resources (similar to resources list widget in WebUI).

        See https://app.yuleak.com/apidoc#get-resources for endpoint details.

        Returns:
            list of Resource items
        """
        results = []
        for d in YuleakClient.get_request('dashboard/{0}/resources'.format(self.id)):
            results.append(Resource.from_json(d, self))
        return results
예제 #21
0
    def delete(self):
        """Delete the current filter

        See https://app.yuleak.com/apidoc#delete-filters for endpoint details.

        Returns:
            (bool) True if the filter has been deleted
        """
        return YuleakClient.delete_request('dashboard/{0}/filters'.format(
            self.dashboard.id),
                                           params={
                                               'value': self.value,
                                               'category': self.category
                                           })
예제 #22
0
    def add_bookmark(self):
        """Add a bookmark to the current server.

        See https://app.yuleak.com/apidoc#post-bookmark for endpoint details.

        Returns:
            (bool) True if the bookmark have been added
        """
        if self.bookmark:
            logger.warning('The server is already bookmarked.')
        if YuleakClient.post_request(
                'dashboard/{0}/server/{1}/bookmark'.format(
                    self.dashboard.id, self.id)):
            self.bookmark = True
        return self.bookmark
예제 #23
0
    def stats(self):
        """Get the current dashboard statistics (similar to dahboard view in WebUI).

        See https://app.yuleak.com/apidoc#get-dashboard for endpoint details.

        Returns:
            dict containing statistics
        """
        stats = self.BASE_STATS.copy()
        data = YuleakClient.get_request('dashboard/{0}'.format(self.id))
        if len(data) == 0:
            return stats
        for k, v in data[0].items():
            stats[k] = v
        return stats
예제 #24
0
    def add_filter(self, category, value, type_='required'):
        """Add a filter to the current dashboard.

        See https://app.yuleak.com/apidoc#post-filters for endpoint details.

        Args:
            category (str): Filter category (server, domain, alert, date)
            value (str): Filter value (all, blacklist, cloudflare ...)
            type_ (str): Filter type: required (by default) or ignored

        Returns:
            True if the filter has been added
        """
        return YuleakClient.post_request('dashboard/{0}/filters'.format(self.id),
                                         data={'category': category,
                                               'value': value,
                                               'type': type_})
예제 #25
0
    def del_bookmark(self):
        """Delete the bookmark of the current server.

        See https://app.yuleak.com/apidoc#delete-bookmark for endpoint details.

        Returns:
            (bool) True if the bookmark have been deleted
        """
        if not self.bookmark:
            logger.warning('The server is not bookmarked.')
        if YuleakClient.delete_request(
                'dashboard/{0}/server/{1}/bookmark'.format(
                    self.dashboard.id, self.id)):
            self.bookmark = False
            return True
        else:
            return False
예제 #26
0
    def graph(self):
        """Get the current dashboard graph (similar to graph view in WebUI).

        See https://app.yuleak.com/apidoc#get-graph for endpoint details.

        Returns:
            list of Node items
        """
        results = {}
        data = YuleakClient.get_request('dashboard/{0}/graph'.format(self.id))
        if len(data) == 0:
            return []
        # Nodes
        for n in data[0].get('nodes', []):
            results[n.get('id')] = Node.from_json(n)
        # Edges
        for e in data[0].get('edges', []):
            parent_node = results.get(e[0])
            child_node = results.get(e[1])
            if parent_node is None or child_node is None:
                continue
            parent_node.connect(child_node)
        return list(results.values())
예제 #27
0
def test_basics():
    credits_ = YuleakClient.credits()
    assert credits_ == 0
    dashboards = YuleakClient.dashboards()
    assert len(dashboards) > 0