自动化——bat——关闭高危端口

@echo off
title 创建IP安全策略,屏蔽135、139 . . . 等端口
echo “正在关闭,请等待”
netsh ipsec static add policy name=qianye
netsh ipsec static add filterlist name=Filter1
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=135 protocol=TCP
echo “135端口已经关闭”
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=136 protocol=TCP
echo “136端口已经关闭”
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=137 protocol=TCP
echo “137端口已经关闭”
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=138 protocol=TCP
echo “138端口已经关闭”
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=139 protocol=TCP
echo “139端口已经关闭”
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=445 protocol=TCP
echo “445端口已经关闭”
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=3389 protocol=TCP
echo “3389端口已经关闭”
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=1444 protocol=TCP
echo “1444端口已经关闭”
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=135 protocol=UDP
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=136 protocol=UDP
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=137 protocol=UDP
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=138 protocol=UDP
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=139 protocol=UDP
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=445 protocol=UDP
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=3389 protocol=UDP
netsh ipsec static add filter filterlist=Filter1 srcaddr=any dstaddr=me dstport=1444 protocol=UDP
netsh ipsec static add filteraction name=FilteraAtion1 action=block
netsh ipsec static add rule name=Rule1 policy=qianye filterlist=Filter1 filteraction=FilteraAtion1
netsh ipsec static set policy name=qianye assign=y
echo “恭喜您,危险端口已经关闭”
echo “按任意键退出 ”
pause

你可能感兴趣的:(bat,自动化,网络,服务器)