Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
start [2025/12/06 17:46] jango |
start [2026/02/19 22:31] (aktuell) jango |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| < | < | ||
| - | Füge global dazu: | + | param( |
| + | [string]$Url = "https:// | ||
| + | [string]$Username = " | ||
| + | [string]$Password = " | ||
| + | [switch]$IgnoreCertErrors | ||
| + | ) | ||
| - | static uint8 g_shift | + | [Net.ServicePointManager]:: |
| - | static uint8 g_caps | + | if ($IgnoreCertErrors) { [System.Net.ServicePointManager]:: |
| - | + | function New-BasicAuthValue([string]$User, | |
| - | Und passe get_keycode_once() so an, dass Modifier-Tasten den Zustand setzen und nicht als Zeichen zurückkommen: | + | |
| - | + | " | |
| - | int get_keycode_once(uint8 *out_scancode) | + | |
| - | { | + | |
| - | if (!kbd_has_data()) return 0; | + | |
| - | uint8 sc = kbd_read_data(); | + | |
| - | + | ||
| - | if (sc == 0xE0) { e0_prefix = 1; return 0; } | + | |
| - | + | ||
| - | // Break (release) | + | |
| - | if (sc & 0x80) { | + | |
| - | uint8 make = sc & 0x7F; | + | |
| - | + | ||
| - | // Shift released? | + | |
| - | if (!e0_prefix && (make == 0x2A || make == 0x36)) g_shift = 0; | + | |
| - | + | ||
| - | if (!e0_prefix && make < 128) key_down[make] = 0; | + | |
| - | e0_prefix = 0; | + | |
| - | return 0; | + | |
| - | } | + | |
| - | + | ||
| - | // Make (press) | + | |
| - | | + | |
| - | // Shift pressed? | + | |
| - | if (sc == 0x2A || sc == 0x36) { g_shift = 1; return | + | |
| - | + | ||
| - | // CapsLock toggled? | + | |
| - | if (sc == 0x3A) { g_caps ^= 1; return 0; } | + | |
| - | + | ||
| - | // suppress repeats | + | |
| - | if (sc < 128) { | + | |
| - | if (key_down[sc]) return 0; | + | |
| - | key_down[sc] = 1; | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | e0_prefix = 0; | + | |
| - | *out_scancode = sc; | + | |
| - | return 1; | + | |
| } | } | ||
| - | 2) ASCII-Übersetzung mit Shift (US-Map als Basis) | + | $req = [System.Net.HttpWebRequest]:: |
| + | $req.Method = " | ||
| + | $req.AllowAutoRedirect = $false | ||
| + | $req.Headers.Add(" | ||
| + | $req.UserAgent = " | ||
| - | Ersetze/ | + | try { $resp = $req.GetResponse() } |
| - | + | catch [System.Net.WebException] { $resp = $_.Exception.Response | |
| - | static const char kbd_us[128] = { | + | |
| - | 0, 27,' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | /* rest 0 */ | + | |
| - | }; | + | |
| - | + | ||
| - | static const char kbd_us_shift[128] = { | + | |
| - | 0, 27,' | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | }; | + | |
| - | + | ||
| - | static char get_ascii_char_ex(uint8 sc) | + | |
| - | { | + | |
| - | if (sc >= 128) return 0; | + | |
| - | + | ||
| - | char c = g_shift ? kbd_us_shift[sc] : kbd_us[sc]; | + | |
| - | + | ||
| - | // CapsLock nur für Buchstaben (und Shift invertiert Caps) | + | |
| - | if (c >= ' | + | |
| - | if (g_caps ^ g_shift) c = (char)(c - ' | + | |
| - | } else if (c >= ' | + | |
| - | if (g_caps ^ g_shift) c = (char)(c - ' | + | |
| - | | + | |
| - | return c; | + | if ($resp) { |
| + | "HTTP: {0}" -f ([int]$resp.StatusCode) | ||
| + | " | ||
| + | " | ||
| + | $resp.Close() | ||
| } | } | ||
| </ | </ | ||
| < | < | ||
| - | // erlaubte Zeichen für Mini-BASIC | + | param( |
| - | static int is_allowed_basic_char(char c) { | + | |
| - | if (c == ' ' || c == '.' || c == '"' || c == ' | + | |
| - | c == ' | + | ) |
| - | c == ',' | + | |
| - | if (c >= ' | + | [Net.ServicePointManager]:: |
| - | if (c >= ' | + | if ($IgnoreCertErrors) { [System.Net.ServicePointManager]:: |
| - | return 0; | + | |
| - | } | + | |
| - | </ | + | |
| - | < | + | $req = [System.Net.HttpWebRequest]:: |
| - | // ===================== MINI BASIC (int-only) ===================== | + | $req.Method |
| + | $req.AllowAutoRedirect | ||
| - | #define BASIC_MAX_LINES 64 | + | try { |
| - | #define BASIC_LINE_LEN | + | |
| - | + | } catch [System.Net.WebException] | |
| - | typedef struct | + | |
| - | | + | |
| - | uint8 used; | + | |
| - | char | + | |
| - | } BasicLine; | + | |
| - | + | ||
| - | static BasicLine g_prog[BASIC_MAX_LINES]; | + | |
| - | static int g_vars[26]; // A..Z | + | |
| - | + | ||
| - | static void basic_reset_program(void) | + | |
| - | for (int i = 0; i < BASIC_MAX_LINES; | + | |
| - | g_prog[i].used = 0; | + | |
| - | g_prog[i].line_no = 0; | + | |
| - | g_prog[i].text[0] = 0; | + | |
| - | } | + | |
| } | } | ||
| - | static void basic_reset_vars(void) { | + | if ($resp) { |
| - | for (int i = 0; i < 26; i++) g_vars[i] = 0; | + | " |
| + | " | ||
| + | $resp.Headers.GetValues(" | ||
| + | $resp.Close() | ||
| + | } else { | ||
| + | "No response (TLS/ | ||
| } | } | ||
| + | </ | ||
| - | static int is_space(char c) { return c == ' ' || c == '\t'; } | + | < |
| + | PS C:\Users\Manuel Zarat> C: | ||
| + | Target: https:// | ||
| + | User: | ||
| + | Count: | ||
| - | static char up(char c) { | + | [13: |
| - | | + | [13: |
| - | | + | [13: |
| - | } | + | [13: |
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| + | [13: | ||
| - | static void skip_spaces(const char **p) { | + | PS C: |
| - | while (**p && is_space(**p)) (*p)++; | + | </ |
| - | } | + | Hallo Besucher! Willkommen in diesem kleinen Wiki rund um IT. Vieles ist noch **unvollständig, |
| - | static int is_digit(char c) { return (c >= ' | + | Du kannst Artikel gerne [[todo|ergänzen oder verbessern]]. Gerne mit so vielen Links wie nötig. Bitte keine Werbelinks und nur selbst verfasste oder lizenzfreie Texte! Copyright beachten! |
| - | static int is_alpha(char c) { return (c >= ' | + | |
| - | static int starts_with_kw(const char *s, const char *kw) { | ||
| - | // case-insensitive, | ||
| - | int i = 0; | ||
| - | while (kw[i]) { | ||
| - | if (up(s[i]) != kw[i]) return 0; | ||
| - | i++; | ||
| - | } | ||
| - | char next = s[i]; | ||
| - | return (next == 0 || is_space(next)); | ||
| - | } | ||
| - | static uint16 parse_u16(const char **p) { | + | =====Fehlende Verlinkungen===== |
| - | skip_spaces(p); | + | |
| - | uint16 v = 0; | + | |
| - | while (is_digit(**p)) { | + | |
| - | v = (uint16)(v * 10 + (**p - ' | + | |
| - | (*p)++; | + | |
| - | } | + | |
| - | return v; | + | |
| - | } | + | |
| - | static int parse_int(const char **p) { | + | Eine Liste von Seiten die noch erstellt werden müssen. |
| - | skip_spaces(p); | + | |
| - | int sign = 1; | + | |
| - | if (**p == ' | + | |
| - | else if (**p == ' | + | |
| - | int v = 0; | + | ~~ORPHANSWANTED: |
| - | while (is_digit(**p)) { | + | |
| - | v = v * 10 + (**p - ' | + | |
| - | (*p)++; | + | |
| - | } | + | |
| - | return v * sign; | + | |
| - | } | + | |
| - | static int find_line_index(uint16 line_no) { | ||
| - | for (int i = 0; i < BASIC_MAX_LINES; | ||
| - | if (g_prog[i].used && g_prog[i].line_no == line_no) return i; | ||
| - | } | ||
| - | return -1; | ||
| - | } | ||
| - | static int find_free_slot(void) { | ||
| - | for (int i = 0; i < BASIC_MAX_LINES; | ||
| - | if (!g_prog[i].used) return i; | ||
| - | } | ||
| - | return -1; | ||
| - | } | ||
| - | static int find_next_line_sorted(uint16 last_line, uint16 *out_line, int *out_idx) { | + | <code powershell> |
| - | int found = 0; | + | <# |
| - | | + | PowerShell 5.1 – EAS Basic-Auth Test (sendet IMMER weiter, auch bei 429) |
| - | int best_i = -1; | + | |
| - | + | Optional: | |
| - | for (int i = 0; i < BASIC_MAX_LINES; | + | - -IgnoreCertErrors |
| - | | + | - -LogHeaders um X-EAS-FAIL / X-Blocked-By etc. zu sehen, falls du die in HAProxy setzt. |
| - | | + | #> |
| - | if (ln > last_line && ln < best) { | + | |
| - | | + | param( |
| - | | + | |
| - | | + | [string]$Username = " |
| - | } | + | |
| - | } | + | |
| - | + | | |
| - | if (!found) return 0; | + | |
| - | | + | [switch]$IgnoreCertErrors, |
| - | *out_idx = best_i; | + | [switch]$LogHeaders |
| - | return 1; | + | ) |
| + | |||
| + | # TLS 1.2 erzwingen | ||
| + | [Net.ServicePointManager]:: | ||
| + | |||
| + | # Optional: Zertifikatsfehler ignorieren (nur Tests) | ||
| + | if ($IgnoreCertErrors) { | ||
| + | | ||
| } | } | ||
| - | + | ||
| - | static void basic_store_line(uint16 line_no, const char *rest) { | + | function New-BasicAuthValue |
| - | // rest: nach der Zeilennummer (inkl. leading spaces) | + | param([string]$User, [string]$Pass) |
| - | // Wenn rest leer -> löschen | + | |
| - | const char *p = rest; | + | |
| - | skip_spaces(& | + | |
| - | + | ||
| - | int idx = find_line_index(line_no); | + | |
| - | + | ||
| - | if (*p == 0) { | + | |
| - | | + | |
| - | return; | + | |
| - | } | + | |
| - | + | ||
| - | if (idx < 0) { | + | |
| - | | + | |
| - | if (idx < 0) { | + | |
| - | print_new_line(); | + | |
| - | print_string("BASIC: OUT OF PROGRAM SPACE" | + | |
| - | | + | |
| - | } | + | |
| - | g_prog[idx].used = 1; | + | |
| - | g_prog[idx].line_no = line_no; | + | |
| - | } | + | |
| - | + | ||
| - | // copy text, uppercase keywords funktionieren trotzdem case-insensitive | + | |
| - | int j = 0; | + | |
| - | while (*p && j < BASIC_LINE_LEN - 1) { | + | |
| - | | + | |
| - | } | + | |
| - | g_prog[idx].text[j] = 0; | + | |
| } | } | ||
| - | + | ||
| - | static void basic_list(void) { | + | $auth = New-BasicAuthValue -User $Username -Pass $Password |
| - | | + | |
| - | | + | Write-Host |
| - | int idx; | + | Write-Host (" |
| - | + | Write-Host (" | |
| - | while (find_next_line_sorted(last, &ln, &idx)) { | + | Write-Host "" |
| - | | + | |
| - | | + | for ($i=1; $i -le $Count; $i++) { |
| - | | + | $sw = [Diagnostics.Stopwatch]:: |
| - | | + | $code = -1 |
| - | | + | $err = $null |
| + | $h = @{} | ||
| + | |||
| + | try { | ||
| + | $req = [System.Net.HttpWebRequest]:: | ||
| + | | ||
| + | $req.AllowAutoRedirect = $false | ||
| + | $req.Timeout = $TimeoutSec * 1000 | ||
| + | $req.ReadWriteTimeout = $TimeoutSec * 1000 | ||
| + | $req.UserAgent = " | ||
| + | $req.Headers.Add(" | ||
| + | | ||
| + | |||
| + | $resp = $req.GetResponse() | ||
| + | $code = [int]$resp.StatusCode | ||
| + | if ($LogHeaders) { | ||
| + | | ||
| } | } | ||
| - | } | + | $resp.Close() |
| - | + | } | |
| - | static void basic_error(const char *msg) { | + | catch [System.Net.WebException] |
| - | print_new_line(); | + | if ($_.Exception.Response) { |
| - | print_string(" | + | |
| - | print_string((char*)msg); | + | $code = [int]$resp.StatusCode |
| - | } | + | if ($LogHeaders) { |
| - | + | | |
| - | // ---------- Expression parser (recursive descent) ---------- | + | } |
| - | static int parse_expr(const char **p); // forward | + | |
| - | + | | |
| - | static int parse_factor(const char **p) { | + | $err = $_.Exception.Message |
| - | skip_spaces(p); | + | |
| - | + | ||
| - | // unary | + | |
| - | if (**p == ' | + | |
| - | if (**p == ' | + | |
| - | + | ||
| - | | + | |
| - | (*p)++; | + | |
| - | int v = parse_expr(p); | + | |
| - | | + | |
| - | | + | |
| - | else basic_error(" | + | |
| - | | + | |
| } | } | ||
| - | + | } | |
| - | // variable | + | catch { |
| - | if (is_alpha(**p)) { | + | |
| - | char c = up(**p); | + | } |
| - | (*p)++; | + | |
| - | if (c >= ' | + | $sw.Stop() |
| - | | + | $ts = (Get-Date).ToString(" |
| + | |||
| + | | ||
| + | Write-Host | ||
| + | } else { | ||
| + | if ($LogHeaders) { | ||
| + | $xFail = $h[" | ||
| + | $xBlk = $h[" | ||
| + | $extra | ||
| + | | ||
| + | if ($xBlk) | ||
| + | $suffix = "" | ||
| + | if ($extra.Count | ||
| + | Write-Host ("[{0}] #{1,4} -> HTTP {2} ({3} ms){4}" | ||
| + | } else { | ||
| + | Write-Host ("[{0}] #{1,4} -> HTTP {2} ({3} ms)" -f $ts, $i, $code, $sw.ElapsedMilliseconds) | ||
| } | } | ||
| - | + | | |
| - | // number | + | |
| - | if (is_digit(**p)) { | + | |
| - | return parse_int(p); | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | return 0; | + | |
| - | } | + | |
| - | + | ||
| - | static int parse_term(const char **p) { | + | |
| - | int v = parse_factor(p); | + | |
| - | for (;;) { | + | |
| - | skip_spaces(p); | + | |
| - | if (**p == ' | + | |
| - | else if (**p == '/' | + | |
| - | (*p)++; | + | |
| - | int d = parse_factor(p); | + | |
| - | if (d == 0) { basic_error(" | + | |
| - | v = v / d; | + | |
| - | } else break; | + | |
| - | } | + | |
| - | return v; | + | |
| - | } | + | |
| - | + | ||
| - | static int parse_expr(const char **p) { | + | |
| - | int v = parse_term(p); | + | |
| - | for (;;) { | + | |
| - | skip_spaces(p); | + | |
| - | if (**p == ' | + | |
| - | else if (**p == ' | + | |
| - | else break; | + | |
| - | } | + | |
| - | return v; | + | |
| - | } | + | |
| - | + | ||
| - | static int parse_relop(const char **p, const char **out_op) { | + | |
| - | skip_spaces(p); | + | |
| - | // supported: =, <, >, <=, >=, <> | + | |
| - | if (**p == ' | + | |
| - | if (**p == '<' | + | |
| - | (*p)++; | + | |
| - | if (**p == ' | + | |
| - | if (**p == '>' | + | |
| - | *out_op = "<"; | + | |
| - | } | + | |
| - | if (**p == '>' | + | |
| - | (*p)++; | + | |
| - | if (**p == ' | + | |
| - | *out_op = ">"; | + | |
| - | } | + | |
| - | return 0; | + | |
| - | } | + | |
| - | + | ||
| - | static int eval_relation(int a, int b, const char *op) { | + | |
| - | if (op[0] == ' | + | |
| - | if (op[0] == '<' | + | |
| - | if (op[0] == '>' | + | |
| - | if (op[0] == '<' | + | |
| - | if (op[0] == '>' | + | |
| - | if (op[0] == '<' | + | |
| - | return 0; | + | |
| - | } | + | |
| - | + | ||
| - | // ---------- Statement execution ---------- | + | |
| - | static int basic_exec_stmt(const char *line, uint16 *pc_line /*in/out*/, int *stop /*out*/) { | + | |
| - | const char *p = line; | + | |
| - | skip_spaces(& | + | |
| - | + | ||
| - | if (*p == 0) return 1; | + | |
| - | + | ||
| - | // REM | + | |
| - | if (starts_with_kw(p, | + | |
| - | + | ||
| - | // END | + | |
| - | if (starts_with_kw(p, | + | |
| - | + | ||
| - | + | ||
| - | if (starts_with_kw(p, | + | |
| - | p += 5; | + | |
| - | skip_spaces(& | + | |
| - | + | ||
| - | // PRINT " | + | |
| - | if (*p == '"' | + | |
| - | p++; | + | |
| - | print_new_line(); | + | |
| - | while (*p && *p != '"' | + | |
| - | print_char(*p++); | + | |
| - | } | + | |
| - | if (*p == '"' | + | |
| - | return 1; | + | |
| - | } | + | |
| - | + | ||
| - | // PRINT expr | + | |
| - | int v = parse_expr(& | + | |
| - | print_new_line(); | + | |
| - | print_int(v); | + | |
| - | return 1; | + | |
| - | } | + | |
| - | + | ||
| - | // LET (optional) | + | |
| - | if (starts_with_kw(p, | + | |
| - | p += 3; | + | |
| - | skip_spaces(& | + | |
| - | } | + | |
| - | + | ||
| - | // IF expr rel expr THEN line | + | |
| - | if (starts_with_kw(p, | + | |
| - | p += 2; | + | |
| - | int left = parse_expr(& | + | |
| - | + | ||
| - | const char *op = 0; | + | |
| - | if (!parse_relop(& | + | |
| - | + | ||
| - | int right = parse_expr(& | + | |
| - | + | ||
| - | skip_spaces(& | + | |
| - | if (!starts_with_kw(p, | + | |
| - | p += 4; | + | |
| - | + | ||
| - | uint16 target = parse_u16(& | + | |
| - | if (target == 0) { basic_error(" | + | |
| - | + | ||
| - | if (eval_relation(left, | + | |
| - | *pc_line = (uint16)(target - 1); // Trick: RUN loop nimmt "next > pc_line" | + | |
| - | } | + | |
| - | return 1; | + | |
| - | } | + | |
| - | + | ||
| - | // GOTO line | + | |
| - | if (starts_with_kw(p, | + | |
| - | p += 4; | + | |
| - | uint16 target = parse_u16(& | + | |
| - | if (target == 0) { basic_error(" | + | |
| - | *pc_line = (uint16)(target - 1); | + | |
| - | return 1; | + | |
| - | } | + | |
| - | + | ||
| - | // Assignment: A = expr | + | |
| - | if (is_alpha(*p)) { | + | |
| - | char vname = up(*p++); | + | |
| - | if (vname < ' | + | |
| - | skip_spaces(& | + | |
| - | if (*p != ' | + | |
| - | p++; | + | |
| - | int value = parse_expr(& | + | |
| - | g_vars[vname - ' | + | |
| - | return 1; | + | |
| - | } | + | |
| - | + | ||
| - | basic_error(" | + | |
| - | return 0; | + | |
| - | } | + | |
| - | + | ||
| - | static void basic_run(void) { | + | |
| - | uint16 pc = 0; // last executed line_no (for sorted iteration) | + | |
| - | int stop = 0; | + | |
| - | + | ||
| - | // Start at " | + | |
| - | pc = 0; | + | |
| - | + | ||
| - | while (!stop) { | + | |
| - | uint16 ln; | + | |
| - | int idx; | + | |
| - | if (!find_next_line_sorted(pc, | + | |
| - | + | ||
| - | // execute | + | |
| - | uint16 pc_before = ln; | + | |
| - | uint16 pc_line = ln; | + | |
| - | basic_exec_stmt(g_prog[idx].text, | + | |
| - | + | ||
| - | // pc_line may be changed by GOTO/IF | + | |
| - | pc = pc_line; | + | |
| - | + | ||
| - | // normal case: move to next after current | + | |
| - | if (pc == pc_before) pc = ln; | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | // ---------- REPL line handler ---------- | + | |
| - | static void basic_repl_line(const char *input) { | + | |
| - | const char *p = input; | + | |
| - | skip_spaces(& | + | |
| - | if (*p == 0) return; | + | |
| - | + | ||
| - | // line starts with number? -> program line | + | |
| - | if (is_digit(*p)) { | + | |
| - | uint16 ln = parse_u16(& | + | |
| - | basic_store_line(ln, | + | |
| - | return; | + | |
| - | } | + | |
| - | + | ||
| - | // Immediate commands | + | |
| - | if (starts_with_kw(p, | + | |
| - | if (starts_with_kw(p, | + | |
| - | if (starts_with_kw(p, | + | |
| - | + | ||
| - | // keep your old shell commands too: | + | |
| - | if (starts_with_kw(p, | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | print_new_line(); | + | |
| - | print_string(" | + | |
| - | return; | + | |
| - | } | + | |
| - | + | ||
| - | if (starts_with_kw(p, | + | |
| - | + | ||
| - | // Otherwise: treat as immediate BASIC statement (PRINT/ | + | |
| - | uint16 dummy = 0; | + | |
| - | int stop = 0; | + | |
| - | basic_exec_stmt(p, | + | |
| } | } | ||
| </ | </ | ||
| - | |||
| - | Hallo Besucher! Willkommen in diesem kleinen Wiki rund um IT. Vieles ist noch **unvollständig, | ||
| - | |||
| - | Du kannst Artikel gerne [[todo|ergänzen oder verbessern]]. Gerne mit so vielen Links wie nötig. Bitte keine Werbelinks und nur selbst verfasste oder lizenzfreie Texte! Copyright beachten! | ||
| - | |||
| - | |||
| - | =====Fehlende Verlinkungen===== | ||
| - | |||
| - | Eine Liste von Seiten die noch erstellt werden müssen. | ||
| - | |||
| - | ~~ORPHANSWANTED: | ||
| - | |||
| - | |||