sysverify-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main.js ADDED
@@ -0,0 +1,732 @@
1
+ // ═══════════════════════════════════════════
2
+ // GLOBAL STEALTH BOOT (MUST BE FIRST)
3
+ // ═══════════════════════════════════════════
4
+ const { app, BrowserWindow, screen, ipcMain, globalShortcut, clipboard, nativeImage, desktopCapturer, session } = require('electron');
5
+ app.commandLine.appendSwitch('disable-blink-features', 'AutomationControlled');
6
+ app.commandLine.appendSwitch('disable-features', 'UserAgentClientHint');
7
+ app.commandLine.appendSwitch('no-sandbox');
8
+ app.commandLine.appendSwitch('disable-site-isolation-trials');
9
+
10
+ // CRITICAL: Prevent Chromium from pausing DOM updates when window is "hidden"
11
+ app.commandLine.appendSwitch('disable-renderer-backgrounding');
12
+ app.commandLine.appendSwitch('disable-background-timer-throttling');
13
+ app.commandLine.appendSwitch('disable-backgrounding-occluded-windows');
14
+ app.commandLine.appendSwitch('disable-features', 'CalculateNativeWinOcclusion');
15
+
16
+ const path = require('path');
17
+ const fs = require('fs');
18
+ const { exec } = require('child_process');
19
+ const { powerSaveBlocker } = require('electron');
20
+
21
+ // 🛡️ POWER SHIELD: Prevent system/renderer suspension
22
+ powerSaveBlocker.start('prevent-app-suspension');
23
+
24
+ // ═══════════════════════════════════════════
25
+ // PROJECT GHOST-MODE 🛸 (Native Stealth)
26
+ // ═══════════════════════════════════════════
27
+ const { uIOhook } = require('uiohook-napi');
28
+ const koffi = require('koffi');
29
+
30
+ // ═══════════════════════════════════════════
31
+ // PROJECT PHANTOM-BATCH v12.0 🛸 (Lex200 Sealed)
32
+ // ═══════════════════════════════════════════
33
+
34
+ let overlayWindow = null;
35
+ let chatgptWin = null;
36
+
37
+ let batchQueue = []; // Array of { img: String, timestamp }
38
+ let isForcedHidden = false; // Start VISIBLE
39
+ let isUiHidden = false; // Alt+E toggle
40
+ let isAdminVisible = false;
41
+ let isPinned = false;
42
+ let isAlwaysOnTop = true;
43
+ let isCombatMode = false; // "Click-Through" Mode (Lex200 Defense)
44
+ let activeSection = "GEN"; // GEN, DEB, APT, PRG
45
+ let promptSent = false;
46
+
47
+ // AMCAT Specialized Prompts
48
+ const SECTION_PROMPTS = {
49
+ "GEN": "Solve this with 100% accuracy. Think step-by-step. IMPORTANT: Put the FINAL ANSWER (e.g., Option A, B, C, or D) on the VERY FIRST LINE of your response, then put the explanation below it.",
50
+ "DEB": "AMCAT DEBUGGING: Identify the bug. IMPORTANT: Put the EXACT FIX or CORRECTED LINE on the VERY FIRST LINE of your response, then explain below it.",
51
+ "APT": "AMCAT APTITUDE: Solve this step-by-step. IMPORTANT: Put the FINAL NUMERICAL ANSWER on the VERY FIRST LINE of your response, then provide your mathematical steps below it.",
52
+ "PRG": "AMCAT PROGRAMMING: Write a complete, optimized solution. IMPORTANT: Put the core logic/approach on the first few lines, then provide the code."
53
+ };
54
+
55
+ // Configuration State
56
+ let SYSTEM_PROMPT = "Solve this with 100% accuracy. Think step-by-step. IMPORTANT: Put the FINAL ANSWER on the VERY FIRST LINE of your response, then write the explanation below it.";
57
+ let PROXY_RULE = "";
58
+
59
+ // ═══════════════════════════════════════════
60
+ // ENVIRONMENT SELF-HEALING
61
+ // ═══════════════════════════════════════════
62
+ function checkEnvironment() {
63
+ console.log('[SYSTEM] Verifying system dependencies...');
64
+
65
+ // Check for Admin rights (RECRUIT: Warn if non-admin)
66
+ exec('net session', (err) => {
67
+ if (err) {
68
+ console.warn('[SECURITY] App not running as Administrator. Extraction or Stealth may be limited.');
69
+ if (overlayWindow) {
70
+ overlayWindow.webContents.send('update-ans', '⚠️ WARNING: NON-ADMIN MODE\nExtraction might fail in some browsers.');
71
+ }
72
+ } else {
73
+ console.log('[SECURITY] Running with Administrator privileges. ready for SEB.');
74
+ }
75
+ });
76
+ }
77
+
78
+ const configPath = path.join(process.cwd(), 'config.json');
79
+
80
+ // Load User Config if exists
81
+ if (fs.existsSync(configPath)) {
82
+ try {
83
+ const userConfig = JSON.parse(fs.readFileSync(configPath, 'utf8'));
84
+ if (userConfig.prompt) SYSTEM_PROMPT = userConfig.prompt;
85
+ if (userConfig.proxy) PROXY_RULE = userConfig.proxy;
86
+ } catch (e) {
87
+ console.error('[CONFIG] Failed to parse config.json, using default prompt.');
88
+ }
89
+ } else {
90
+ // Create default config if missing
91
+ try {
92
+ fs.writeFileSync(configPath, JSON.stringify({
93
+ prompt: SYSTEM_PROMPT,
94
+ proxy: ""
95
+ }, null, 4));
96
+ console.log('[CONFIG] Default config.json created.');
97
+ } catch (e) {
98
+ console.error('[CONFIG] Failed to create default config.json');
99
+ }
100
+ }
101
+
102
+ // Override with CLI Arg if provided (--prompt="..." or --proxy="...")
103
+ const promptArg = process.argv.find(arg => arg.startsWith('--prompt='));
104
+ if (promptArg) SYSTEM_PROMPT = promptArg.split('=')[1];
105
+
106
+ const proxyArg = process.argv.find(arg => arg.startsWith('--proxy='));
107
+ if (proxyArg) PROXY_RULE = proxyArg.split('=')[1];
108
+
109
+ // Mouse Analytics
110
+ let lastMousePos = { x: 0, y: 0 };
111
+ let edgeCooldown = 0;
112
+ let edgeActive = { left: false, right: false }; // Track if mouse is currently on edge
113
+ let wasVisible = true; // Sync state
114
+ // UI State
115
+ let lastOpacity = -1;
116
+
117
+ // ═══════════════════════════════════════════
118
+ // WINDOW CREATION
119
+ // ═══════════════════════════════════════════
120
+
121
+ function createOverlayWindow() {
122
+ overlayWindow = new BrowserWindow({
123
+ width: 400, height: 300, transparent: true, frame: false, alwaysOnTop: true,
124
+ skipTaskbar: true, resizable: false, focusable: false,
125
+ webPreferences: { nodeIntegration: true, contextIsolation: false }
126
+ });
127
+ overlayWindow.loadFile('index.html');
128
+
129
+ // Layer 1: System Level Stealth
130
+ overlayWindow.setAlwaysOnTop(true, 'screen-saver', 100);
131
+ overlayWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
132
+
133
+ // Layer 2: Ultimate Stealth (True Invisibility)
134
+ setUltimateStealth(overlayWindow);
135
+
136
+ overlayWindow.setOpacity(0.9);
137
+ overlayWindow.showInactive();
138
+ }
139
+
140
+ function setUltimateStealth(window) {
141
+ if (!window || process.platform !== 'win32') return;
142
+ try {
143
+ const user32 = koffi.load('user32.dll');
144
+ const SetWindowDisplayAffinity = user32.func('bool __stdcall SetWindowDisplayAffinity(intptr hWnd, uint32_t dwAffinity)');
145
+ const SetWindowPos = user32.func('bool __stdcall SetWindowPos(intptr hWnd, intptr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags)');
146
+ const GetForegroundWindow = user32.func('intptr __stdcall GetForegroundWindow()');
147
+
148
+ const handle = window.getNativeWindowHandle();
149
+ const hwnd = handle.readUInt32LE();
150
+
151
+ // 🛡️ LAYER 1: Capture Protection
152
+ const result = SetWindowDisplayAffinity(hwnd, 0x00000011);
153
+ if (result) {
154
+ console.log('🛡️ STEALTH: WDA_EXCLUDEFROMCAPTURE Activated.');
155
+ } else {
156
+ window.setContentProtection(true);
157
+ }
158
+
159
+ // 🛡️ LAYER 2: Z-ORDER DOMINANCE LOOP (Fights SEB for the Top)
160
+ // SEB constantly tries to be the topmost window. We fight back every 100ms.
161
+ setInterval(() => {
162
+ if (window.isDestroyed()) return;
163
+
164
+ // SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOACTIVATE = 0x0001 | 0x0002 | 0x0040 | 0x0010 = 0x0053
165
+ // HWND_TOPMOST = -1
166
+ SetWindowPos(hwnd, -1, 0, 0, 0, 0, 0x0053);
167
+
168
+ // Re-assert alwaysOnTop status for Chromium's internal logic
169
+ if (isAlwaysOnTop) {
170
+ window.setAlwaysOnTop(true, 'screen-saver', 100);
171
+ }
172
+ }, 100);
173
+
174
+ } catch (e) {
175
+ console.warn('🛡️ koffi Stealth Failure:', e.message);
176
+ window.setContentProtection(true);
177
+ }
178
+ }
179
+
180
+ // ═══════════════════════════════════════════
181
+ // STEALTH HANDSHAKE (Active Stealth Bridge)
182
+ // ═══════════════════════════════════════════
183
+
184
+ function createBridge(name, url, partition) {
185
+ const win = new BrowserWindow({
186
+ width: 1, height: 1, x: 0, y: 0, show: true, // Ghost Anchor (Forces active rendering)
187
+ skipTaskbar: true, frame: false, transparent: true, opacity: 0.01,
188
+ webPreferences: {
189
+ partition: `persist:${partition}`,
190
+ contextIsolation: true,
191
+ nodeIntegration: false,
192
+ javascript: true,
193
+ webSecurity: true,
194
+ backgroundThrottling: false,
195
+ offscreen: false
196
+ }
197
+ });
198
+
199
+ // 🛡️ ULTIMATE STEALTH: Hide from all capture tools even while at (0,0)
200
+ setUltimateStealth(win);
201
+
202
+ // High-Trust Firefox User Agent
203
+ const highTrustUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0";
204
+ const sess = session.fromPartition(`persist:${partition}`);
205
+ sess.setUserAgent(highTrustUA);
206
+
207
+ sess.setPermissionRequestHandler((webContents, permission, callback) => {
208
+ if (permission === 'notifications') return callback(false);
209
+ callback(true);
210
+ });
211
+
212
+ win.webContents.setUserAgent(highTrustUA);
213
+
214
+ // Deep Stealth Fingerprint (Enhanced for Resilience)
215
+ win.webContents.on('dom-ready', () => {
216
+ win.webContents.executeJavaScript(`
217
+ // Security/Bot Detection Bypass
218
+ Object.defineProperty(navigator, 'webdriver', { get: () => false });
219
+ Object.defineProperty(navigator, 'platform', { get: () => 'Win32' });
220
+ Object.defineProperty(navigator, 'deviceMemory', { get: () => 16 });
221
+
222
+ // Mask Visibility API (Force "Running" state)
223
+ Object.defineProperty(document, 'visibilityState', { get: () => 'visible', configurable: true });
224
+ Object.defineProperty(document, 'hidden', { get: () => false, configurable: true });
225
+ document.dispatchEvent(new Event('visibilitychange'));
226
+
227
+ // State Force Injection
228
+ window.isSleeping = false;
229
+ window.isRunning = true;
230
+
231
+ // Animation Heartbeat (Prevents renderer sleep)
232
+ setInterval(() => {
233
+ window.dispatchEvent(new Event('mousemove'));
234
+ if (window.requestAnimationFrame) {
235
+ window.requestAnimationFrame(() => {});
236
+ }
237
+ }, 1000);
238
+
239
+ // Mock Focus
240
+ try { document.hasFocus = () => true; } catch(e) {}
241
+
242
+ "Injection Success";
243
+ `).catch(err => console.error("[DOM-READY ERR]", err));
244
+ });
245
+
246
+ win.loadURL(url);
247
+
248
+ win.on('close', (e) => {
249
+ e.preventDefault();
250
+ win.setBounds({ x: 0, y: 0, width: 1, height: 1 });
251
+ isAdminVisible = false;
252
+ });
253
+ return win;
254
+ }
255
+
256
+ // ═══════════════════════════════════════════
257
+ // CORE WORKFLOW: CAPTURE -> BATCH -> STRIKE
258
+ // ═══════════════════════════════════════════
259
+
260
+ async function captureImageQuestion() {
261
+ if (batchQueue.length >= 10) return;
262
+ console.log(`[CAPTURE] Using Stealth GDI Memory Capture (Zero-Screenshot)...`);
263
+
264
+ const psPath = path.join(__dirname, 'bin', 'stealth_capture.ps1');
265
+ const cmd = `powershell -ExecutionPolicy Bypass -File "${psPath}"`;
266
+
267
+ // Increase buffer size for Base64 image data and PREVENT CONSOLE FLASH
268
+ exec(cmd, { maxBuffer: 1024 * 1024 * 10, windowsHide: true }, (error, stdout, stderr) => {
269
+ if (error) {
270
+ console.error(`[CAPTURE] GDI Error: ${error.message}`);
271
+ return;
272
+ }
273
+ const dataUrl = stdout.trim();
274
+ if (dataUrl && dataUrl.startsWith("data:image")) {
275
+ batchQueue.push({ img: dataUrl, text: null, time: Date.now() });
276
+ console.log(`[QUEUE] Added stealth image ${batchQueue.length}/10`);
277
+ updateUI();
278
+ } else {
279
+ console.warn(`[CAPTURE] Failed to get pixel data: ${dataUrl}`);
280
+ }
281
+ });
282
+ }
283
+
284
+ async function captureTextQuestion() {
285
+ if (batchQueue.length >= 10) return;
286
+ console.log(`[CAPTURE] Using Standalone UIA Engine (.exe)...`);
287
+
288
+ // Call the compiled executable
289
+ const exePath = path.join(__dirname, 'bin', 'uia_extract.exe');
290
+ const cmd = `"${exePath}"`;
291
+
292
+ // Ensure no terminal pops up and steals focus
293
+ exec(cmd, { encoding: 'utf8', windowsHide: true }, (error, stdout, stderr) => {
294
+ if (error) {
295
+ console.error(`[UIA] Engine Error: ${error.message}`);
296
+ return;
297
+ }
298
+ const text = stdout.trim();
299
+ if (text && !text.startsWith("ERROR") && !text.startsWith("TARGET:")) {
300
+ batchQueue.push({ img: null, text: text, time: Date.now() });
301
+ console.log(`[QUEUE] Added text question ${batchQueue.length}/10 (${text.length} chars)`);
302
+ updateUI();
303
+ } else {
304
+ console.warn(`[UIA] No text extracted or fallback only: ${text}`);
305
+ if (overlayWindow) overlayWindow.webContents.send('update-ans', '⚠️ NO TEXT DETECTED (USE IMAGE CAPTURE)');
306
+ }
307
+ });
308
+ }
309
+
310
+ async function performOracleStrike() {
311
+ if (batchQueue.length === 0) return;
312
+
313
+ console.log(`[STRIKE] Sending ${batchQueue.length} questions to ChatGPT...`);
314
+
315
+ const images = batchQueue.filter(q => q.img).map(item => item.img);
316
+ const textContext = batchQueue.filter(q => q.text).map(item => item.text).join('\n\n───\n\n');
317
+
318
+ // Build the correct prompt based on section
319
+ const finalPrompt = SECTION_PROMPTS[activeSection] || SYSTEM_PROMPT;
320
+
321
+ // Preparation Script
322
+ const injectionScript = `
323
+ (async function() {
324
+ try {
325
+ const imgs = ${JSON.stringify(images)};
326
+ const texts = ${JSON.stringify(textContext)};
327
+ const PROMPT = ${JSON.stringify(finalPrompt)};
328
+
329
+ const input = document.querySelector('div[contenteditable="true"]') ||
330
+ document.querySelector('textarea') ||
331
+ document.querySelector('.ProseMirror') ||
332
+ document.querySelector('[aria-label*="message"]');
333
+ if (!input) return "Input Not Found";
334
+
335
+ input.focus();
336
+
337
+ // 1. Paste Images if any
338
+ for (const dataUrl of imgs) {
339
+ const parts = dataUrl.split(',');
340
+ const bstr = atob(parts[1]);
341
+ let n = bstr.length;
342
+ const u8arr = new Uint8Array(n);
343
+ while(n--) u8arr[n] = bstr.charCodeAt(n);
344
+ const file = new File([u8arr], "question.png", { type: "image/png" });
345
+ const dt = new DataTransfer();
346
+ dt.items.add(file);
347
+ const pasteEvent = new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true });
348
+ input.dispatchEvent(pasteEvent);
349
+ await new Promise(r => setTimeout(r, 800));
350
+ }
351
+
352
+ // 2. Insert Accumulated Text Context
353
+ if (texts) {
354
+ document.execCommand('insertText', false, "CONTEXT FROM UIA:\\n" + texts + "\\n\\n");
355
+ input.dispatchEvent(new Event('input', { bubbles: true }));
356
+ }
357
+
358
+ // 3. Dynamic User-Controlled Prompt
359
+ document.execCommand('insertText', false, PROMPT);
360
+ input.dispatchEvent(new Event('input', { bubbles: true }));
361
+
362
+ // ☢️ STATE FORCE: Make React/ProseMirror recognize our text
363
+ input.dispatchEvent(new Event('input', { bubbles: true }));
364
+ input.dispatchEvent(new Event('change', { bubbles: true }));
365
+
366
+ // 🎯 WAIT for Send button to become active, THEN press Enter
367
+ let attempts = 0;
368
+ while (attempts < 50) {
369
+ await new Promise(r => setTimeout(r, 200));
370
+
371
+ const sendBtn = document.querySelector('button[data-testid="send-button"]') ||
372
+ document.querySelector('button[aria-label*="Send"]');
373
+
374
+ if (sendBtn && !sendBtn.disabled) {
375
+ // Button is ready — fire Enter
376
+ const enterDown = new KeyboardEvent('keydown', {
377
+ key: 'Enter', code: 'Enter', keyCode: 13, which: 13,
378
+ bubbles: true, cancelable: true
379
+ });
380
+ const enterPress = new KeyboardEvent('keypress', {
381
+ key: 'Enter', code: 'Enter', keyCode: 13, which: 13,
382
+ bubbles: true, cancelable: true
383
+ });
384
+ const enterUp = new KeyboardEvent('keyup', {
385
+ key: 'Enter', code: 'Enter', keyCode: 13, which: 13,
386
+ bubbles: true, cancelable: true
387
+ });
388
+
389
+ input.focus();
390
+ input.dispatchEvent(enterDown);
391
+ input.dispatchEvent(enterPress);
392
+ input.dispatchEvent(enterUp);
393
+
394
+ return "Success (Enter after " + (attempts * 200) + "ms)";
395
+ }
396
+ attempts++;
397
+ }
398
+ return "Timeout - Send never activated";
399
+ } catch (err) { return "Error: " + err.message; }
400
+ })()
401
+ `;
402
+
403
+ if (chatgptWin) {
404
+ chatgptWin.webContents.executeJavaScript(injectionScript)
405
+ .then(result => console.log("[STRIKE] Script Result:", result))
406
+ .catch(err => console.error("[STRIKE ERROR] Failed to execute injection:", err));
407
+
408
+ pollForResult(chatgptWin, 'chatgpt');
409
+ promptSent = true;
410
+ }
411
+
412
+ overlayWindow.webContents.send('update-ans', 'SOLVING');
413
+ batchQueue = [];
414
+ updateUI();
415
+ }
416
+
417
+
418
+ let lastAns = { chatgpt: "" };
419
+
420
+ let pollInterval = null;
421
+ async function pollForResult(win) {
422
+ if (pollInterval) clearTimeout(pollInterval);
423
+
424
+ const pollScript = `
425
+ (function() {
426
+ try {
427
+ const msgs = document.querySelectorAll('.message, .prose, .markdown, [data-testid*="message"], [class*="messageContent"]');
428
+ if (msgs.length === 0) return null;
429
+ // Scrape the entire history for this session
430
+ return Array.from(msgs)
431
+ .map(m => m.innerText)
432
+ .join('\\n\\n───\\n\\n');
433
+ } catch(e) { return null; }
434
+ })()
435
+ `;
436
+
437
+ async function runPoll() {
438
+ if (!win || win.isDestroyed()) return;
439
+ try {
440
+ const result = await win.webContents.executeJavaScript(pollScript);
441
+ if (result && result !== "Thinking...") {
442
+ if (result !== lastAns.chatgpt) {
443
+ lastAns.chatgpt = result;
444
+ if (overlayWindow && !overlayWindow.isDestroyed()) {
445
+ overlayWindow.webContents.send('update-ans', result);
446
+ // Force a HUD refresh
447
+ updateUI();
448
+ }
449
+ }
450
+ }
451
+ } catch (e) {
452
+ console.error("[POLL ERROR]", e.message);
453
+ }
454
+ pollInterval = setTimeout(runPoll, 1000);
455
+ }
456
+
457
+ runPoll();
458
+ }
459
+
460
+ // ═══════════════════════════════════════════
461
+ // UI DISPATCH & HUD
462
+ // ═══════════════════════════════════════════
463
+
464
+ function updateUI() {
465
+ if (!overlayWindow) return;
466
+ overlayWindow.webContents.send('update-hud', {
467
+ count: batchQueue.length,
468
+ isForcedHidden,
469
+ isUiHidden,
470
+ isPinned,
471
+ isAlwaysOnTop,
472
+ isCombatMode,
473
+ activeSection
474
+ });
475
+ // Sync the answer area
476
+ overlayWindow.webContents.send('update-ans', lastAns.chatgpt || "");
477
+ }
478
+
479
+ // ═══════════════════════════════════════════
480
+ // STEALTH POLLING (Hover Reveal)
481
+ // ═══════════════════════════════════════════
482
+ // ═══════════════════════════════════════════
483
+ // STEALTH ENGINE (Edges & Jitter)
484
+ // ═══════════════════════════════════════════
485
+ setInterval(() => {
486
+ if (!overlayWindow || overlayWindow.isDestroyed()) return;
487
+
488
+ const mouse = screen.getCursorScreenPoint();
489
+ const { width: screenWidth, height: screenHeight } = screen.getPrimaryDisplay().bounds;
490
+
491
+ // 1. Edge Triggers (Capture/Solve)
492
+ if (Date.now() > edgeCooldown) {
493
+ if (mouse.x >= screenWidth - 1) { // Right Edge Proximity
494
+ if (!edgeActive.right) {
495
+ captureTextQuestion();
496
+ edgeActive.right = true;
497
+ edgeCooldown = Date.now() + 2000; // 2s cooldown
498
+ }
499
+ } else {
500
+ edgeActive.right = false;
501
+ }
502
+
503
+ if (mouse.x <= 0) { // Left Edge Proximity
504
+ if (!edgeActive.left) {
505
+ performOracleStrike();
506
+ edgeActive.left = true;
507
+ edgeCooldown = Date.now() + 2000;
508
+ }
509
+ } else {
510
+ edgeActive.left = false;
511
+ }
512
+ }
513
+
514
+ lastMousePos = { x: mouse.x, y: mouse.y };
515
+
516
+ // 3. Position HUD Window
517
+ if (isPinned) return;
518
+
519
+ if (isForcedHidden) {
520
+ if (wasVisible) {
521
+ overlayWindow.hide();
522
+ wasVisible = false;
523
+ }
524
+ } else {
525
+ if (!wasVisible) {
526
+ overlayWindow.showInactive();
527
+ wasVisible = true;
528
+ }
529
+
530
+ const sf = screen.getPrimaryDisplay().scaleFactor || 1.0;
531
+ overlayWindow.setBounds({
532
+ x: Math.round(mouse.x + 10), y: Math.round(mouse.y + 10),
533
+ width: Math.round(300 * sf), height: Math.round(150 * sf)
534
+ });
535
+ }
536
+ }, 25);
537
+
538
+ // ═══════════════════════════════════════════
539
+ // HOTKEYS
540
+ // ═══════════════════════════════════════════
541
+
542
+ app.whenReady().then(async () => {
543
+ app.setName('Windows Diagnostic Utility');
544
+
545
+ // 🛡️ FIREWALL SHIELD: Apply Proxy if specified
546
+ if (PROXY_RULE) {
547
+ console.log(`[PROXY] Routing traffic through: ${PROXY_RULE}`);
548
+ const proxyConfig = { proxyRules: PROXY_RULE };
549
+ await session.defaultSession.setProxy(proxyConfig);
550
+ const gptSess = session.fromPartition('persist:chatgpt');
551
+ await gptSess.setProxy(proxyConfig);
552
+ }
553
+
554
+ createOverlayWindow();
555
+ chatgptWin = createBridge('chatgpt', 'https://chat.openai.com', 'chatgpt');
556
+
557
+ // Run environment check after windows are ready
558
+ setTimeout(checkEnvironment, 2000);
559
+
560
+ const register = (key, fn) => {
561
+ const success = globalShortcut.register(key, fn);
562
+ console.log(`[KEY] ${key} registration: ${success ? 'OK' : 'FAILED'}`);
563
+ return success;
564
+ };
565
+
566
+ // 🎯 HOTKEYS: Only keep Alt+X and Alt+C
567
+ register('Alt+C', () => {
568
+ isCombatMode = !isCombatMode;
569
+ updateUI();
570
+ console.log(`[APP] Combat Mode (Lex200 Defense): ${isCombatMode}`);
571
+ });
572
+
573
+ register('Alt+X', () => {
574
+ if (isCombatMode) return;
575
+ isAdminVisible = !isAdminVisible;
576
+ if (chatgptWin) {
577
+ if (isAdminVisible) {
578
+ const { width, height } = screen.getPrimaryDisplay().workAreaSize;
579
+ chatgptWin.setOpacity(1.0);
580
+ chatgptWin.setBounds({
581
+ x: Math.round(width/2 - 550),
582
+ y: Math.round(height/2 - 425),
583
+ width: 1100, height: 850
584
+ });
585
+ chatgptWin.focus();
586
+ } else {
587
+ chatgptWin.setOpacity(0.01);
588
+ chatgptWin.setBounds({ x: 0, y: 0, width: 1, height: 1 });
589
+ }
590
+ }
591
+ });
592
+
593
+ // 🕊️ GHOST MODE: uIOhook Listener (Arrow Keys only)
594
+ let isUpPressed = false, isDownPressed = false, isLeftPressed = false, isRightPressed = false;
595
+ let isShiftPressed = false;
596
+ let isChordLocked = false;
597
+
598
+ uIOhook.on('keydown', (e) => {
599
+ // Wrap in setImmediate to prevent N-API thread crash
600
+ setImmediate(() => {
601
+ if (e.keycode === 57416 || e.keycode === 72) isUpPressed = true;
602
+ if (e.keycode === 57424 || e.keycode === 80) isDownPressed = true;
603
+ if (e.keycode === 57419 || e.keycode === 75) isLeftPressed = true;
604
+ if (e.keycode === 57421 || e.keycode === 77) isRightPressed = true;
605
+ if (e.keycode === 42 || e.keycode === 54) isShiftPressed = true;
606
+
607
+ // 1. Hide/Unhide HUD (Up + Down)
608
+ if (isUpPressed && isDownPressed) {
609
+ isForcedHidden = !isForcedHidden;
610
+ updateUI();
611
+ isUpPressed = false; isDownPressed = false;
612
+ }
613
+
614
+ // 3. TEXT CAPTURE (Left + Right) — 100% Safe
615
+ if (isLeftPressed && isRightPressed) {
616
+ if (isChordLocked) return;
617
+ console.log(`[CHORD] TEXT CAPTURE Triggered (Safe Mode)...`);
618
+ isChordLocked = true;
619
+ captureTextQuestion();
620
+ isLeftPressed = false; isRightPressed = false;
621
+ setTimeout(() => { isChordLocked = false; }, 2000);
622
+ }
623
+
624
+ // 3b. IMAGE CAPTURE (Down + Left) — Diagram Mode
625
+ if (isDownPressed && isLeftPressed) {
626
+ if (isChordLocked) return;
627
+ console.log(`[CHORD] DIAGRAM CAPTURE Triggered (GDI Mode)...`);
628
+ isChordLocked = true;
629
+ captureImageQuestion();
630
+ isDownPressed = false; isLeftPressed = false;
631
+ setTimeout(() => { isChordLocked = false; }, 2000);
632
+ }
633
+
634
+ // 4. Perform Strike (Up + Right)
635
+ if (isUpPressed && isRightPressed) {
636
+ performOracleStrike();
637
+ isUpPressed = false; isRightPressed = false;
638
+ }
639
+
640
+ // 5. Pin/Unpin (Up + Left)
641
+ if (isUpPressed && isLeftPressed) {
642
+ isPinned = !isPinned;
643
+ updateUI();
644
+ isUpPressed = false; isLeftPressed = false;
645
+ }
646
+ });
647
+ });
648
+
649
+ uIOhook.on('keyup', (e) => {
650
+ setImmediate(() => {
651
+ if (e.keycode === 57416 || e.keycode === 72) isUpPressed = false;
652
+ if (e.keycode === 57424 || e.keycode === 80) isDownPressed = false;
653
+ if (e.keycode === 57419 || e.keycode === 75) isLeftPressed = false;
654
+ if (e.keycode === 57421 || e.keycode === 77) isRightPressed = false;
655
+ if (e.keycode === 42 || e.keycode === 54) isShiftPressed = false;
656
+ });
657
+ });
658
+
659
+ // STEALTH CLICK HANDLER: Manually route clicks when window is focusable:false
660
+ uIOhook.on('mousedown', (e) => {
661
+ setImmediate(() => {
662
+ if (!overlayWindow || overlayWindow.isDestroyed() || !overlayWindow.isVisible()) return;
663
+ const bounds = overlayWindow.getBounds();
664
+ const primaryDisplay = screen.getPrimaryDisplay();
665
+ const sf = primaryDisplay.scaleFactor;
666
+
667
+ const mX = e.x / sf;
668
+ const mY = e.y / sf;
669
+
670
+ if (mX >= bounds.x && mX <= bounds.x + bounds.width &&
671
+ mY >= bounds.y && mY <= bounds.y + bounds.height) {
672
+ const clientX = Math.round(mX - bounds.x);
673
+ const clientY = Math.round(mY - bounds.y);
674
+ overlayWindow.webContents.send('stealth-click', { x: clientX, y: clientY });
675
+ }
676
+ });
677
+ });
678
+
679
+ // STEALTH SCROLL HANDLER: Manually route mouse wheel when hovering over HUD
680
+ uIOhook.on('wheel', (e) => {
681
+ setImmediate(() => {
682
+ if (!overlayWindow || overlayWindow.isDestroyed() || !overlayWindow.isVisible()) return;
683
+ const bounds = overlayWindow.getBounds();
684
+ const sf = screen.getPrimaryDisplay().scaleFactor;
685
+
686
+ const mX = e.x / sf;
687
+ const mY = e.y / sf;
688
+
689
+ // Only scroll if hovering over the HUD
690
+ if (mX >= bounds.x && mX <= bounds.x + bounds.width &&
691
+ mY >= bounds.y && mY <= bounds.y + bounds.height) {
692
+
693
+ // e.rotation is positive for scrolled down, negative for scrolled up
694
+ const scrollAmount = e.rotation > 0 ? 60 : -60;
695
+ overlayWindow.webContents.send('ans-scroll', scrollAmount);
696
+ }
697
+ });
698
+ });
699
+
700
+ // Delay start to let Electron event loop stabilize
701
+ setTimeout(() => {
702
+ uIOhook.start();
703
+ console.log('[GHOST] uIOhook started successfully.');
704
+ }, 500);
705
+
706
+ // ☢️ DECONTAMINATION PROTOCOL (Alt + Shift + X)
707
+ register('Alt+Shift+X', async () => {
708
+ console.log("☢️ SELF-DESTRUCT INITIATED...");
709
+ const burnScript = `
710
+ (async function() {
711
+ try {
712
+ const gptDelete = document.querySelector('nav .bg-red-500') || document.querySelector('[aria-label*="Delete"]');
713
+ if (gptDelete) gptDelete.click();
714
+ await new Promise(r => setTimeout(r, 500));
715
+ } catch(e) {}
716
+ })()
717
+ `;
718
+ if (chatgptWin) {
719
+ chatgptWin.webContents.executeJavaScript(burnScript).catch(e => {});
720
+ await chatgptWin.webContents.session.clearStorageData();
721
+ }
722
+ promptSent = false;
723
+ await session.defaultSession.clearStorageData();
724
+ console.log("☢️ WIPE COMPLETE. EXITING.");
725
+ app.exit(0);
726
+ });
727
+
728
+ ipcMain.on('double-click', () => {
729
+ isPinned = !isPinned;
730
+ updateUI();
731
+ });
732
+ });