Meilenstein 3: Windows-Anbindung für itrdp:// und itssh://
- Gemeinsame, strenge Link-Prüfung in itconnect-common.ps1 (Regeln wie im Backend, Regex-Ende mit \z, nur Parameter host/port/user) - launch-rdp.ps1: mstsc /v bzw. temporäre .rdp-Datei bei Benutzername - launch-ssh.ps1: wt.exe ssh, Fallback auf ssh.exe - register-handlers.reg / unregister-handlers.reg (HKCU, Skripte unter Program Files) - test-launcher.ps1 mit gültigen und bösartigen Testlinks - .gitattributes: Windows-Dateien unverändert (CRLF, BOM) - SETUP.md: Installation, Test und Fehlerbilder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e89c4ad59
commit
37a60fc62a
8 files changed
+361
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
windows/* -text
|
||||||
@@ -304,6 +304,52 @@ Dashboard: Kacheln gruppiert nach RDP, SSH und Web, Filter „Alle / Privat / Te
|
|||||||
|
|
||||||
Der Knopf „Verbinden“ erzeugt Links im Format `itrdp://connect?host=<ziel>&port=<port>&user=<benutzer>` bzw. `itssh://…`. Damit Windows sie öffnet, braucht es die Protokoll-Handler aus Meilenstein 3. Web-Einträge öffnen sich in einem neuen Tab.
|
Der Knopf „Verbinden“ erzeugt Links im Format `itrdp://connect?host=<ziel>&port=<port>&user=<benutzer>` bzw. `itssh://…`. Damit Windows sie öffnet, braucht es die Protokoll-Handler aus Meilenstein 3. Web-Einträge öffnen sich in einem neuen Tab.
|
||||||
|
|
||||||
|
### 4.8 Windows-Anbindung (Meilenstein 3)
|
||||||
|
|
||||||
|
Damit „Verbinden“ im Dashboard `mstsc.exe` bzw. Windows Terminal öffnet, werden auf jedem Windows-Rechner die Protokolle `itrdp://` und `itssh://` registriert.
|
||||||
|
|
||||||
|
Dateien in `windows/`:
|
||||||
|
|
||||||
|
| Datei | Zweck |
|
||||||
|
|---|---|
|
||||||
|
| `itconnect-common.ps1` | Gemeinsame Prüfung der Links (gleiche Regeln wie im Backend) |
|
||||||
|
| `launch-rdp.ps1` | Prüft den Link, startet `mstsc /v:host:port` (mit Benutzer über eine temporäre `.rdp`-Datei) |
|
||||||
|
| `launch-ssh.ps1` | Prüft den Link, startet `wt.exe ssh -p port -l benutzer host` (ohne Windows Terminal: `ssh.exe`) |
|
||||||
|
| `register-handlers.reg` | Registriert die Protokolle für den angemeldeten Windows-Benutzer |
|
||||||
|
| `unregister-handlers.reg` | Entfernt die Registrierung wieder |
|
||||||
|
| `test-launcher.ps1` | Testet die Prüfung, ohne etwas zu starten |
|
||||||
|
|
||||||
|
**Installation** (PowerShell **als Administrator**, im Ordner `windows` des Repos):
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
New-Item -ItemType Directory -Force "C:\Program Files\it-connect" | Out-Null
|
||||||
|
Copy-Item .\itconnect-common.ps1, .\launch-rdp.ps1, .\launch-ssh.ps1, .\test-launcher.ps1 "C:\Program Files\it-connect\"
|
||||||
|
Get-ChildItem "C:\Program Files\it-connect" | Unblock-File
|
||||||
|
```
|
||||||
|
|
||||||
|
Danach **als normaler Benutzer** `register-handlers.reg` doppelklicken und bestätigen.
|
||||||
|
|
||||||
|
Warum `C:\Program Files`: Dort kann nur ein Admin schreiben. Lägen die Skripte in einem Benutzerordner, könnte Schadsoftware ohne Admin-Rechte sie austauschen und würde dann bei jedem Klick auf „Verbinden“ ausgeführt.
|
||||||
|
|
||||||
|
**Testen** (normale PowerShell):
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\it-connect\test-launcher.ps1"
|
||||||
|
```
|
||||||
|
|
||||||
|
Erwartet: lauter grüne `OK`-Zeilen und „Alle Tests bestanden.“ Danach im Dashboard einen RDP- und einen SSH-Eintrag anlegen und auf „Verbinden“ klicken. Der Browser fragt beim ersten Mal, ob er die App öffnen darf; das bestätigen (optional „immer erlauben“). Zum Ausprobieren ohne Browser: `Start-Process "itrdp://connect?host=test-server-01.example.local&port=3389"`.
|
||||||
|
|
||||||
|
**Fehlerbilder:**
|
||||||
|
|
||||||
|
| Problem | Lösung |
|
||||||
|
|---|---|
|
||||||
|
| Nichts passiert beim Klick | `register-handlers.reg` importiert? Pfad `C:\Program Files\it-connect\launch-rdp.ps1` vorhanden? |
|
||||||
|
| Meldungsfenster „konnte nicht geöffnet werden“ | Der Link ist ungültig, der Grund steht in der Meldung |
|
||||||
|
| Skript wird blockiert | Gruppenrichtlinie/AppLocker verbietet PowerShell-Skripte → mit der IT klären (siehe Teil 5) |
|
||||||
|
| SSH öffnet ein altes Konsolenfenster | Windows Terminal ist nicht installiert, Fallback auf `ssh.exe` |
|
||||||
|
|
||||||
|
Hinweis: Der Aufruf nutzt `-ExecutionPolicy Bypass` nur für diese Skripte, weil sie nicht signiert sind. In der Firma kann man sie stattdessen mit einem Code-Signing-Zertifikat signieren und die Policy auf `AllSigned` lassen.
|
||||||
|
|
||||||
### Noch offen
|
### Noch offen
|
||||||
|
|
||||||
- systemd-Dienst und Caddy: folgt in Meilenstein 5
|
- systemd-Dienst und Caddy: folgt in Meilenstein 5
|
||||||
@@ -344,3 +390,4 @@ Checkliste, wenn der Dienst zu Hause läuft:
|
|||||||
| 2026-11-20 | Erste Fassung: Server, Claude Code, Remote Control, Tailscale |
|
| 2026-11-20 | Erste Fassung: Server, Claude Code, Remote Control, Tailscale |
|
||||||
| 2026-11-20 | Meilenstein 1: Python-Umgebung, Konfiguration, Admin anlegen, lokaler Start, Tests |
|
| 2026-11-20 | Meilenstein 1: Python-Umgebung, Konfiguration, Admin anlegen, lokaler Start, Tests |
|
||||||
| 2026-11-20 | Meilenstein 2: Verbindungs-API, Sichtbarkeitsregeln, Dashboard |
|
| 2026-11-20 | Meilenstein 2: Verbindungs-API, Sichtbarkeitsregeln, Dashboard |
|
||||||
|
| 2026-11-20 | Meilenstein 3: Windows-Protokoll-Handler, PowerShell-Skripte, Installation und Test |
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
# Gemeinsame Funktionen für launch-rdp.ps1 und launch-ssh.ps1.
|
||||||
|
# Parst und prüft Links der Form
|
||||||
|
# itrdp://connect?host=<ziel>&port=<port>[&user=<benutzer>]
|
||||||
|
# itssh://connect?host=<ziel>&port=<port>[&user=<benutzer>]
|
||||||
|
# Regeln wie im Backend (backend/app/validierung.py):
|
||||||
|
# Ziel: Hostname (Buchstaben, Ziffern, Punkte, Bindestriche) oder IPv6-Adresse
|
||||||
|
# Port: 1-65535
|
||||||
|
# Benutzer: Buchstaben, Ziffern, Punkte, Bindestriche, Unterstriche
|
||||||
|
# Wichtig: Regex-Ende immer mit \z, weil $ in .NET einen abschliessenden Zeilenumbruch erlaubt.
|
||||||
|
|
||||||
|
Set-StrictMode -Version 2.0
|
||||||
|
|
||||||
|
$script:ItcLabelRegex = '^(?!-)[A-Za-z0-9-]{1,63}(?<!-)\z'
|
||||||
|
$script:ItcBenutzerRegex = '^[A-Za-z0-9._-]{1,64}\z'
|
||||||
|
$script:ItcPortRegex = '^[0-9]{1,5}\z'
|
||||||
|
|
||||||
|
function Test-ItcHost {
|
||||||
|
param([string]$Wert)
|
||||||
|
if ([string]::IsNullOrEmpty($Wert) -or $Wert.Length -gt 253) { return $false }
|
||||||
|
|
||||||
|
if ($Wert.Contains(':')) {
|
||||||
|
# IPv6: nur Hex-Ziffern, Doppelpunkte und Punkte (IPv4-Anteil), keine Klammern, keine Zonen-ID
|
||||||
|
if ($Wert -cnotmatch '^[0-9A-Fa-f:.]+\z') { return $false }
|
||||||
|
$ip = $null
|
||||||
|
if (-not [System.Net.IPAddress]::TryParse($Wert, [ref]$ip)) { return $false }
|
||||||
|
return ($ip.AddressFamily -eq [System.Net.Sockets.AddressFamily]::InterNetworkV6)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Hostname oder IPv4 (IPv4 besteht aus gültigen Labels aus Ziffern)
|
||||||
|
$name = $Wert
|
||||||
|
if ($name.EndsWith('.')) { $name = $name.Substring(0, $name.Length - 1) }
|
||||||
|
if ($name -eq '') { return $false }
|
||||||
|
foreach ($label in $name.Split('.')) {
|
||||||
|
if ($label -cnotmatch $script:ItcLabelRegex) { return $false }
|
||||||
|
}
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-ItcBenutzer {
|
||||||
|
param([string]$Wert)
|
||||||
|
return ($Wert -cmatch $script:ItcBenutzerRegex)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ConvertFrom-ItcUrl {
|
||||||
|
<#
|
||||||
|
Zerlegt einen it-connect-Link und prüft alle Werte.
|
||||||
|
Rückgabe: Objekt mit Host, Port, User (User kann $null sein).
|
||||||
|
Bei ungültigen Eingaben wird eine Ausnahme mit deutscher Meldung ausgelöst.
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)][AllowEmptyString()][string]$Url,
|
||||||
|
[Parameter(Mandatory = $true)][ValidateSet('itrdp', 'itssh')][string]$Schema,
|
||||||
|
[Parameter(Mandatory = $true)][int]$StandardPort
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($Url.Length -gt 1024) { throw 'Der Link ist zu lang.' }
|
||||||
|
|
||||||
|
# Erlaubt: <schema>://connect?... bzw. <schema>://connect/?...
|
||||||
|
# Im Abfrageteil nur unbedenkliche Zeichen; alles andere muss %-kodiert sein.
|
||||||
|
$muster = '^(?i:' + $Schema + ')://connect/?\?(?<q>[A-Za-z0-9._~%=&-]*)\z'
|
||||||
|
$treffer = [regex]::Match($Url, $muster)
|
||||||
|
if (-not $treffer.Success) { throw 'Ungültiger Link. Erwartet wird ' + $Schema + '://connect?host=...' }
|
||||||
|
|
||||||
|
$werte = @{}
|
||||||
|
foreach ($teil in $treffer.Groups['q'].Value.Split('&')) {
|
||||||
|
if ($teil -eq '') { continue }
|
||||||
|
$kv = $teil.Split('=', 2)
|
||||||
|
if ($kv.Count -ne 2) { throw 'Ungültiger Parameter im Link.' }
|
||||||
|
$schluessel = $kv[0].ToLowerInvariant()
|
||||||
|
if (@('host', 'port', 'user') -notcontains $schluessel) { throw ('Unbekannter Parameter im Link: ' + $kv[0]) }
|
||||||
|
if ($werte.ContainsKey($schluessel)) { throw ('Parameter doppelt im Link: ' + $schluessel) }
|
||||||
|
try {
|
||||||
|
$werte[$schluessel] = [System.Uri]::UnescapeDataString($kv[1])
|
||||||
|
} catch {
|
||||||
|
throw 'Ungültige Kodierung im Link.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $werte.ContainsKey('host')) { throw 'Im Link fehlt das Ziel (host).' }
|
||||||
|
$zielHost = $werte['host']
|
||||||
|
if (-not (Test-ItcHost $zielHost)) { throw ('Ungültiges Ziel: ' + $zielHost) }
|
||||||
|
|
||||||
|
$port = $StandardPort
|
||||||
|
if ($werte.ContainsKey('port') -and $werte['port'] -ne '') {
|
||||||
|
if ($werte['port'] -cnotmatch $script:ItcPortRegex) { throw 'Ungültiger Port.' }
|
||||||
|
$port = [int]$werte['port']
|
||||||
|
if ($port -lt 1 -or $port -gt 65535) { throw 'Ungültiger Port.' }
|
||||||
|
}
|
||||||
|
|
||||||
|
$benutzer = $null
|
||||||
|
if ($werte.ContainsKey('user') -and $werte['user'] -ne '') {
|
||||||
|
if (-not (Test-ItcBenutzer $werte['user'])) { throw ('Ungültiger Benutzername: ' + $werte['user']) }
|
||||||
|
$benutzer = $werte['user']
|
||||||
|
}
|
||||||
|
|
||||||
|
return [pscustomobject]@{ Host = $zielHost; Port = $port; User = $benutzer }
|
||||||
|
}
|
||||||
|
|
||||||
|
function Format-ItcAdresse {
|
||||||
|
# host:port, IPv6 in eckigen Klammern
|
||||||
|
param([Parameter(Mandatory = $true)]$Ziel)
|
||||||
|
if ($Ziel.Host.Contains(':')) { return ('[' + $Ziel.Host + ']:' + $Ziel.Port) }
|
||||||
|
return ($Ziel.Host + ':' + $Ziel.Port)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Show-ItcFehler {
|
||||||
|
param([string]$Text)
|
||||||
|
try {
|
||||||
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
|
[void][System.Windows.Forms.MessageBox]::Show($Text, 'it-connect', 'OK', 'Error')
|
||||||
|
} catch {
|
||||||
|
Write-Error $Text
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<#
|
||||||
|
Öffnet eine RDP-Verbindung aus einem itrdp://-Link.
|
||||||
|
Wird über den Protokoll-Handler aufgerufen (siehe register-handlers.reg):
|
||||||
|
powershell.exe -File launch-rdp.ps1 "itrdp://connect?host=...&port=...&user=..."
|
||||||
|
Mit -Pruefen wird nur angezeigt, was gestartet würde (für Tests).
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true, Position = 0)][AllowEmptyString()][string]$Url,
|
||||||
|
[switch]$Pruefen
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
. (Join-Path $PSScriptRoot 'itconnect-common.ps1')
|
||||||
|
|
||||||
|
function Get-ItcRdpBefehl {
|
||||||
|
param([Parameter(Mandatory = $true)]$Ziel)
|
||||||
|
$adresse = Format-ItcAdresse $Ziel
|
||||||
|
if ($null -eq $Ziel.User) {
|
||||||
|
return [pscustomobject]@{ Programm = 'mstsc.exe'; Argumente = ('/v:' + $adresse); RdpInhalt = $null }
|
||||||
|
}
|
||||||
|
# mstsc kennt keinen Benutzer-Parameter, daher eine temporäre .rdp-Datei
|
||||||
|
$inhalt = "full address:s:$adresse`r`nusername:s:$($Ziel.User)`r`n"
|
||||||
|
return [pscustomobject]@{ Programm = 'mstsc.exe'; Argumente = $null; RdpInhalt = $inhalt }
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$ziel = ConvertFrom-ItcUrl -Url $Url -Schema 'itrdp' -StandardPort 3389
|
||||||
|
$befehl = Get-ItcRdpBefehl $ziel
|
||||||
|
|
||||||
|
if ($Pruefen) { return $befehl }
|
||||||
|
|
||||||
|
if ($null -eq $befehl.RdpInhalt) {
|
||||||
|
Start-Process -FilePath $befehl.Programm -ArgumentList $befehl.Argumente
|
||||||
|
} else {
|
||||||
|
$datei = Join-Path $env:TEMP ('it-connect-' + [guid]::NewGuid().ToString() + '.rdp')
|
||||||
|
Set-Content -LiteralPath $datei -Value $befehl.RdpInhalt -Encoding Unicode
|
||||||
|
Start-Process -FilePath $befehl.Programm -ArgumentList ('"' + $datei + '"')
|
||||||
|
# mstsc liest die Datei beim Start; danach wieder aufräumen
|
||||||
|
Start-Sleep -Seconds 10
|
||||||
|
Remove-Item -LiteralPath $datei -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
if ($Pruefen) { throw }
|
||||||
|
Show-ItcFehler ('RDP-Verbindung konnte nicht geöffnet werden: ' + $_.Exception.Message)
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<#
|
||||||
|
Öffnet eine SSH-Verbindung aus einem itssh://-Link in Windows Terminal (wt.exe).
|
||||||
|
Ist Windows Terminal nicht installiert, wird ssh.exe direkt gestartet.
|
||||||
|
Wird über den Protokoll-Handler aufgerufen (siehe register-handlers.reg):
|
||||||
|
powershell.exe -File launch-ssh.ps1 "itssh://connect?host=...&port=...&user=..."
|
||||||
|
Mit -Pruefen wird nur angezeigt, was gestartet würde (für Tests).
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true, Position = 0)][AllowEmptyString()][string]$Url,
|
||||||
|
[switch]$Pruefen
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
. (Join-Path $PSScriptRoot 'itconnect-common.ps1')
|
||||||
|
|
||||||
|
function Get-ItcSshBefehl {
|
||||||
|
param([Parameter(Mandatory = $true)]$Ziel, [bool]$MitTerminal = $true)
|
||||||
|
# Alle Werte sind geprüft (keine Leerzeichen, Anführungszeichen oder ';'),
|
||||||
|
# daher ist das Zusammensetzen der Argumente unkritisch.
|
||||||
|
$sshArgs = @('-p', [string]$Ziel.Port)
|
||||||
|
if ($null -ne $Ziel.User) { $sshArgs += @('-l', $Ziel.User) }
|
||||||
|
$sshArgs += $Ziel.Host
|
||||||
|
|
||||||
|
if ($MitTerminal) {
|
||||||
|
$argumente = @('new-tab', '--title', $Ziel.Host, 'ssh') + $sshArgs
|
||||||
|
return [pscustomobject]@{ Programm = 'wt.exe'; Argumente = ($argumente -join ' ') }
|
||||||
|
}
|
||||||
|
return [pscustomobject]@{ Programm = 'ssh.exe'; Argumente = ($sshArgs -join ' ') }
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$ziel = ConvertFrom-ItcUrl -Url $Url -Schema 'itssh' -StandardPort 22
|
||||||
|
$wt = Get-Command 'wt.exe' -ErrorAction SilentlyContinue
|
||||||
|
$befehl = Get-ItcSshBefehl -Ziel $ziel -MitTerminal ($null -ne $wt)
|
||||||
|
|
||||||
|
if ($Pruefen) { return $befehl }
|
||||||
|
|
||||||
|
Start-Process -FilePath $befehl.Programm -ArgumentList $befehl.Argumente
|
||||||
|
} catch {
|
||||||
|
if ($Pruefen) { throw }
|
||||||
|
Show-ItcFehler ('SSH-Verbindung konnte nicht geöffnet werden: ' + $_.Exception.Message)
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
Windows Registry Editor Version 5.00
|
||||||
|
|
||||||
|
; Registriert die Protokolle itrdp:// und itssh:// fuer den aktuellen Benutzer.
|
||||||
|
; Voraussetzung: Die Skripte liegen in C:\Program Files\it-connect\
|
||||||
|
; (dort koennen nur Admins schreiben, das schuetzt vor Manipulation).
|
||||||
|
|
||||||
|
[HKEY_CURRENT_USER\Software\Classes\itrdp]
|
||||||
|
@="URL:it-connect RDP"
|
||||||
|
"URL Protocol"=""
|
||||||
|
|
||||||
|
[HKEY_CURRENT_USER\Software\Classes\itrdp\shell\open\command]
|
||||||
|
@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -File \"C:\\Program Files\\it-connect\\launch-rdp.ps1\" \"%1\""
|
||||||
|
|
||||||
|
[HKEY_CURRENT_USER\Software\Classes\itssh]
|
||||||
|
@="URL:it-connect SSH"
|
||||||
|
"URL Protocol"=""
|
||||||
|
|
||||||
|
[HKEY_CURRENT_USER\Software\Classes\itssh\shell\open\command]
|
||||||
|
@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -File \"C:\\Program Files\\it-connect\\launch-ssh.ps1\" \"%1\""
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<#
|
||||||
|
Testet die Link-Prüfung von launch-rdp.ps1 und launch-ssh.ps1, ohne etwas zu starten.
|
||||||
|
Aufruf (im Ordner mit den Skripten):
|
||||||
|
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\test-launcher.ps1
|
||||||
|
#>
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$rdp = Join-Path $PSScriptRoot 'launch-rdp.ps1'
|
||||||
|
$ssh = Join-Path $PSScriptRoot 'launch-ssh.ps1'
|
||||||
|
$fehler = 0
|
||||||
|
|
||||||
|
function Pruefe-Gueltig($Skript, $Url, $ErwartetTeil) {
|
||||||
|
try {
|
||||||
|
$b = & $Skript -Url $Url -Pruefen
|
||||||
|
$text = "$($b.Programm) $($b.Argumente) $($b.RdpInhalt)"
|
||||||
|
if ($text.Contains($ErwartetTeil)) {
|
||||||
|
Write-Host "OK $Url" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host "FEHLER $Url -> '$text' enthält nicht '$ErwartetTeil'" -ForegroundColor Red
|
||||||
|
$script:fehler++
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Host "FEHLER $Url -> abgelehnt: $($_.Exception.Message)" -ForegroundColor Red
|
||||||
|
$script:fehler++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Pruefe-Ungueltig($Skript, $Url) {
|
||||||
|
try {
|
||||||
|
$b = & $Skript -Url $Url -Pruefen
|
||||||
|
Write-Host "FEHLER $Url -> wurde akzeptiert: $($b.Programm) $($b.Argumente)" -ForegroundColor Red
|
||||||
|
$script:fehler++
|
||||||
|
} catch {
|
||||||
|
Write-Host "OK $Url (abgelehnt: $($_.Exception.Message))" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "`n== Gültige RDP-Links ==" -ForegroundColor Cyan
|
||||||
|
Pruefe-Gueltig $rdp 'itrdp://connect?host=test-server-01.example.local&port=3389' '/v:test-server-01.example.local:3389'
|
||||||
|
Pruefe-Gueltig $rdp 'itrdp://connect/?host=192.0.2.10&port=3390' '/v:192.0.2.10:3390'
|
||||||
|
Pruefe-Gueltig $rdp 'itrdp://connect?host=2001%3Adb8%3A%3A1&port=3389' '/v:[2001:db8::1]:3389'
|
||||||
|
Pruefe-Gueltig $rdp 'itrdp://connect?host=srv01' '/v:srv01:3389'
|
||||||
|
Pruefe-Gueltig $rdp 'ITRDP://connect?host=srv01&port=3389&user=test_admin' 'username:s:test_admin'
|
||||||
|
|
||||||
|
Write-Host "`n== Gültige SSH-Links ==" -ForegroundColor Cyan
|
||||||
|
Pruefe-Gueltig $ssh 'itssh://connect?host=test-server-01.example.local&port=22&user=root' '-p 22 -l root test-server-01.example.local'
|
||||||
|
Pruefe-Gueltig $ssh 'itssh://connect?host=fe80%3A%3A1&port=2222' '-p 2222 fe80::1'
|
||||||
|
|
||||||
|
Write-Host "`n== Ungültige Links (müssen abgelehnt werden) ==" -ForegroundColor Cyan
|
||||||
|
$ungueltig = @(
|
||||||
|
'itrdp://connect?host=srv01%3Bcalc.exe',
|
||||||
|
'itrdp://connect?host=srv01%26whoami',
|
||||||
|
'itrdp://connect?host=srv01%7Cx',
|
||||||
|
'itrdp://connect?host=%24(calc)',
|
||||||
|
'itrdp://connect?host=srv01%20%2Fadmin',
|
||||||
|
'itrdp://connect?host=srv01%0A',
|
||||||
|
'itrdp://connect?host=-srv01',
|
||||||
|
'itrdp://connect?host=%5B2001%3Adb8%3A%3A1%5D',
|
||||||
|
'itrdp://connect?host=fe80%3A%3A1%25eth0',
|
||||||
|
'itrdp://connect?host=srv01&port=0',
|
||||||
|
'itrdp://connect?host=srv01&port=65536',
|
||||||
|
'itrdp://connect?host=srv01&port=22a',
|
||||||
|
'itrdp://connect?host=srv01&user=DOMAIN%5Cuser',
|
||||||
|
'itrdp://connect?host=srv01&user=a%22b',
|
||||||
|
'itrdp://connect?host=srv01&host=srv02',
|
||||||
|
'itrdp://connect?host=srv01&cmd=x',
|
||||||
|
'itrdp://connect?host=srv01 /admin',
|
||||||
|
'itrdp://andere?host=srv01',
|
||||||
|
'itssh://connect?host=srv01',
|
||||||
|
'itrdp://connect?port=3389',
|
||||||
|
''
|
||||||
|
)
|
||||||
|
foreach ($u in $ungueltig) { Pruefe-Ungueltig $rdp $u }
|
||||||
|
Pruefe-Ungueltig $ssh 'itssh://connect?host=srv01&user=root%3Bcalc'
|
||||||
|
Pruefe-Ungueltig $ssh 'itrdp://connect?host=srv01'
|
||||||
|
|
||||||
|
Write-Host ''
|
||||||
|
if ($fehler -eq 0) {
|
||||||
|
Write-Host 'Alle Tests bestanden.' -ForegroundColor Green
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
Write-Host "$fehler Test(s) fehlgeschlagen." -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Windows Registry Editor Version 5.00
|
||||||
|
|
||||||
|
; Entfernt die Protokolle itrdp:// und itssh:// fuer den aktuellen Benutzer.
|
||||||
|
|
||||||
|
[-HKEY_CURRENT_USER\Software\Classes\itrdp]
|
||||||
|
|
||||||
|
[-HKEY_CURRENT_USER\Software\Classes\itssh]
|
||||||
Reference in new issue
Block a user