misp-warninglists/tools/generate-tlds.py

31 lines
779 B
Python
Raw Normal View History

2020-07-06 16:17:54 +02:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from generator import download, get_version, write_to_file
def process(url, dst):
warninglist = {
'name': 'TLDs as known by IANA',
'version': get_version(),
'description': 'Event contains one or more TLDs as attribute with an IDS flag set',
2020-07-21 13:42:50 +02:00
'list': [],
'matching_attributes': ["hostname", "domain", "domain|ip"],
'type': 'string'
}
2020-07-21 13:42:50 +02:00
r = download(url)
for tld in r.text.splitlines():
if tld.startswith('#'):
continue
warninglist['list'].append(tld)
write_to_file(warninglist, dst)
if __name__ == '__main__':
tlds_url = 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt'
tlds_dst = 'tlds'
process(tlds_url, tlds_dst)