Wndows關閉高危端口&修改遠程端口命令

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章