boen
thanks for the script. I did create a python version that parses BOTH lists into a single file so that it can be imported by Mikrotik automatically if anyone wants it.
# : Imports
import urllib.request
import re
# : Specify URL_File To Be Parsed
dshield_url = "
http://feeds.dshield.org/topips.txt"
# : Opens URL_File To Be Read
dshield_raw_text = urllib.request.urlopen(dshield_url)
dshield_string = str(dshield_raw_text.read())
# : Regex Pattern To Locate IPv4 Addresses
ipv4_pattern = r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
# : Find All IP Addresses From URL
iplist = re.findall( ipv4_pattern, dshield_string )
# : Create RSC Formatted File & Open For Writing
dshield_rsc = ".\DShield.rsc"
dshield_clean_text = open(dshield_rsc, "w")
# : Write Results To File
dshield_clean_text.write("/ip firewall address-list\n")
for ip in iplist:
dshield_clean_text.write("add list=DShield address=" + (ip) + "/32\n")
# : Specify URL_File To Be Parsed
dshield_url = "
http://feeds.dshield.org/block.txt"
# : Opens URL_File To Be Read
dshield_raw_text = urllib.request.urlopen(dshield_url)
dshield_string = str(dshield_raw_text.read())
# : Regex Pattern To Locate IPv4 Addresses Ending In 0
ipv4_pattern = r'\d{1,3}\.\d{1,3}\.\d{1,3}\.0'
# : Find All IP Addresses From URL
iplist = re.findall( ipv4_pattern, dshield_string )
# : Write Results To File
for ip in iplist:
dshield_clean_text.write("add list=DShield address=" + (ip) + "/24\n")
# : Close File
dshield_clean_text.close()