// ⚠️ INSECURE DEMO — 仅用于演示攻击面,禁止照抄 import { app, BrowserWindow } from "electron"; app.whenReady().then(async () => { const win = new BrowserWindow({ show: false, webPreferences: { // 这三项是经典的危险组合:页面直接拿到 Node。 contextIsolation: false, sandbox: false, nodeIntegration: true, webSecurity: true, }, }); await win.loadURL("data:text/html,

insecure

"); const probe = (await win.webContents.executeJavaScript( `({ hasRequire: typeof require !== "undefined", hasProcess: typeof process !== "undefined", })`, )) as { hasRequire: boolean; hasProcess: boolean }; console.log(JSON.stringify({ evt: "insecure-probe", ...probe })); app.quit(); });