-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
61 lines (49 loc) · 1.92 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os, re, json
from datetime import datetime, timedelta
import confusables
import pendulum
from corona import CZDS, WhoisDs, Corona
USERNAME = os.environ['USERNAME']
PASSWORD = os.environ['PASSWORD']
class RunDomainData(object):
_date = datetime.today() - timedelta(days=2)
_save_path = './data/{folder}/{date}/'
def __run_czds(self):
print('Running CZDS')
czds_save_path = self._save_path.format(folder='zone_files',date=self._date.strftime('%Y-%m-%d'))
czds = CZDS(USERNAME,PASSWORD, save_path=czds_save_path).download()
print('Completed CZDS')
def __run_whoids(self):
print('Running WHOIDS')
whoisds_save_path = self._save_path.format(folder='whoisds_files',date=self._date.strftime('%Y-%m-%d'))
whoisds = WhoisDs(date=pendulum.now('UTC').add(days=-2), save_path=whoisds_save_path).run()
print('Completed WHOISDS')
def __run_blacklist(self):
print('Running Blacklist')
blacklist_config = open('blacklist.config', 'r').read().split('\n')
blacklist_terms = []
for item in blacklist_config:
if len(item.strip()) > 0:
blacklist_terms.append(item.strip())
term_list = []
for item in blacklist_terms:
term_list.append({
'term': item,
'value': re.compile(confusables.confusable_regex(item, include_character_padding=False), re.IGNORECASE | re.UNICODE)
})
corona = Corona().generate(term_list)
print('Completed Blacklist')
def run(self):
try:
self.__run_czds()
except:
raise Exception('Error running CZDS')
try:
self.__run_whoids()
except:
raise Exception('Error running WHOISDS')
try:
self.__run_blacklist()
except:
raise Exception('Error running Blacklist')
RunDomainData().run()