How to use the passivetotal.libs.dns.DnsRequest 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_dns.py View on Github external
def setup_class(self):
        self.patcher = patch('passivetotal.api.Client._get', fake_request)
        self.patcher.start()
        self.client = DnsRequest('--No-User--', '--No-Key--')
github Te-k / harpoon / harpoon / commands / pt.py View on Github external
r["registrant"]["state"] if "state" in r["registrant"] else "",
                                        r["registrant"]["country"] if "country" in r["registrant"] else ""
                                    )
                                )


                elif args.email:
                    raw_results = client.search_whois_by_field(
                        query=args.email.strip(),
                        field="email"
                    )
                    print(json.dumps(raw_results,  sort_keys=True, indent=4, separators=(',', ': ')))
                else:
                    self.parser.print_help()
            elif args.subcommand == "dns":
                client = DnsRequest(conf['PassiveTotal']['username'], conf['PassiveTotal']['key'])
                raw_results = client.get_passive_dns(
                    query=unbracket(args.DOMAIN),
                )
                print(json.dumps(raw_results,  sort_keys=True, indent=4, separators=(',', ': ')))
            elif args.subcommand == "malware":
                client = EnrichmentRequest(conf["PassiveTotal"]["username"], conf["PassiveTotal"]['key'])
                if args.domain:
                    raw_results = client.get_malware(query=args.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()
                    domain_list = list(set([a.strip() for a in data]))
                    if len(domain_list) < 51:
                        raw_results = client.get_bulk_malware(query=domain_list)
                        if "results" not in raw_results or not raw_results["success"]:
github Te-k / harpoon / harpoon / commands / ptdns.py View on Github external
def run(self, conf, args):
        client = DnsRequest(conf['PassiveTotal']['username'], conf['PassiveTotal']['key'])
        raw_results = client.get_passive_dns(
            query=args.DOMAIN,
        )
        print(json.dumps(raw_results,  sort_keys=True, indent=4, separators=(',', ': ')))
github passivetotal / python_api / passivetotal / libs / dns.py View on Github external
def __init__(self, *args, **kwargs):
        """Inherit from the base class."""
        super(DnsRequest, self).__init__(*args, **kwargs)
github Te-k / harpoon / harpoon / commands / domain.py View on Github external
if d['rrtype'] in ['A', 'AAAA']:
                        passive_dns.append({
                            'first': d['time_first_o'].astimezone(pytz.utc),
                            'last': d['time_last_o'].astimezone(pytz.utc),
                            'ip': d['rrdata'],
                            'source': 'Robtex'
                        })

                # PT
                pt_e = plugins['pt'].test_config(conf)
                if pt_e:
                    try:
                        pt_osint = {}
                        ptout = False
                        print('[+] Downloading Passive Total information....')
                        client = DnsRequest(conf['PassiveTotal']['username'], conf['PassiveTotal']['key'])
                        raw_results = client.get_passive_dns(query=unbracket(args.DOMAIN))
                        if "results" in raw_results:
                            for res in raw_results["results"]:
                                passive_dns.append({
                                    "first": parse(res["firstSeen"]).astimezone(pytz.utc),
                                    "last": parse(res["lastSeen"]).astimezone(pytz.utc),
                                    "ip": res["resolve"],
                                    "source": "PT"
                                })
                        if "message" in raw_results:
                            if "quota_exceeded" in raw_results["message"]:
                                print("PT quota exceeded")
                                ptout = True
                        if not ptout:
                            client2 = EnrichmentRequest(conf["PassiveTotal"]["username"], conf["PassiveTotal"]['key'])
                            # Get OSINT
github PUNCH-Cyber / stoq-plugins-public / v1 / worker / passivetotal / passivetotal / passivetotal.py View on Github external
def get_dns(self, **kwargs):
        client = DnsRequest(self.username, self.apikey)

        keys = ['query', 'end', 'start', 'timeout', 'sources']

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

        if kwargs.get('unique'):
            return client.get_unique_resolutions(**params)
        else:
            return client.get_passive_dns(**params)