def get_test_phishing_domain(): __tracebackhide__ = True ch = CertHole() l = None tries = 0 l = ch.get_data(random.choice(['txt', 'xml'])) log.info("Collected list of domains from certhole: {}".format(l[:4])) wait(3) tries = 0 while tries < 200: try: c = random.choice(l) except TypeError as err: log.error(err) tries += 1 continue domain = c.domain_address if not "http://" in domain and not "https://" in domain: domain = "http://{}".format(domain) try: status = (requests.get(domain)).status_code wait(0.3) except requests.exceptions.ConnectionError as err: log.error(err) tries += 1 l.remove(c) continue if status in list([i for i in range(200, 400)]): return domain else: tries += 1 l.remove(c) continue
def test_get_domain_blocked_csv(self): ch = CertHole() domains = ch.get_data_blocked(default_type='csv') self.assertGreater(len(domains), 0) self.assertIsInstance(domains[0], Domain) self.assertIsNotNone(domains[0].domain_address) self.assertIsNotNone(domains[0].insert_date) self.assertIsNotNone(domains[0].delete_date)
def test_get_domain_json(self): ch = CertHole() domains = ch.get_data(default_type='json') self.assertGreater(len(domains), 0) self.assertIsInstance(domains[0], Domain) self.assertIsNotNone(domains[0].domain_address) self.assertIsNotNone(domains[0].insert_date) self.assertIn(domains[0].is_blocked, [True, False])
def get_phishing_domains(): ch = CertHole() return [d.domain_address for d in ch.get_data('txt')]
def test_get_domain_raw_data_txt(self): ch = CertHole() domains = ch.get_raw_data(default_type='txt') self.assertIsInstance(domains, list) self.assertGreater(len(domains), 0) self.assertIsInstance(domains[0], str)
def test_get_domain_blocked_txt(self): ch = CertHole() self.assertRaises(CertHoleTypeException, ch.get_data_blocked, 'txt')
def test_get_domain_wrong_type(self): ch = CertHole() self.assertRaises(CertHoleTypeException, ch.get_data, 'rar')
def test_wrong_url(self): ch = CertHole(base_url='http://hole.cert.pl/dommmmmains') self.assertRaises(CertHoleConnectionException, ch.get_raw_data)
def test_init(self): ch = CertHole() self.assertIsNotNone(ch)
def get_test_phishing_domain(): __tracebackhide__ = True ch = CertHole() l = ch.get_data('txt') return (random.choice(l)).domain_address