10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
12
12
import re
13
+
13
14
import certstream
14
- import tqdm
15
15
import entropy
16
- from tld import get_tld
16
+ import tqdm
17
+ import yaml
17
18
from Levenshtein import distance
18
19
from termcolor import colored , cprint
19
-
20
- from suspicious import keywords , tlds
20
+ from tld import get_tld
21
21
22
22
from confusables import unconfuse
23
23
@@ -39,7 +39,7 @@ def score_domain(domain):
39
39
int: the score of `domain`.
40
40
"""
41
41
score = 0
42
- for t in tlds :
42
+ for t in suspicious [ ' tlds' ] :
43
43
if domain .endswith (t ):
44
44
score += 20
45
45
@@ -70,12 +70,12 @@ def score_domain(domain):
70
70
score += 10
71
71
72
72
# Testing keywords
73
- for word in keywords . keys () :
73
+ for word in suspicious [ ' keywords' ] :
74
74
if word in domain :
75
- score += keywords [word ]
75
+ score += suspicious [ ' keywords' ] [word ]
76
76
77
77
# Testing Levenshtein distance for strong keywords (>= 70 points) (ie. paypol)
78
- for key in [k for (k ,s ) in keywords .items () if s >= 70 ]:
78
+ for key in [k for (k ,s ) in suspicious [ ' keywords' ] .items () if s >= 70 ]:
79
79
# Removing too generic keywords (ie. mail.domain.com)
80
80
for word in [w for w in words_in_domain if w not in ['email' , 'mail' , 'cloud' ]]:
81
81
if distance (str (word ), str (key )) == 1 :
@@ -131,4 +131,19 @@ def callback(message, context):
131
131
132
132
133
133
if __name__ == '__main__' :
134
+ with open ('suspicious.yaml' , 'r' ) as f :
135
+ suspicious = yaml .safe_load (f )
136
+
137
+ with open ('external.yaml' , 'r' ) as f :
138
+ external = yaml .safe_load (f )
139
+
140
+ if external ['override_suspicious.yaml' ] is True :
141
+ suspicious = external
142
+ else :
143
+ if external ['keywords' ] is not None :
144
+ suspicious ['keywords' ].update (external ['keywords' ])
145
+
146
+ if external ['tlds' ] is not None :
147
+ suspicious ['tlds' ].update (external ['tlds' ])
148
+
134
149
certstream .listen_for_events (callback , url = certstream_url )
0 commit comments