def run(self): super(Pdns, self).run() if self.args is None: return if self.args.url: url = self.args.url elif PDNS_URL: url = PDNS_URL else: self.log('error', 'You need to give the server to query.') return if self.args.user: user = self.args.user else: user = PDNS_USER if self.args.password: password = self.args.password else: password = PDNS_PASS pdns = PyPDNS(url.rstrip('/'), (user, password)) try: data = pdns.query(self.args.query) except Exception as e: self.log('error', e) return if not data: self.log('error', 'Unable to find {}.'.format(self.args.query)) return for d in data: self.log('success', "{} -> {} ({} requests)\n\t RR Name: {} - Data: {}".format( d['time_first'].strftime("%Y/%m/%d %H:%M"), d['time_last'].strftime("%Y/%m/%d %H:%M"), d['count'], d['rrname'], d['rdata']))
def run(self): super(Pdns, self).run() if self.args is None: return if self.args.url: url = self.args.url elif cfg.pdns.pdns_url: url = cfg.pdns.pdns_url else: self.log('error', 'You need to give the server to query.') return if self.args.user: user = self.args.user else: user = cfg.pdns.pdns_user if self.args.password: password = self.args.password else: password = cfg.pdns.pdns_pass self.pdns = PyPDNS(url.rstrip('/'), (user, password)) if self.args.misp: self.misp(self.args.misp, self.args.verbose) else: self.query(self.args.query, self.args.verbose)
def pdnscircl(url, user, passwd, q): cached = _cache_get(q, 'pdns') if cached is not None: return cached pdnscircl = PyPDNS(url, basic_auth=(user, passwd)) response = pdnscircl.query(q) all_uniq = [] for e in reversed(response): host = e['rrname'].lower() if host in all_uniq: continue else: all_uniq.append(host) response = (len(all_uniq), all_uniq[:5]) _cache_set(q, response, 'pdns') return response
def pdnscircl(url, user, passwd, q): cached = _cache_get(q, 'pdns') if cached is not None: return cached pdns = PyPDNS(url, basic_auth=(user, passwd)) response = pdns.query(q) all_uniq = [] for e in reversed(response): host = e['rrname'].lower() if host in all_uniq: continue else: all_uniq.append(host) response = (len(all_uniq), all_uniq[:5]) _cache_set(q, response, 'pdns') return response
def test_not_auth(self): x = PyPDNS(basic_auth=('username', 'yourpassword')) with self.assertRaises(UnauthorizedError): x.query('www.microsoft.com')
def test_not_auth(self): x = PyPDNS(basic_auth=('username','yourpassword')) with self.assertRaises(UnauthorizedError): x.query('www.microsoft.com')