查看: 9496|回复: 26
收起左侧

[分享] 一键关闭135-139及445脚本和相关服务,win8.1亲测通过

  [复制链接]
easyt
发表于 2017-5-15 00:47:04 | 显示全部楼层 |阅读模式
本帖最后由 easyt 于 2017-5-16 22:03 编辑

除了打补丁,还要关端口和关相应的服务,写了下面这个一键脚本,在windows 8.1上测试通过,发上来做备份,有需要拿。

[mw_shl_code=css,true]@echo off
color 1f
title 您正在使用一键屏蔽危险端口和服务 by et
echo 您正在使用一键屏蔽危险端口和服务
echo "正在帮您关闭这些危险端口,请稍等"
echo “正在开启Windows防火墙服务”
net start MpsSvc
echo ”正在帮您开启Windows防火墙自启动“
sc config MpsSvc start= auto
echo ”正在启用防火墙“
netsh advfirewall set allprofiles state on
echo "正在帮您屏蔽端口...."
echo.
echo.
echo.
echo 正在屏蔽135端口 请稍候…
netsh advfirewall firewall delete rule name = "Disable port 135 - TCP"
netsh advfirewall firewall add rule name = "Disable port 135 - TCP" dir = in action = block protocol = TCP localport = 135
echo.
netsh advfirewall firewall delete rule name = "Disable port 135 - UDP"
netsh advfirewall firewall add rule name = "Disable port 135 - UDP" dir = in action = block protocol = UDP localport = 135
echo.
echo 正在屏蔽137端口 请稍候…
netsh advfirewall firewall delete rule name = "Disable port 137 - TCP"
netsh advfirewall firewall add rule name = "Disable port 137 - TCP" dir = in action = block protocol = TCP localport = 137
echo.
netsh advfirewall firewall delete rule name = "Disable port 137 - UDP"
netsh advfirewall firewall add rule name = "Disable port 137 - UDP" dir = in action = block protocol = UDP localport = 137
echo.
echo 正在屏蔽138端口 请稍候…
netsh advfirewall firewall delete rule name = "Disable port 138 - TCP"
netsh advfirewall firewall add rule name = "Disable port 138 - TCP" dir = in action = block protocol = TCP localport = 138
echo.
netsh advfirewall firewall delete rule name = "Disable port 138 - UDP"
netsh advfirewall firewall add rule name = "Disable port 138 - UDP" dir = in action = block protocol = UDP localport = 138
echo.
echo 正在屏蔽139端口 请稍候…
netsh advfirewall firewall delete rule name = "Disable port 139 - TCP"
netsh advfirewall firewall add rule name = "Disable port 139 - TCP" dir = in action = block protocol = TCP localport = 139
echo.
netsh advfirewall firewall delete rule name = "Disable port 139 - UDP"
netsh advfirewall firewall add rule name = "Disable port 139 - UDP" dir = in action = block protocol = UDP localport = 139
echo.
echo 正在关闭445端口 请稍候…
netsh advfirewall firewall delete rule name = "Disable port 445 - TCP"
netsh advfirewall firewall add rule name = "Disable port 445 - TCP" dir = in action = block protocol = TCP localport = 445
echo.
netsh advfirewall firewall delete rule name = "Disable port 445 - UDP"
netsh advfirewall firewall add rule name = "Disable port 445 - UDP" dir = in action = block protocol = UDP localport = 445
echo.

echo "危险端口已经用Windows防火墙屏蔽成功"

echo.
echo ----------------
echo “正在关闭Workstation(LanmanWorkstation)服务”
sc stop LanmanWorkstation
sc config LanmanWorkstation start= disabled

echo.
echo ----------------
echo “正在关闭Server(LanmanServer)服务”
sc stop LanmanServer
sc config LanmanServer start= disabled

echo.
echo ----------------
echo “正在关闭TCP/IP NetBIOS Helper(lmhosts)共享服务”
sc stop lmhosts
sc config lmhosts start= disabled

echo.
echo ----------------
echo “正在关闭Distributed Transaction Coordinator(MSDTC)共享服务”
sc stop MSDTC
sc config MSDTC start= disabled

echo.
echo ----------------
echo “正在关闭NetBT服务”
sc stop NetBT
sc config NetBT start= disabled

echo.
echo ----------------
reg add "hklm\System\CurrentControlSet\Services\NetBT\Parameters" /v "SMBDeviceEnabled" /t reg_dword /d "0" /f
reg add "hklm\SOFTWARE\Microsoft\Ole" /v "EnableDCOM" /t reg_sz /d "N" /f
reg add "hklm\SOFTWARE\Microsoft\Rpc" /v "DCOM Protocols" /t reg_multi_sz /d "" /f

echo.
echo ----------------
echo "恭喜您,危险端口已经关闭,请重新启动电脑后用netstat -an查看本地端口"

echo 按任意键退出
pause>nul
[/mw_shl_code]

风之咩~
发表于 2017-5-15 01:07:42 | 显示全部楼层
katar2048
发表于 2017-5-15 07:01:15 | 显示全部楼层
好像在Win7及以上才能用
抱柱人
发表于 2017-5-15 09:28:39 | 显示全部楼层
可以测试一下其他系统
断剑留痕
发表于 2017-5-15 10:54:41 | 显示全部楼层
有没有不开启防火墙就能关闭端口的方法
liumz1963
发表于 2017-5-15 11:43:55 | 显示全部楼层
xp上如何?
酷酷万人迷
发表于 2017-5-15 12:50:57 来自手机 | 显示全部楼层
win7能用吗?
随便注册
发表于 2017-5-15 13:10:57 | 显示全部楼层
断剑留痕 发表于 2017-5-15 10:54
有没有不开启防火墙就能关闭端口的方法

防范和遏制“Eternal Blue”病毒攻击指南_凤凰资讯
http://news.ifeng.com/a/20170513/51087512_0.shtml

IP策略也可以,但是只能一个端口一个端口的添加,而防火墙可以一次写几个。
用IP安全策略封闭端口 - xztslsz的专栏 - 博客频道 - CSDN.NET
http://blog.csdn.net/xztslsz/article/details/1621892
ELOHIM
发表于 2017-5-15 13:54:12 | 显示全部楼层

这都是安装完系统以后联网以前要做的必备课,为什么现在才做?
ynpejcxzz
发表于 2017-5-15 20:12:56 | 显示全部楼层
怎么看445端口关闭的状态?

您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

手机版|杀毒软件|软件论坛| 卡饭论坛

Copyright © KaFan  KaFan.cn All Rights Reserved.

Powered by Discuz! X3.4( 沪ICP备2020031077号-2 ) GMT+8, 2024-11-24 13:39 , Processed in 0.129892 second(s), 17 queries .

卡饭网所发布的一切软件、样本、工具、文章等仅限用于学习和研究,不得将上述内容用于商业或者其他非法用途,否则产生的一切后果自负,本站信息来自网络,版权争议问题与本站无关,您必须在下载后的24小时之内从您的电脑中彻底删除上述信息,如有问题请通过邮件与我们联系。

快速回复 客服 返回顶部 返回列表