Wndows关闭高危端口&修改远程端口命令

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Wndows关闭高危端口&修改远程端口命令相关的知识,希望对你有一定的参考价值。

Wndows关闭高危端口&修改远程端口命令

修改3899端口

#复制如下命令到写字板,以bat格式保存:
@echo off
color 0a
title  修改Windows 远程桌面服务端口号
echo *******************************************************************
echo * 请输入您要更改的远程桌面端口号,范围:1024-65535,不能与其他端口冲突*
echo *******************************************************************
echo.
set /p port=请输入端口:
reg add "HKLMSYSTEMCurrentControlSetControlTerminal ServerWds
dpwdTds	cp" /v PortNumber /t reg_dword /d %port% /f
reg add "HKLMSYSTEMCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp" /v PortNumber /t reg_dword /d %port% /f
netsh firewall set opmode mode = enable
netsh firewall set portopening all 80 web enable
netsh firewall set portopening all 3389 remote-pre enable
netsh firewall set portopening all %port% remote enable
echo.
echo *******************************
echo * 重新启动远程桌面*
echo *******************************
reg add "HKLMSYSTEMCurrentControlSetControlTerminal Server" /v fDenyTSConnections /t reg_dword /d 1 /f
reg add "HKLMSYSTEMCurrentControlSetControlTerminal Server" /v fDenyTSConnections /t reg_dword /d 0 /f
echo.
echo 下面开始重新启动电脑以生效,请选择启动方式:
echo 选择1手动重新启动
echo 选择2自动重新启动
set /p select=请您选择1,2:
if  "%select%"=="1"  goto A
if  "%select%"=="2"  goto B
pause
exit
:A
echo 退出,请手动重新启动电脑
pause
exit
:B
shutdown -r -t 1
pause
exit

关闭windows高危端口

#同样复制命令,以bat格式保存,在服务器运行即可
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
@echo off 
color 1f 
title 关闭135 137 138 139 445 端口
echo. 
echo. 
echo. 
echo 正在关闭135端口 请稍候… 
netsh advfirewall firewall add rule name = "Disable port 135 - TCP" dir = in action = block protocol = TCP localport = 135
echo. 
netsh advfirewall firewall add rule name = "Disable port 135 - UDP" dir = in action = block protocol = UDP localport = 135
echo. 
echo 正在关闭137端口 请稍候… 
netsh advfirewall firewall add rule name = "Disable port 137 - TCP" dir = in action = block protocol = TCP localport = 137
echo. 
netsh advfirewall firewall add rule name = "Disable port 137 - UDP" dir = in action = block protocol = UDP localport = 137
echo. 
echo 正在关闭138端口 请稍候… 
netsh advfirewall firewall add rule name = "Disable port 138 - TCP" dir = in action = block protocol = TCP localport = 138
echo. 
netsh advfirewall firewall add rule name = "Disable port 138 - UDP" dir = in action = block protocol = UDP localport = 138
echo. 
echo 正在关闭139端口 请稍候… 
netsh advfirewall firewall add rule name = "Disable port 139 - TCP" dir = in action = block protocol = TCP localport = 139
echo. 
netsh advfirewall firewall add rule name = "Disable port 139 - UDP" dir = in action = block protocol = UDP localport = 139
echo. 
echo 正在关闭445端口 请稍候… 
netsh advfirewall firewall add rule name = "Disable port 445 - TCP" dir = in action = block protocol = TCP localport = 445
echo. 
netsh advfirewall firewall add rule name = "Disable port 445 - UDP" dir = in action = block protocol = UDP localport = 445
echo.
echo 按任意键退出 
pause>nul

以上是关于Wndows关闭高危端口&修改远程端口命令的主要内容,如果未能解决你的问题,请参考以下文章

如何远程查看服务器端口是不是打开?

服务器安装完系统后必做的几个安全性操作

windows修改远程端口操作(无须重启服务器)3389端口关闭

ubuntu怎么关闭22端口

检查远程主机上一个端口的状态[关闭]

linux修改远程端口22