How to use the passivetotal.libs.attributes.AttributeRequest function in passivetotal

To help you get started, we’ve selected a few passivetotal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github passivetotal / python_api / tests / test_attributes.py View on Github external
def setup_class(self):
        self.patcher = patch('passivetotal.api.Client._get', fake_request)
        self.patcher.start()
        self.client = AttributeRequest('--No-User--', '--No-Key--')
github passivetotal / python_api / examples / host_pair_sentinel.py View on Github external
if len(data['tags']) == 0:
            continue
        print(data['queryValue'], ','.join(data['tags']))

query = sys.argv[1]
direction = sys.argv[2]
result_key = {'parents': 'parent', 'children': 'child'}

if len(sys.argv) != 3:
    print("Usage: python host_pair_sentinel.py  ")
    sys.exit(1)
if direction not in ['children', 'parents']:
    print("[!] Direction must be 'children' or 'parents' to work")
    sys.exit(1)

client = AttributeRequest.from_config()
matches = client.get_host_attribute_pairs(query=query, direction=direction)
hostnames = [x[result_key[direction]] for x in matches.get("results", list())]

client = EnrichmentRequest.from_config()
enriched = client.get_bulk_enrichment(query=hostnames)
show_tagged(direction, enriched)
github passivetotal / python_api / passivetotal / cli / client.py View on Github external
def call_attribute(args):
    """Abstract call to attribute-based queries."""
    client = AttributeRequest.from_config()
    pruned = prune_args(
        query=args.query,
        type=args.type
    )

    if args.type == 'tracker':
        data = client.get_host_attribute_trackers(**pruned)
    else:
        data = client.get_host_attribute_components(**pruned)

    return data
github passivetotal / python_api / examples / tracker_sentinel.py View on Github external
1) Take in a domain or IP
2) Identify all tracking codes associated with the query
3) Search for other sites not matching the original query using any codes
4) Construct a table output with data for easy consumption
"""
__author__ = 'Brandon Dixon (brandon@passivetotal.org)'
__version__ = '1.0.0'
__description__ = "Surface related entities based on tracking codes"
__keywords__ = ['trackers', 'phishing', 'crimeware', 'analysis']

import sys
from tabulate import tabulate
from passivetotal.libs.attributes import AttributeRequest

query = sys.argv[1]
client = AttributeRequest.from_config()
# client.set_debug(True)
processed_values = list()


def surface_values(item):
    """Identify items that could be interesting."""
    if item.get('attributeValue') in processed_values:
        return {}

    children = client.search_trackers(
        query=item.get('attributeValue'),
        type=item.get('attributeType')
    )

    interesting = dict()
    for child in children.get('results', []):
github PUNCH-Cyber / stoq-plugins-public / v1 / worker / passivetotal / passivetotal / passivetotal.py View on Github external
def get_attribute(self, **kwargs):
        client = AttributeRequest(self.username, self.apikey)

        keys = ['query', 'type']

        params = self._cleanup_params(keys, **kwargs)

        if params.get('type') == 'tracker':
            return client.get_host_attribute_trackers(**params)
        else:
            return client.get_host_attribute_components(**params)
github passivetotal / python_api / passivetotal / libs / attributes.py View on Github external
def __init__(self, *args, **kwargs):
        """Setup the primary client instance."""
        super(AttributeRequest, self).__init__(*args, **kwargs)