forked from mboot-github/python-whois
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·444 lines (401 loc) · 8.19 KB
/
test.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
#!/usr/bin/python3
import whois
Verbose = True
NEW_TESTS = """
# https://www.rfc-editor.org/rfc/rfc6761.html
# The domains "example.", "example.com.", "example.net.", "example.org.",
# and any names falling within those domains,
# are special in the following ways:
# TODO future:
# example.com # All example names are registered in perpetuity to IANA:
# OK NOW:
# abroco.me
# wp.pl
# New TLD
whois.aero
nic.cd
register.bg
bit.ly
nic.re
nic.pet
twnic.net.tw
nic.td
nic.moe
nic.mg
nic.love
google.cf
google.bo
thnic.co.th
nic.br
nusurionuy5ff.at
phila.ac.ug # has a None date
nic.ma # error in ma: missing extend
merlin.ua # Unknown date format: '2006-03-30 13:26:31+03:00'
www.google.co.jp
# test next item if first one has no whois data
dns1.carnet.hr # get actual info from carnet.hr
# now a secondlevel tld
ns1.cfi.co.ug # should go to: cfi.co.ug but not to: co.ug
# test IDNs
meta.中文网
meta.在线
# NEW TLDs
meta.accountant
meta.audio
meta.blackfriday
meta.christmas
meta.cricket
meta.date
meta.diet
meta.faith
meta.flowers
meta.gift
meta.guitars
meta.help
meta.hiphop
meta.hosting
meta.juegos
meta.loan
meta.party
meta.photo
meta.property
meta.racing
meta.ren
meta.review
meta.science
meta.sexy
meta.tattoo
meta.wang
meta.webcam
"""
PrivateRegistry = """
google.al
google.ch
google.cw
google.ga
google.gr
google.hu
google.li
google.mp
google.sr
google.tk
google.to
google.vn
nic.ba # PrivateReg
net.pk # PrivateReg
mynic.my # PrivateReg
nic.es # PrivateReg
nic.ec # PrivateReg
nic.zw # PrivateReg
gooogle.onion # PrivateReg
google.ke # PrivateReg
whois.az # PrivateReg
"""
InvalidTld = """
"""
FailedParsing = """
afilias.com.au
amazon.courses
bretagne.bzh
davidetson.ovh
ghc.fit
google.com.au
google.dev
sylblog.xin
vols.cat
www.fsdfsdfsdfsd.google.com
www.google.com
"""
UnknownDateFormat = """
"""
# these are all supposed to result in data or None but no errors
DOMAINS = """
abroco.me
agodasylumsy.top
agtaster.kiwi
amazon.study
america.com
anthropology.website
autobuyer.site
belgium.com
bellerose.asia
bloom.space
buzzi.space
ci.security
clubclio.shop
colooder.app
congres.nc
curly.red
custler.com # may have issues with gethostaddr
darkops.site
ddarko.org
digg.com
discjockey.website
doramy.club
dot.ml
edc.click
elcomercio.pe
emeralds.site
example.com
fraukesart.de # status: free
google.am
google.aw
google.be
google.biz
google.bj
google.ca
google.cat
google.cc
google.cl
google.co
google.co.il
google.com.ar
google.com.br
google.com.co
google.com.tr
google.co.uk
google.cr
google.cz
google.de
google.eu
google.fi
google.fm
google.fr
google.game
google.global
google.hk
google.im
google.in
google.info
google.ink
google.io
google.is
google.it
google.jp
google.link
google.lt
google.me
google.mu
google.name
google.net
google.nl
google.nu
google.nyc
google.online
google.pl
google.press
google.pt
google.pub
google.pw
google.rw
google.sale
google.se
google.security
google.site
google.sk
google.space
google.store
google.tech
google.tel
google.theatre
google.tickets
google.trade
google.tv
google.us
google.website
google.wiki
google.xyz
gopro.com
guinness.ie
hisd.cloud
icee.sa
imdb.com
in.security
invr.space
jisc.ac.uk
juniper.security
karibu.tz
kono.store
kubet77.win
livechat.website
loop.space
luminor.ee
manniswindows.site
medicaldata.icu
microsoft.com
minigames.best
mphimmoitv.com
netsec.ninja
nic.art
nic.auto
nic.autos
nic.baby
nic.bar
nic.beauty
nic.best
nic.bj
nic.blog
nic.boats
nic.bond
nic.build
nic.cam
nic.car
nic.cars
nic.ceo
nic.cfd
nic.college
nic.coop
nic.cyou
nic.dealer
nic.desi
nic.fans
nic.feedback
nic.forum
nic.frl
nic.fun
nic.gent
nic.hair
nic.homes
nic.host
nic.icu
nic.inc
nic.kred
nic.london
nic.luxury
nic.makeup
nic.me
nic.monster
nic.motorcycles
nic.online
nic.ooo
nic.press
nic.protection
nic.qpon
nic.quest
nic.reit
nic.rent
nic.rest
nic.saarland
nic.sbs
nic.security
nic.site
nic.skin
nic.space
nic.storage
nic.store
nic.tech
nic.theatre
nic.tickets
nic.ua
nic.uno
nic.website
nic.xyz
nic.yachts
nic.zuerich
office.com
pep.security
phimchill.tv
python.org
rans88.vip
register.bank
terra.com.pe
test.education
test.ez.lv
theobservatory.space
timphillipsgarage.bond
token.security
tut.by
viacom.tech
vidange.tn
wonder.store
www.asp.net
www.ddarko.pl
www.google.co.jp
www.google.org
yandex.ru
yandex.ua
youtu.be
youtube.com
zieit.edu.ua # has issues with date/time strings
"""
failure = {}
def prepItem(d):
print("-" * 80)
print(d)
def testItem(d):
w = whois.query(d, ignore_returncode=True, verbose=Verbose, internationalized=True)
if w:
wd = w.__dict__
for k, v in wd.items():
print('%20s\t"%s"' % (k, v))
else:
print("None")
def errorItem(d, e, what="Generic"):
print(f"Caught {what} Exception")
failure[d] = {"exception": what, "result": e}
message = f"""
Error : {e},
On Domain: {d}
"""
print(message)
def testDomains(aList):
for d in aList:
# skip empty lines
if not d:
continue
if len(d.strip()) == 0:
continue
# skip comments
if d.strip().startswith("#"):
continue
# skip comments behind the domain
d = d.split("#")[0]
d = d.strip()
prepItem(d)
try:
testItem(d)
except whois.UnknownTld as e:
errorItem(d, e, what="UnknownTld")
except whois.FailedParsingWhoisOutput as e:
errorItem(d, e, what="FailedParsingWhoisOutput")
except whois.UnknownDateFormat as e:
errorItem(d, e, what="UnknownDateFormat")
except whois.WhoisCommandFailed as e:
errorItem(d, e, what="WhoisCommandFailed")
except whois.WhoisQuotaExceeded as e:
errorItem(d, e, what="WhoisQuotaExceeded")
except whois.WhoisPrivateRegistry as e:
errorItem(d, e, what="WhoisPrivateRegistry")
except Exception as e:
errorItem(d, e, what="Generic")
def main():
# ----------------------------
testAllTlds = True
testOnlyProblems = True
testOnlyNew = True
# ----------------------------
if testAllTlds is True:
print("Tld's currently supported")
zz = whois.validTlds()
for tld in zz:
print(tld)
print("\n========================================\n")
print("Testing")
testDomains(NEW_TESTS.split("\n"))
if testOnlyNew is False:
if testOnlyProblems is False:
print("\n========================================\n")
testDomains(DOMAINS.split("\n"))
print("\n========================================\n")
testDomains(PrivateRegistry.split("\n"))
print("\n========================================\n")
testDomains(InvalidTld.split("\n"))
print("\n========================================\n")
testDomains(FailedParsing.split("\n"))
print("\n========================================\n")
testDomains(UnknownDateFormat.split("\n"))
print(f"Failure during test : {len(failure)}")
print("\n# ========================")
for i in sorted(failure.keys()):
print(i, failure[i])
main()