-
Notifications
You must be signed in to change notification settings - Fork 7
/
fetcher_bulkregistrarsDomain.py
36 lines (30 loc) · 1.05 KB
/
fetcher_bulkregistrarsDomain.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
import urllib, zipfile, cStringIO, os
import re
# User defined variables
feedaddr = 'http://mirror3.malwaredomains.com/files/bulk_registrars.zip'
zipfilename = 'bulk_registrars.txt'
feedID = 'bulkregistrars'
mkey = 'fetcher_bulkregistrarsDomain:feeddata'
killchain = 'unknown'
if os.path.isfile(zipfilename): os.remove(zipfilename)
zipwebfile = urllib.urlopen(feedaddr)
buffer = cStringIO.StringIO(zipwebfile.read())
zfile = zipfile.ZipFile(buffer)
myfile = zfile.extract(zipfilename)
# Now it's extracted to the local directory
f = open(zipfilename, 'r')
splitlines = f.read()
splitlines = splitlines.split('\n')
if os.path.isfile(zipfilename): os.remove(zipfilename)
print('domain,feedID,killchain,description,url')
for x in splitlines:
#print(x)
x = x.strip()
if re.search('^#', x): continue
if len(x) == 0: continue
x = re.sub('\*\.', '', x)
if re.search('\t#', x):
xlist = x.split('\t#') # Break up the line
print("%s,%s,%s,%s,%s" % (xlist[0], feedID, killchain, 'Bulk TLDs',xlist[1]))
else:
print("%s,%s,%s,%s," % (x, feedID, killchain, 'Bulk TLDs'))