forked from eecs-354-burp/python-whois
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·166 lines (145 loc) · 3.68 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
from gevent import monkey
monkey.patch_all()
import os
import sys
import gevent
from gevent.queue import Queue
import whois
domains = '''
google.jp
www.google.co.jp
www.google.com
www.google.com.ua
www.fsdfsdfsdfsd.google.com
digg.com
imdb.com
microsoft.com
www.google.org
ddarko.org
google.net
www.asp.net
google.pl
www.ddarko.pl
google.co.uk
google.co
google.de
yandex.ru
google.us
google.eu
google.me
google.be
google.biz
google.info
google.name
google.it
google.cz
google.fr
dfsdfsfsdf
test.ez.lv
http://www.google.com.ua/
http://www.php.su/
http://xn--j1ail.xn--p1ai/
xn--80aab5b.xn--p1ai
xn----7sbblj5b.xn--p1ai
XN--80AAFXO8ABI6B0EJ.XN--P1AI
elitelimousines.co.nz
automig.su
borum.su
meatvideokurs.ucoz.ru
kafe-skazka.kiev.ua
crimean.info
actualshop.ru
ruserver.ru
dsavtoservis.ru
zaborych.ru
webinar.abok.ru
schastlivie-deti.ru
www.google.co.jp
fsmaster.com.ua
aitoc.com
folimpex.ru
santechnika-kafel.dp.ua
crimea-kudo.com.ua
souz-vs.clan.su
angry-birds.org.ua
oborudovanie-bu.info
franshiza.denginadom.org
maz-kamaz-zil.narod2.ru
podnebesnaya.biz
vm4070.vps.agava.net
ufa1remont.ucoz.ru
'''
domains = '''
best-film.tv
filmpro.tv
lovi.tv
seone.tv
'''
'''
for domain in domains.split('\n'):
if domain:
print('-'*80)
print(domain)
if domain.endswith('/'):
domain = domain[:-1]
domain = domain.replace('http://', '').replace('https://', '')
try:
w = whois.query(domain, ignore_returncode=1)
if w:
wd = w.__dict__
for k, v in wd.items():
print('%20s\t"%s"' % (k, v))
except Exception as ex:
excType, excObj, excTb = sys.exc_info()
fname = os.path.split(excTb.tb_frame.f_code.co_filename)[1]
print 'Exception {} caught in file {} on line {}: "{}"'.format(excType, fname, excTb.tb_lineno, ex)
'''
class WhoisThreadingTester(object):
def __init__(self):
self._domainsQueue = Queue()
def addDomain(self, domain, resultReadyCallback):
if not callable(resultReadyCallback):
raise ValueError('resultReadyCallback must be callable')
domain = domain.replace('https://', '').replace('http://', '')
if domain.startswith('www.'):
domain = domain[4:]
if domain.endswith('/'):
domain = domain[:-1]
self._domainsQueue.put({domain: resultReadyCallback})
print 'add domain {}'.format(domain)
def _whoisGetter(self):
while True:
gevent.sleep(0)
for nextTask in self._domainsQueue.get().items():
result = None
domain, resultReadyCallback = nextTask
try:
result = whois.query(domain, ignore_returncode=True)
except Exception as ex:
print type(ex)
print ex
resultReadyCallback(result)
def start(self):
try:
gevent.joinall([gevent.spawn(self._whoisGetter)])
except (KeyboardInterrupt, gevent.hub.LoopExit) as ex:
print 'Exit...'
except Exception as ex:
print type(ex)
print ex
if __name__ == '__main__':
def readyCallback(val):
print('-'*80)
print type(val)
if isinstance(val, whois.Domain):
for key in val.__dict__:
print '{} => {}'.format(key, val.__dict__[key])
def test(whoisChecker):
#gevent.sleep(10)
for domain in domains.split('\n'):
if domain:
whoisChecker.addDomain(domain, readyCallback)
#gevent.sleep()
whoisChecker = WhoisThreadingTester()
gevent.spawn(test, whoisChecker)
whoisChecker.start()