How to use the passivetotal.libs.whois.WhoisRequest 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_whois.py View on Github external
def setup_class(self):
        self.patcher = patch('passivetotal.api.Client._get', fake_request)
        self.patcher.start()
        self.client = WhoisRequest('--No-User--', '--No-Key--')
github passivetotal / python_api / examples / top_whois_display.py View on Github external
from passivetotal.libs.dns import DnsUniqueResponse
from passivetotal.libs.whois import WhoisRequest
from passivetotal.libs.whois import WhoisResponse
from passivetotal.common.utilities import is_ip

query = sys.argv[1]
if not is_ip(query):
    raise Exception("This script only accepts valid IP addresses!")
    sys.exit(1)

# look up the unique resolutions
client = DnsRequest.from_config()
raw_results = client.get_unique_resolutions(query=query)
loaded = DnsUniqueResponse(raw_results)

whois_client = WhoisRequest.from_config()
for record in loaded.get_records()[:3]:
    raw_whois = whois_client.get_whois_details(query=record.resolve)
    whois = WhoisResponse(raw_whois)
    print(record.resolve, whois.contactEmail)
github Te-k / harpoon / harpoon / commands / pt.py View on Github external
def run(self, conf, args, plugins):
        if 'subcommand' in args:
            if args.subcommand == 'whois':
                client = WhoisRequest(conf['PassiveTotal']['username'], conf['PassiveTotal']['key'])
                if args.domain:
                    raw_results = client.search_whois_by_field(
                        query=unbracket(args.domain.strip()),
                        field="domain"
                    )
                    print(json.dumps(raw_results,  sort_keys=True, indent=4, separators=(',', ': ')))
                elif args.file:
                    with open(args.file, 'r') as infile:
                        data = infile.read().split()
                    print("Domain|Date|Registrar|name|email|Phone|organization|Street|City|Postal Code|State|Country")
                    for d in data:
                        do = unbracket(d.strip())
                        # FIXME: bulk request here
                        raw_results = client.search_whois_by_field(
                            query=do,
                            field="domain"
github stratosphereips / whois-similarity-distance / whois_similarity_distance / util / whois_obj.py View on Github external
def __process_result_pt__(self): # passive total
        d = self.__get_top_level_domain__()
        try:
            if d:
                client = WhoisRequest.from_config()
                raw_results = client.get_whois_details(query=d)
                self.raw_whois = raw_results
            elif not d:
                print("PT, domain null " + str(d) + " " + str(self.id))
        except:
            print("PT rejects " + str(self.domain) + " ")
github passivetotal / python_api / passivetotal / cli / client.py View on Github external
def call_whois(args):
    """Abstract call to WHOIS-based queries."""
    client = WhoisRequest.from_config()
    pruned = prune_args(
        query=args.query,
        compact_record=args.compact,
        field=args.field
    )

    if not args.field:
        data = client.get_whois_details(**pruned)
    else:
        data = client.search_whois_by_field(**pruned)

    return data
github passivetotal / python_api / examples / whois_search.py View on Github external
import sys
from passivetotal.libs.whois import WhoisRequest

if len(sys.argv) != 3:
    print("Usage: python whois_search.py  ")

valid_types = ['domain', 'email', 'name',
               'organization', 'address', 'phone', 'nameserver']

query_type = sys.argv[1]
query_value = sys.argv[2]

if query_type not in valid_types:
    print("[!] ERROR: Query type must be one of the following:\n\t%s" % (', '.join(valid_types)))

client = WhoisRequest.from_config()
response = client.search_whois_by_field(field=query_type, query=query_value)
for item in response.get('results', []):
    domain = item.get('domain', None)
    if domain:
        print(domain, item.get('registered'), item.get('registryUpdatedAt'), item.get('expiresAt'))
github passivetotal / python_api / passivetotal / libs / whois.py View on Github external
def __init__(self, *args, **kwargs):
        """Inherit from the base class."""
        super(WhoisRequest, self).__init__(*args, **kwargs)
github PUNCH-Cyber / stoq-plugins-public / v1 / worker / passivetotal / passivetotal / passivetotal.py View on Github external
def get_whois(self, **kwargs):
        client = WhoisRequest(self.username, self.apikey)

        keys = ['query', 'compact', 'field']

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

        if not params.get('field'):
            return client.get_whois_details(**params)
        else:
            return client.search_whois_by_field(**params)