第七課:sql server 常用操作遠(yuǎn)程桌面語句
專注APT攻擊與防御
https://micropoor.blogspot.com/
1.是否開啟遠(yuǎn)程桌面,1表示關(guān)閉,0表示開啟
EXEC master..xp_regread 'HKEY_LOCAL_MACHINE','SYSTEMCurrentControlSetControlTerminal Server'
,'fDenyTSConnections'

2.讀取遠(yuǎn)程桌面端口
EXEC master..xp_regread 'HKEY_LOCAL_MACHINE','SYSTEMCurrentControlSetControlTerminal
ServerWinStationsRDP-Tcp','PortNumber'

3.開啟遠(yuǎn)程桌面
EXEC master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEMCurrentControlSetControlTerminal
Server','fDenyTSConnections','REG_DWORD',0;
reg文件開啟遠(yuǎn)程桌面:
Windows Registry Editor Version 5.00HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal
Server]"fDenyTSConnections"=dword:00000000[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal
ServerWinStationsRDP-Tcp]"PortNumber"=dword:00000d3d
////
保存micropoor.reg,并執(zhí)行regedit /s micropoor.reg
注:如果第一次開啟遠(yuǎn)程桌面,部分需要配置防火墻規(guī)則允許遠(yuǎn)程端口。
netsh advfirewall firewall add rule name="Remote Desktop" protocol=TCP dir=in localport=3389 action=allow

4.關(guān)閉遠(yuǎn)程桌面
EXEC master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEMCurrentControlSetControlTerminal
Server','fDenyTSConnections','REG_DWORD',1;

Micropoor
?