کد زیر رو در terminal وارد کنید :
/ip firewall filter
add chain=forward protocol=tcp dst-port=25 src-address-list=spammer
action=drop comment="BLOCK SPAMMERS OR INFECTED USERS"
add chain=forward protocol=tcp dst-port=25 connection-limit=30,32 limit=50,5 action=add-src-to-address-list
address-list=spammer address-list-timeout=1d comment="Detect and add-list SMTP virus or spammers"
/system script
add name="spammers" source=":log error \"----------Users detected like \
SPAMMERS -------------\";
\n:foreach i in \[/ip firewall address-list find \
list=spammer\] do={:set usser \[/ip firewall address-list get \$i \
address\];
\n:foreach j in=\[/ip hotspot active find address=\$usser\] \
do={:set ip \[/ip hotspot active get \$j user\];
\n:log error \$ip;
\n:log \
error \$usser} };" policy=ftp,read,write,policy,test,winbox
/ip firewall filter
add action=drop chain=virus comment="Drop Spammer" disabled=no dst-port=25 protocol=tcp src-address-list=spammer
add action=add-src-to-address-list address-list=spammer address-list-timeout=1d chain=virus comment="add to spammer list" connection-limit=30,32 disabled=no dst-port=25 limit=50,5 protocol=tcp
add action=jump chain=forward comment="jump to the virus chain" disabled=no jump-target=virus
:global spamip;
:log error "----------Users detected like SPAMMERS -------------";
:foreach i in [/ip firewall address-list find list=spammer] do={:set spamip [/ip firewall address-list get $i address];
:log error $spamip};
:global spamip;
:if ([:len [/ip firewall address-list find list=spammer]]>0) do= {
:log error "---------- IP's detected as SPAMMERS ----------";
:foreach i in [/ip firewall address-list find list=spammer] do={ :set spamip [/ip firewall address-list get $i address];
:log error $spamip };
}
:local emailip
:local spamip
:local keepflag 0
:foreach j in [/ip firewall address-list find list=email-log] do={
:set emailip [/ip firewall address-list get $j address]
:foreach i in [/ip firewall address-list find list=spammer] do={
:set spamip [/ip firewall address-list get $i address]
:if ($emailip=$spamip) do={:set keepflag 1}
}
:if ($keepflag=0) do={/ip firewall address-list remove $j} else= {:set keepflag 0}
}
:if ([:len [/ip firewall address-list find list=spammer]]>0) do={
:local bodymsg ""
:local emailflag 0
:log error "---------- IP's detected as SPAMMERS ----------"
:foreach i in [/ip firewall address-list find list=spammer] do={
:set spamip [/ip firewall address-list get $i address]
:log error $spamip
}
:foreach i in [/ip firewall address-list find list=spammer] do={
:set spamip [/ip firewall address-list get $i address]
:foreach j in [/ip firewall address-list find list=email-log] do={
:set emailip [/ip firewall address-list get $j address]
:if ($spamip=$emailip) do={:set emailflag 1}
}
:if ($emailflag=0) do={
:set bodymsg ($bodymsg . $spamip . "\r\n")
/ip firewall address-list add address=$spamip list=email-log
} else= {:set emailflag 0}
}
:if ([:len $bodymsg]>0) do={
/tool e-mail send from=MikroTik-XX@yourisp.com server=xxx.xxx.xxx.xxx to=youremail@yourisp.com subject="IP's detected as SPAMMERS" body=$bodymsg
:set bodymsg ""
}
}