Criar lista de blacklist dinamica Mikrotik (fetch)
Criar os arquivos individuais no servidor web com o seguinte scripts, funciona para qualquer fonte:
#!/bin/sh
set -x
saveTo=/var/www/html/blacklist
now=$(date);
echo "# Generated on $now" > $saveTo/
echo "/ip firewall address-list" >> $saveTo/dshield.rsc
wget -q -O - http://feeds.dshield.org/block.txt | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.0\t/ { print "add list=blacklist address=" $1 "/24 comment=DShield";}' >> $saveTo/dshield.rsc
echo "# Generated on $now" > $saveTo/spamhaus.rsc
echo "/ip firewall address-list" >> $saveTo/spamhaus.rsc
wget -q -O - http://www.spamhaus.org/drop/drop.lasso | awk --posix '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\// { print "add list=blacklist address=" $1 " comment=SpamHaus";}' >> $saveTo/spamhaus.rsc
echo "# Generated on $now" > $saveTo/malc0de.rsc
echo "/ip firewall address-list" >> $saveTo/malc0de.rsc
wget -q -O - http://malc0de.com/bl/IP_Blacklist.txt | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ { print "add list=blacklist address=" $1 " comment=malc0de";}' >> $saveTo/malc0de.rsc
echo "# Generated on $now" > $saveTo/serpro.rsc
echo "/ip firewall address-list" >> $saveTo/serpro.rsc
wget -q -O - https://s3.i02.estaleiro.serpro.gov.br/blocklist/blocklist.txt | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ { print "add list=blacklist address=" $1 " comment=serpro";}' >> $saveTo/serpro.rsc
---------------------------------------------------------------------
Após isso criar scripts de atualização para cada link ajustando o comentario:
<pre>
# Script which will download the drop list as a text file
/system script add name="Download_serpro" source={
/tool fetch url="http://exemplo.com.br/blacklist/serpro.rsc" mode=http;
:log info "Downloaded serpro.rsc from megadedicados";
}
# Script which will Remove old serpro list and add new one
/system script add name="Replace_serpro" source={
/ip firewall address-list remove [find where comment="serpro"]
/import file-name=serpro.rsc;
:log info "Removed old serpro records and imported new list";
}
# Schedule the download and application of the serpro list
/system scheduler add comment="Download serpro list" interval=3d \
name="DownloadserproList" on-event=Download_serpro \
start-date=jan/01/1970 start-time=23:58:29
/system scheduler add comment="Apply serpro List" interval=3d \
name="InstallserproList" on-event=Replace_serpro \
start-date=jan/01/1970 start-time=00:03:29
</pre>
Comentários
Postar um comentário