Skip to content

Commit 14b3803

Browse files
authored
Merge pull request #1067 from stratosphereips/alya/remove_hardcoded_tlds
use whois.validTlds() instead of hardcoded valid tlds
2 parents 1cb4978 + 4383948 commit 14b3803

File tree

1 file changed

+5
-110
lines changed

1 file changed

+5
-110
lines changed

modules/ip_info/ip_info.py

Lines changed: 5 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import asyncio
1616
import multiprocessing
1717

18+
1819
from modules.ip_info.jarm import JARM
1920
from slips_files.common.flow_classifier import FlowClassifier
21+
from slips_files.core.helpers.whitelist.whitelist import Whitelist
2022
from .asn_info import ASN
2123
from slips_files.common.abstracts.module import IModule
2224
from slips_files.common.slips_utils import utils
@@ -60,109 +62,7 @@ def init(self):
6062
# update asn every 1 month
6163
self.update_period = 2592000
6264
self.is_gw_mac_set = False
63-
# we can only getthe age of these tlds
64-
self.valid_tlds = [
65-
".ac_uk",
66-
".am",
67-
".amsterdam",
68-
".ar",
69-
".at",
70-
".au",
71-
".bank",
72-
".be",
73-
".biz",
74-
".br",
75-
".by",
76-
".ca",
77-
".cc",
78-
".cl",
79-
".club",
80-
".cn",
81-
".co",
82-
".co_il",
83-
".co_jp",
84-
".com",
85-
".com_au",
86-
".com_tr",
87-
".cr",
88-
".cz",
89-
".de",
90-
".download",
91-
".edu",
92-
".education",
93-
".eu",
94-
".fi",
95-
".fm",
96-
".fr",
97-
".frl",
98-
".game",
99-
".global_",
100-
".hk",
101-
".id_",
102-
".ie",
103-
".im",
104-
".in_",
105-
".info",
106-
".ink",
107-
".io",
108-
".ir",
109-
".is_",
110-
".it",
111-
".jp",
112-
".kr",
113-
".kz",
114-
".link",
115-
".lt",
116-
".lv",
117-
".me",
118-
".mobi",
119-
".mu",
120-
".mx",
121-
".name",
122-
".net",
123-
".ninja",
124-
".nl",
125-
".nu",
126-
".nyc",
127-
".nz",
128-
".online",
129-
".org",
130-
".pe",
131-
".pharmacy",
132-
".pl",
133-
".press",
134-
".pro",
135-
".pt",
136-
".pub",
137-
".pw",
138-
".rest",
139-
".ru",
140-
".ru_rf",
141-
".rw",
142-
".sale",
143-
".se",
144-
".security",
145-
".sh",
146-
".site",
147-
".space",
148-
".store",
149-
".tech",
150-
".tel",
151-
".theatre",
152-
".tickets",
153-
".trade",
154-
".tv",
155-
".ua",
156-
".uk",
157-
".us",
158-
".uz",
159-
".video",
160-
".website",
161-
".wiki",
162-
".work",
163-
".xyz",
164-
".za",
165-
]
65+
self.whitelist = Whitelist(self.logger, self.db)
16666
self.is_running_non_stop: bool = self.db.is_running_non_stop()
16767

16868
async def open_dbs(self):
@@ -348,13 +248,8 @@ def get_age(self, domain):
348248
if domain.endswith(".arpa") or domain.endswith(".local"):
349249
return False
350250

351-
# make sure whois supports the given tld
352-
for tld in self.valid_tlds:
353-
if domain.endswith(tld):
354-
# valid tld
355-
break
356-
else:
357-
# tld not supported
251+
domain_tld: str = self.whitelist.domain_analyzer.get_tld(domain)
252+
if domain_tld not in whois.validTlds():
358253
return False
359254

360255
cached_data = self.db.get_domain_data(domain)

0 commit comments

Comments
 (0)