- WebSocket Shell/RDP: Rollenprüfung statt nur JWT-Gültigkeit (war: jeder eingeloggte User konnte fremde Agents per Shell/RDP übernehmen) - JWT_SECRET: Server bricht ab statt mit unsicherem Default weiterzulaufen - Auth: Token läuft jetzt über httpOnly-Cookie statt localStorage (XSS-Schutz gegen Session-Diebstahl) - WS-Auth: Token nicht mehr als URL-Query-Param (landete in nginx-Logs), sondern als erste Message bzw. automatisch via Cookie - Frontend: toter Rollen-Check (isSuperAdmin/isAdmin ohne Funktionsaufruf) in AgentDetailPage gefixt - XSS: DOMPurify-Sanitizing für alle marked.parse()-Renderstellen (KI-Antworten, Kommentare, Knowledge Base) - E-Mail: HTML-Escaping für alle ticket-gesteuerten Felder (auch über öffentliche Ticket-Route erreichbar) - SSRF-Schutz beim Knowledge-Base-URL-Import (blockt private/Loopback-Adressen) - TV-Dashboard: Shared-Key statt komplett offenem Endpoint - Striktes Rate-Limit auf /login, must_change_password serverseitig erzwungen - Agent (C#) v2.7.0: RDP-Consent/Disconnect/Capture verlangen jetzt ein Pro-Session-Secret (war: jeder lokale Prozess konnte Consent vortäuschen), DataDir-ACL für agent.log/status.json - FIDO-PINs AES-256-GCM-verschlüsselt statt Klartext, Retention-Job für alte patch_commands/audit_log Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
101 lines
3.1 KiB
C#
101 lines
3.1 KiB
C#
using ITNexusAgent;
|
|
using ITNexusAgent.Models;
|
|
using ITNexusAgent.UI;
|
|
using Newtonsoft.Json;
|
|
using System.ServiceProcess;
|
|
|
|
internal class Program
|
|
{
|
|
[STAThread]
|
|
static void Main(string[] args)
|
|
{
|
|
var exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule!.FileName;
|
|
|
|
if (args.Length > 0)
|
|
{
|
|
switch (args[0])
|
|
{
|
|
case "--notify":
|
|
RunNotification(args.Length > 1 ? args[1] : "");
|
|
return;
|
|
|
|
case "--rdp-consent":
|
|
ConsentModeRunner.Run(
|
|
args.Length > 1 ? args[1] : "",
|
|
args.Length > 2 ? args[2] : "");
|
|
return;
|
|
|
|
case "--rdp-capture":
|
|
CaptureModeRunner.Run(
|
|
args.Length > 1 ? args[1] : "",
|
|
args.Length > 2 && int.TryParse(args[2], out var si) ? si : 0,
|
|
args.Length > 3 ? args[3] : "");
|
|
return;
|
|
|
|
case "--rdp-indicator":
|
|
IndicatorModeRunner.Run(
|
|
args.Length > 1 ? args[1] : "",
|
|
args.Length > 2 ? args[2] : "");
|
|
return;
|
|
|
|
case "--dashboard":
|
|
RunDashboard();
|
|
return;
|
|
|
|
case "--install":
|
|
AgentService.MigrateFromOldAgent();
|
|
AgentService.Install(exePath);
|
|
return;
|
|
|
|
case "--uninstall":
|
|
AgentService.Uninstall();
|
|
return;
|
|
}
|
|
}
|
|
|
|
ServiceBase.Run(new AgentService());
|
|
}
|
|
|
|
static void RunNotification(string base64Json)
|
|
{
|
|
const string errorLog = @"C:\ProgramData\IT Nexus Agent\notify-error.log";
|
|
try
|
|
{
|
|
var json = Encoding.UTF8.GetString(Convert.FromBase64String(base64Json));
|
|
File.AppendAllText(errorLog, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} START json={json}\n");
|
|
|
|
var ann = JsonConvert.DeserializeObject<Announcement>(json);
|
|
if (ann == null)
|
|
{
|
|
File.AppendAllText(errorLog, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ERROR: Deserialization returned null\n");
|
|
return;
|
|
}
|
|
|
|
var app = new System.Windows.Application();
|
|
app.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose;
|
|
app.DispatcherUnhandledException += (s, e) =>
|
|
{
|
|
File.AppendAllText(errorLog, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} DISPATCHER ERROR: {e.Exception}\n");
|
|
e.Handled = true;
|
|
app.Shutdown();
|
|
};
|
|
|
|
var win = new NotificationWindow(ann);
|
|
win.Topmost = true;
|
|
win.Show();
|
|
win.Activate();
|
|
app.Run();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
File.AppendAllText(errorLog, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ERROR: {ex}\n");
|
|
}
|
|
}
|
|
|
|
static void RunDashboard()
|
|
{
|
|
var app = new System.Windows.Application();
|
|
app.Run(new DashboardWindow());
|
|
}
|
|
}
|