Tactical RMM是一个开源的远程管理工具,而RustDesk是一个开源的远程桌面应用程序。通过将 Tactical RMM集成到RustDesk中可使用RustDesk来管理Tactical RMM的服务器。本文主要介绍如何将Tactical RMM集成到RustDesk。
一、与RustDesk集成前操作
1、安装Tactical RMM服务器,具体步骤可按照其官方文档和开放端口。
2、创建以下脚本(均为 PowerShell)。
2、创建一个URL。
3、创建自定义字段获取RustDesk ID和密码。
4、创建收集器任务。
二、替换IPADDRESS和KEY
<code class="language-ps" data-lang="ps">$ErrorActionPreference= 'silentlycontinue' if (!(Test-Path C:\Temp)) { New-Item -ItemType Directory -Force -Path C:\Temp > null } cd C:\Temp Invoke-WebRequest "https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.exe" -Outfile "rustdesk.exe" Start-Process .\rustdesk.exe --silent-install -wait $ServiceName = 'Rustdesk' $arrService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue if ($arrService -eq $null) { Start-Sleep -seconds 20 } while ($arrService.Status -ne 'Running') { Start-Service $ServiceName Start-Sleep -seconds 5 $arrService.Refresh() } net stop rustdesk $username = ((Get-WMIObject -ClassName Win32_ComputerSystem).Username).Split('\')[1] Remove-Item C:\Users\$username\AppData\Roaming\RustDesk\config\RustDesk2.toml New-Item C:\Users\$username\AppData\Roaming\RustDesk\config\RustDesk2.toml Set-Content C:\Users\$username\AppData\Roaming\RustDesk\config\RustDesk2.toml "rendezvous_server = 'IPADDRESS' `nnat_type = 1`nserial = 0`n`n[options]`ncustom-rendezvous-server = 'IPADDRESS'`nkey = 'KEY='`nrelay-server = 'IPADDRESS'`napi-server = 'https://IPADDRESS'" Remove-Item C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml New-Item C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml Set-Content C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml "rendezvous_server = 'IPADDRESS' `nnat_type = 1`nserial = 0`n`n[options]`ncustom-rendezvous-server = 'IPADDRESS'`nkey = 'KEY='`nrelay-server = 'IPADDRESS'`napi-server = 'https://IPADDRESS'" net start rustdesk
三、RustDesk获取ID
收集器脚本需要自定义代理字段。
<code class="language-ps" data-lang="ps">$ErrorActionPreference= 'silentlycontinue' cd $env:ProgramFiles\RustDesk\ .\rustdesk.exe --get-id | out-host
四、创建用作检查的脚本
<code class="language-ps" data-lang="ps">$ErrorActionPreference= 'silentlycontinue' $confirmation_file = "C:\Program Files\RustDesk\rdrunonce.txt" if ([System.IO.File]::Exists($confirmation_file)) { echo "Confirmation file exists" exit 0 } else { echo "Confirmation file doesn't exists" exit 1 }
五、RustDesk设置并获取密码
收集器脚本需要自定义代理字段,以在检查失败时运行。
<code class="language-ps" data-lang="ps">$ErrorActionPreference= 'silentlycontinue' $confirmation_file = "C:\Program Files\RustDesk\rdrunonce.txt" net stop rustdesk > null $ProcessActive = Get-Process rustdesk -ErrorAction SilentlyContinue if($ProcessActive -ne $null) { Stop-Process -ProcessName rustdesk -Force } $rustdesk_pw = (-join ((65..90) + (97..122) | Get-Random -Count 12 | % {[char]$_})) Start-Process "$env:ProgramFiles\RustDesk\rustdesk.exe" "--password $rustdesk_pw" -wait Write-Output $rustdesk_pw net start rustdesk > null New-Item $confirmation_file > null
六、RustDesk URL操作
rustdesk://connection/new/{{agent.rustdeskid}}?password={{agent.rustdeskpwd}}
七、添加自定义代理字段
rustdeskid Type = Text
rustdeskpwd Type = Text