码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-06-10 13:21:42      阅读:58      评论:0      收藏:0      [点我收藏+]

标签:冲突   web   生效   station   关闭window   服务器   shu   高危端口   reg   

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

修改3899端口

#复制如下命令到写字板,以bat格式保存:
@echo off
color 0a
title  修改Windows 远程桌面服务端口号
echo *******************************************************************
echo * 请输入您要更改的远程桌面端口号,范围:1024-65535,不能与其他端口冲突*
echo *******************************************************************
echo.
set /p port=请输入端口:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v PortNumber /t reg_dword /d %port% /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-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 "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t reg_dword /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal 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关闭高危端口&修改远程端口命令

标签:冲突   web   生效   station   关闭window   服务器   shu   高危端口   reg   

原文地址:https://blog.51cto.com/8149087/2503225

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!