Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
start [2026/02/18 22:54] jango |
start [2026/02/19 22:31] (aktuell) jango |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | < | ||
| + | param( | ||
| + | [string]$Url = " | ||
| + | [string]$Username = " | ||
| + | [string]$Password = " | ||
| + | [switch]$IgnoreCertErrors | ||
| + | ) | ||
| + | |||
| + | [Net.ServicePointManager]:: | ||
| + | if ($IgnoreCertErrors) { [System.Net.ServicePointManager]:: | ||
| + | |||
| + | function New-BasicAuthValue([string]$User, | ||
| + | $pair = " | ||
| + | "Basic " + [Convert]:: | ||
| + | } | ||
| + | |||
| + | $req = [System.Net.HttpWebRequest]:: | ||
| + | $req.Method = " | ||
| + | $req.AllowAutoRedirect = $false | ||
| + | $req.Headers.Add(" | ||
| + | $req.UserAgent = " | ||
| + | |||
| + | try { $resp = $req.GetResponse() } | ||
| + | catch [System.Net.WebException] { $resp = $_.Exception.Response } | ||
| + | |||
| + | if ($resp) { | ||
| + | "HTTP: {0}" -f ([int]$resp.StatusCode) | ||
| + | " | ||
| + | " | ||
| + | $resp.Close() | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | param( | ||
| + | [string]$Url = " | ||
| + | [switch]$IgnoreCertErrors | ||
| + | ) | ||
| + | |||
| + | [Net.ServicePointManager]:: | ||
| + | if ($IgnoreCertErrors) { [System.Net.ServicePointManager]:: | ||
| + | |||
| + | $req = [System.Net.HttpWebRequest]:: | ||
| + | $req.Method = " | ||
| + | $req.AllowAutoRedirect = $false | ||
| + | |||
| + | try { | ||
| + | $resp = $req.GetResponse() | ||
| + | } catch [System.Net.WebException] { | ||
| + | $resp = $_.Exception.Response | ||
| + | } | ||
| + | |||
| + | if ($resp) { | ||
| + | "HTTP: {0}" -f ([int]$resp.StatusCode) | ||
| + | " | ||
| + | $resp.Headers.GetValues(" | ||
| + | $resp.Close() | ||
| + | } else { | ||
| + | "No response (TLS/ | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | PS C: | ||
| + | Target: https:// | ||
| + | User: | ||
| + | Count: | ||
| + | |||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | PS C: | ||
| + | </ | ||
| Hallo Besucher! Willkommen in diesem kleinen Wiki rund um IT. Vieles ist noch **unvollständig, | Hallo Besucher! Willkommen in diesem kleinen Wiki rund um IT. Vieles ist noch **unvollständig, | ||
| Zeile 14: | Zeile 104: | ||
| <code powershell> | <code powershell> | ||
| + | <# | ||
| + | PowerShell 5.1 – EAS Basic-Auth Test (sendet IMMER weiter, auch bei 429) | ||
| + | |||
| + | Optional: | ||
| + | - -IgnoreCertErrors (nur Test!) | ||
| + | - -LogHeaders um X-EAS-FAIL / X-Blocked-By etc. zu sehen, falls du die in HAProxy setzt. | ||
| + | #> | ||
| + | |||
| param( | param( | ||
| [string]$Url = " | [string]$Url = " | ||
| - | [string]$Username = "doesnotexist-testuser", | + | [string]$Username = "D2000\\jango.zarat", |
| - | [string]$Password = "WrongPassword123!", | + | [string]$Password = "Lunikoff0310!", |
| - | [int]$Count = 50, | + | [int]$Count = 20, |
| - | [int]$DelayMs = 200 | + | [int]$DelayMs = 100, |
| + | [int]$TimeoutSec = 10, | ||
| + | [switch]$IgnoreCertErrors, | ||
| + | [switch]$LogHeaders | ||
| ) | ) | ||
| - | + | ||
| - | # Basic Auth header bauen | + | # TLS 1.2 erzwingen |
| - | $pair = "{0}:{1}" -f $Username, $Password | + | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 |
| - | $b64 = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($pair)) | + | |
| - | + | # Optional: Zertifikatsfehler ignorieren | |
| - | $headers = @{ | + | if ($IgnoreCertErrors) |
| - | | + | |
| - | " | + | |
| - | " | + | |
| } | } | ||
| - | + | ||
| - | Write-Host " | + | function New-BasicAuthValue { |
| - | Write-Host " | + | param([string]$User, |
| - | Write-Host " | + | $pair = " |
| + | $b64 = [Convert]:: | ||
| + | return "Basic $b64" | ||
| + | } | ||
| + | |||
| + | $auth = New-BasicAuthValue -User $Username -Pass $Password | ||
| + | |||
| + | Write-Host | ||
| + | Write-Host | ||
| + | Write-Host | ||
| Write-Host "" | Write-Host "" | ||
| + | |||
| for ($i=1; $i -le $Count; $i++) { | for ($i=1; $i -le $Count; $i++) { | ||
| - | $sw = [System.Diagnostics.Stopwatch]:: | + | $sw = [Diagnostics.Stopwatch]:: |
| + | $code = -1 | ||
| + | $err = $null | ||
| + | $h = @{} | ||
| + | |||
| try { | try { | ||
| - | | + | |
| - | $resp = Invoke-WebRequest -Uri $Url -Method Get -Headers $headers | + | $req.Method |
| + | | ||
| + | $req.Timeout = $TimeoutSec * 1000 | ||
| + | $req.ReadWriteTimeout = $TimeoutSec * 1000 | ||
| + | $req.UserAgent = "EAS-Test/ | ||
| + | $req.Headers.Add(" | ||
| + | $req.Headers.Add(" | ||
| + | |||
| + | $resp = $req.GetResponse() | ||
| $code = [int]$resp.StatusCode | $code = [int]$resp.StatusCode | ||
| - | } catch { | + | |
| - | # Bei 401/429 wirft Invoke-WebRequest meist eine Exception -> Code auslesen | + | |
| - | $code = $null | + | |
| - | | + | |
| - | | + | |
| - | } elseif | + | |
| - | | + | |
| } | } | ||
| + | $resp.Close() | ||
| } | } | ||
| + | catch [System.Net.WebException] { | ||
| + | if ($_.Exception.Response) { | ||
| + | $resp = $_.Exception.Response | ||
| + | $code = [int]$resp.StatusCode | ||
| + | if ($LogHeaders) { | ||
| + | foreach ($k in $resp.Headers.AllKeys) { $h[$k] = $resp.Headers[$k] } | ||
| + | } | ||
| + | $resp.Close() | ||
| + | } else { | ||
| + | $err = $_.Exception.Message | ||
| + | } | ||
| + | } | ||
| + | catch { | ||
| + | $err = $_.Exception.Message | ||
| + | } | ||
| + | |||
| $sw.Stop() | $sw.Stop() | ||
| $ts = (Get-Date).ToString(" | $ts = (Get-Date).ToString(" | ||
| - | + | ||
| - | if ($null -eq $code) { $code = -1 } | + | if ($code -eq -1) { |
| - | + | Write-Host (" | |
| - | Write-Host (" | + | } else { |
| - | + | if ($LogHeaders) { | |
| - | if ($code -eq 429) { | + | $xFail |
| - | Write-Host "Got 429 -> rate limit seems active. Stopping." | + | $xBlk = $h[" |
| - | | + | $extra = @() |
| + | if ($xFail) { $extra += (" | ||
| + | if ($xBlk) | ||
| + | | ||
| + | if ($extra.Count -gt 0) { $suffix = " | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| } | } | ||
| + | |||
| + | # WICHTIG: NICHT abbrechen bei 429 – weiter senden | ||
| Start-Sleep -Milliseconds $DelayMs | Start-Sleep -Milliseconds $DelayMs | ||
| } | } | ||
| </ | </ | ||