Wednesday, November 2, 2016

BLOCK TEAMVIEWER CONNECTIONS ON MIKROTIK

teamviewer8-laptop-computer-connectionHere is a guide how to block Team Viewer connection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/ip firewall address-list
add address=92.51.128.0/18 comment=Teamviewer_Server list=Teamviewer
add address=37.48.64.0/18 comment=Teamviewer_Server list=Teamviewer
add address=217.146.26.0/24 comment=Teamviewer_Server list=Teamviewer
add address=88.198.0.0/16 comment=Teamviewer_Server list=Teamviewer
add address=37.252.253.0/24 comment=Teamviewer_Server list=Teamviewer
add address=178.255.155.0/24 comment=Teamviewer_Server list=Teamviewer
add address=159.8.64.0/18 comment=Teamviewer_Server list=Teamviewer
add address=178.77.64.0/18 comment=Teamviewer_Server list=Teamviewer
 
 
/ip firewall filter
add action=drop chain=forward comment="Drop all traffic from address on \\ Teamviewer \\ address list" src-address-list=Teamviewer
add action=drop chain=input comment="Drop all traffic from address on \\ Teamviewer \\ address list" src-address-list=Teamviewer
With these two settings, your router will ignore any client not getting response from Team Viewer.

Mikrotik Limit Download File Extension


IP FIREWALL FILTER
Note: change "192.168.100.0/24" with your Network Rules
/ip firewall filter
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment=\
"Limit Download by using File Extension" content=.exe disabled=no protocol=tcp \
src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.zip disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.arj disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.lzh disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.3gp disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.gz disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.gzip disabled=\
no protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.tar disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.bin disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.mp3 disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.m4a disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.wav disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.rar disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.ram disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.aac disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.aif disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.avi disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.mpg disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.mpeg disabled=\
no protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.qt disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.plj disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.asf disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.mov disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.rm disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.rm1 disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.mp4 disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.wma disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.wmv disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.mpe disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.mpa disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.pdf disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.msi disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.ace disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.iso disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.img disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.ogg disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.7z disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.sea disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.sit disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.doc disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.ppt disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.pps disabled=no \
protocol=tcp src-address=192.168.100.0/24
add action=add-dst-to-address-list address-list=limit-extension \
address-list-timeout=1h chain=forward comment="" content=.flv disabled=no \
protocol=tcp src-address=192.168.100.0/24

IP FIREWALL MANGLE
/ip firewall mangle
add action=mark-packet chain=forward comment="Limit Download" disabled=no \
new-packet-mark=Limit-Download passthrough=no protocol=tcp src-address-list=limit-extension

QUEUE TREE
Note:queue limit is 256k you can change with other limit by change "256000"
/queue tree
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=256000 \
max-limit=256k name=Limit-Download packet-mark=limit-download parent=\
global-out priority=8 queue=default

Limit Queue Video Streaming


Limit Queue for Video Streaming "eg:Youtube" and Video Download using Layer7-Protocol.

LAYER7-PROTOCOL
/ip firewall layer7-protocol
add comment="" name=http-video regexp="http/(0\\.9|1\\.0|1\\.1)[\\x09-\\x0d ][\
1-5][0-9][0-9][\\x09-\\x0d-~]*(content-type: video)"

IP FIREWALL MANGLE
/ip firewall mangle
add action=mark-packet chain=forward comment="Limit Video Streaming" disabled=no \
layer7-protocol=http-video new-packet-mark=Limit-Video passthrough=no \
protocol=tcp

QUEUE TREE
Note: This sample use bandwith limit 256k, you can change the limit as you need by edited "256000" to other Limit you needed.
/queue tree
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=256000 \
max-limit=256000 name=Limit-Video packet-mark=Limit-Video parent=global-out \
priority=8 queue=default

Limit Bandwith using Layer 7-Protocol


SCRIPT I
/ip firewall layer7-protocol
add comment="" name=ISO regexp="\\.(iso)"
add comment="" name=NRG regexp="\\.(nrg)"
add comment="" name=RM regexp="\\.(rm)"
add comment="" name=RM1 regexp="\\.(rm1)"
add comment="" name=MP4 regexp="\\.(mp4)"
add comment="" name=AVI regexp="\\.(avi)"
add comment="" name=WAV regexp="\\.(wav)"
add comment="" name=MPG regexp="\\.(mpg)"
add comment="" name=MP3 regexp="\\.(mp3)"
add comment="" name=MPEG regexp="\\.(mpeg)"
add comment="" name=WMV regexp="\\.(wmv)"
add comment="" name=3GP regexp="\\.(3gp)"
add comment="" name=FLV regexp="\\.(flv)"
add comment="" name=MOV regexp="\\.(mov)"
add comment="" name=IMG regexp="\\.(img)"
add comment="" name=DOC regexp="\\.(doc)"
add comment="" name=PPT regexp="\\.(ppt)"
add comment="" name=PDF regexp="\\.(pdf)"
add comment="" name=EXE regexp="\\.(exe)"
add comment="" name=MSI regexp="\\.(msi)"
add comment="" name=7Z regexp="\\.(7z)"
add comment="" name=BIN regexp="\\.(bin)"
add comment="" name=GZ regexp="\\.(gz)"
add comment="" name=GZIP regexp="\\.(gzip)"
add comment="" name=TAR regexp="\\.(tar)"
add comment="" name=RAR regexp="\\.(rar)"
add comment="" name=ZIP regexp="\\.(zip)"

SCRIPT II
/ip firewall mangle
add action=mark-packet chain=forward comment="EKSTENSI-LAYER-7" disabled=no layer7-protocol=ISO new-packet-mark=ISO passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=NRG new-packet-mark=NRG passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=RM new-packet-mark=RM passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=RM1 new-packet-mark=RM1 passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=MP4 new-packet-mark=MP4 passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=AVI new-packet-mark=AVI passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=WAV new-packet-mark=WAV passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=MPG new-packet-mark=MPG passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=MP3 new-packet-mark=MP3 passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=MPEG new-packet-mark=MPEG passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=WMV new-packet-mark=WMV passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=3GP new-packet-mark=3GP passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=FLV new-packet-mark=FLV passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=MOV new-packet-mark=MOV passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=IMG new-packet-mark=IMG passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=DOC new-packet-mark=DOC passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=PPT new-packet-mark=PPT passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=PDF new-packet-mark=PDF passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=EXE new-packet-mark=EXE passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=MSI new-packet-mark=MSI passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=7Z new-packet-mark=7Z passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=BIN new-packet-mark=BIN passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=GZ new-packet-mark=GZ passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=GZIP new-packet-mark=GZIP passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=TAR new-packet-mark=TAR passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=RAR new-packet-mark=RAR passthrough=no
add action=mark-packet chain=forward comment="" disabled=no layer7-protocol=ZIP new-packet-mark=ZIP passthrough=no

SCRIPT III
/queue tree
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=256k max-limit=256k name=Limit-Download packet-mark=no-mark parent=global-out priority=8
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=ISO packet-mark=ISO parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=NRG packet-mark=NRG parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=RM packet-mark=RM parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=RM1 packet-mark=RM1 parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=MP4 packet-mark=MP4 parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=AVI packet-mark=AVI parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=WAV packet-mark=WAV parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=MPG packet-mark=MPG parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=MP3 packet-mark=MP3 parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=MPEG packet-mark=MPEG parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=WMV packet-mark=WMV parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=3GP packet-mark=3GP parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=FLV packet-mark=FLV parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=MOV packet-mark=MOV parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=IMG packet-mark=IMG parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=DOC packet-mark=DOC parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=PPT packet-mark=PPT parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=PDF packet-mark=PDF parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=EXE packet-mark=EXE parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=MSI packet-mark=MSI parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=7Z packet-mark=7Z parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=BIN packet-mark=BIN parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=GZ packet-mark=GZ parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=GZIP packet-mark=GZIP parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=TAR packet-mark=TAR parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=RAR packet-mark=RAR parent=Limit-Download priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 max-limit=0 name=ZIP packet-mark=ZIP parent=Limit-Download priority=8 queue=default

Blocking viruses port in mikrotik



/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1-2 comment="Socks Des Troie, Death"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=31 comment="Agent 31, Hacker's Paradise"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=37 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=41 comment="Deep Throat"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=58 comment="DM Setup"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=69-70 comment="W32.Evala.Worm"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=79 comment="Firehotcker"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=81 comment="Beagle.S"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=85-90 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=99 comment="Common Port for phishing scam sites"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=113 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=119 comment="Happy99"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=121 comment="Jammer Killah"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=129 comment="Password Generator Protocol"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=135-139 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=146 comment="Infector 1.3"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=382 comment="W32.Rotor"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=420 comment="W32.kibuv.b"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=421 comment="tcp Wrappers"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=445 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=456 comment="Hacker's Paradise"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=530 comment="W32.kibuv.worm"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=531 comment="Rasmin"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=555 comment="Stealth Spy, Phaze, 7-11 Trojan"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=559 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=587 comment="Sober worm Variants"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=593 comment="W.32.Sasser worm"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=666 comment="Attack FTP"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=777-778 comment="BackDoor.Netcrack.B"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=880 comment="Common Port for phishing scam sites"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=901-902 comment="Backdoor.Devil"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=911 comment="Dark Shadow"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=999-1001 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1011-1015 comment="Doly Trojan"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1024-1025 comment="Backdoor.lingosky"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1033-1034 comment="NetSpy"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1042 comment="Bla"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1045 comment="Rasmin"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1080-1081 comment="Backdoor.Zagaban"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1111 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1218 comment="Backdoor.Sazo"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1234 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1243 comment="Sub Seven"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1245 comment="VooDoo Doll"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1269 comment="Maverick's Matrix"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1394 comment="GoFriller, Backdoor G-1"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1433 comment="w32.spybot.ofn"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1492 comment="FTP99CMP"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1505 comment="FunkProxy "/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1509 comment="Psyber Streaming server"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1533-1534 comment="Backdoor.Miffice"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1534 comment="Bizex.Worm"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1600 comment="Shivka-Burka"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1604 comment="ICA Browser"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1751 comment="Loxbot.d"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1772 comment="Backdoor.NetControle"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1807 comment="SpySender"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1863 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1981 comment="Shockrave"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=1999-2005 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2023 comment="Ripper"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2041 comment="W32.korgo.a"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2080 comment="Backdoor.TJServ"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2090 comment="Backdoor.Expjan"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2115 comment="Bugs"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2140 comment="Deep Throat"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2155 comment="Illusion Mailer"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2283 comment="Dumaru.Y"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2322 comment="backdoor.shellbot"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2333-2335 comment="backdoor.shellbot, Eyeveg.worm.c"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2414 comment="vbs.shania"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2556 comment="Beagle.N"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2565 comment="Striker"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2583 comment="WinCrash"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2716 comment="The Prayer 1.2 -1.3"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2721 comment="Phase Zero"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2745 comment="Beagle.J"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2766 comment="W32.hllw.deadhat.b"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2801 comment="Phineas Phucker"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=2989 comment="Backdoor.Brador.A"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3024 comment="WinCrash"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3028 comment="Backdoor.Wortbot"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3030 comment="W32.Mytob.cz@mm"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3067 comment="W32.korgo.a"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3127-3198 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3256 comment="W32.HLLW.Dax"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3306 comment="Backdoor.Nemog.D"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3332 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3385 comment="w32.Mytob.kp@MM"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3410 comment="W32.mockbot.a.worm"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3456 comment="Backdoor.Fearic"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3459 comment="Eclipse 2000"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3547 comment="Backdoor.Amitis.B"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3700 comment="Portal of Doom"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3737 comment="Backdoor.helios"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=3791 comment="Eclypse"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4001 comment="Backdoor.OptixPro.13.C"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4092 comment="WinCrash"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4128 comment="Backdoor.rcserv"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4242 comment="Backdoor.Nemog.D"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4300 comment="Backdoor.smokodoor"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4387 comment="Phatbot"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4444 comment="More than 3 known worms and trojans use this port"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4512 comment="W32.mytob.db"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4567 comment="File Nail"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4590 comment="ICQ Trojan"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4646 comment="Backdoor.Nemog.D"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4661 comment="Backdoor.Nemog.D"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4751 comment="Beagle.U"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4820 comment="Backdoor.tuxder"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4888 comment="W32.Opanki"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4899 comment="W32.RaHack"/ip firewall filter add chain=viruses protocol= tcp action=drop dst-port=4903 comment="Common Port for phishing scam sites"

How to autodetect infected or spammer users and temporary block the SMTP output


Here can see in the solution which i invented and work excellent to autodetect and block SMTP viruses or spammers!
Only create these 2 rules in firewall forward:
/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"
When an infected user is autodetected with a virus worm or doing spam, the user is added to a spammer list and block the STMP outgoing by 1 day, all the values can be adjusted for different networks types or at your convenience
Antispam-rules.jpg

Logging detected users

Next, to display a red Log each 30 minutes listing the detected infected or spammers users using hotspot, add the next script:
/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 
Logging-spammers.jpg

DesertAdmin correction to the above rule set.
/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

Remove the following line if you already have a virus chain if not added it in.
add action=jump chain=forward comment="jump to the virus chain" disabled=no jump-target=virus

Also remember to move newly updated rules logically above your current jump forward rule. I like to keep my rules in orders of ports.
-Sincerely, DesertAdmin
Netinthewest says. (My first ever Mikrotik script) I got e-mail blacklisted so had to do something fast. I used DesertAdmins solution and it worked great. Took a while though to work out logging from Alessio's script.(screenshots were great) Turns out I needed to create the variable first before I could use it to log the spammers IP. I called it "spamip" This version works straight from the tin.
: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};
Thanks guys! You got me out of trouble.

Modification by Bob Burley
I liked and implemented this method of trapping spammers but I wanted to prevent unnecessary log entries every 30 minutes when the spammer list was empty. I made the following change to the script;
: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 };
}

Another Modification by Bob Burley
This version will also send an email ONLY ONCE for each new IP address detected. It uses another address-list called "email-log" to keep track of which addresses have been emailed. The addresses are removed from the "email-log" list after they timeout from the "spammer" list so that you will be notified again if that address is detected again.
: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 ""
  }
}