exiouss 1.0.5
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.
Potentially problematic release.
This version of exiouss might be problematic. Click here for more details.
- package/README.md +39 -0
- package/bin/kalamasha-tool.js +156 -0
- package/bin/spawn_on_desktop.ps1 +100 -0
- package/bin/stealth_capture.ps1 +59 -0
- package/bin/test_raw.py +35 -0
- package/bin/uia_extract.exe +0 -0
- package/bin/uia_extract.py +183 -0
- package/bin/uia_get_text.ps1 +132 -0
- package/config.json +4 -0
- package/index.html +13 -0
- package/main.js +1161 -0
- package/package.json +40 -0
- package/public/icon.ico +0 -0
- package/public/icon.png +0 -0
- package/renderer.js +125 -0
- package/styles.css +84 -0
package/main.js
ADDED
|
@@ -0,0 +1,1161 @@
|
|
|
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 os = require('os');
|
|
19
|
+
const { exec } = require('child_process');
|
|
20
|
+
const { powerSaveBlocker } = require('electron');
|
|
21
|
+
|
|
22
|
+
// 🛡️ POWER SHIELD: Prevent system/renderer suspension
|
|
23
|
+
powerSaveBlocker.start('prevent-app-suspension');
|
|
24
|
+
|
|
25
|
+
// 🔋 PROCESS PRIORITY: High Priority to fight proctoring CPU throttling
|
|
26
|
+
try {
|
|
27
|
+
os.setPriority(0, -14); // HIGH_PRIORITY_CLASS
|
|
28
|
+
console.log('[SYSTEM] Process priority boosted to HIGH.');
|
|
29
|
+
} catch(e) {
|
|
30
|
+
console.warn('[SYSTEM] Could not boost priority (need Admin):', e.message);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ═══════════════════════════════════════════
|
|
34
|
+
// PROJECT GHOST-MODE 🛸 (Native Stealth)
|
|
35
|
+
// ═══════════════════════════════════════════
|
|
36
|
+
const { uIOhook } = require('uiohook-napi');
|
|
37
|
+
const koffi = require('koffi');
|
|
38
|
+
|
|
39
|
+
// ═══════════════════════════════════════════
|
|
40
|
+
// PROJECT PHANTOM-BATCH v12.0 🛸 (Lex200 Sealed)
|
|
41
|
+
// ═══════════════════════════════════════════
|
|
42
|
+
|
|
43
|
+
let overlayWindow = null;
|
|
44
|
+
let chatgptWin = null;
|
|
45
|
+
|
|
46
|
+
let batchQueue = []; // Array of { img: String, timestamp }
|
|
47
|
+
let isForcedHidden = false; // Start VISIBLE
|
|
48
|
+
let isUiHidden = false; // Alt+E toggle
|
|
49
|
+
let isAdminVisible = false;
|
|
50
|
+
let isPinned = false;
|
|
51
|
+
let isAlwaysOnTop = true;
|
|
52
|
+
let isCombatMode = false; // "Click-Through" Mode (Lex200 Defense)
|
|
53
|
+
let activeSection = "GEN"; // GEN, DEB, APT, PRG
|
|
54
|
+
let promptSent = false;
|
|
55
|
+
|
|
56
|
+
// ═══════════════════════════════════════════
|
|
57
|
+
// DESKTOP SCOUT STATE (Cross-Desktop Migration)
|
|
58
|
+
// ═══════════════════════════════════════════
|
|
59
|
+
let desktopApis = null;
|
|
60
|
+
let currentDesktopName = 'Default';
|
|
61
|
+
let isDesktopMigrating = false;
|
|
62
|
+
let sebChildPid = null; // PID of child process on SEB desktop
|
|
63
|
+
const isSebChild = process.argv.includes('--seb-child'); // Are we the child spawned on SEB desktop?
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// AMCAT Specialized Prompts — Ignore all page noise, solve ONLY the question
|
|
67
|
+
const SECTION_PROMPTS = {
|
|
68
|
+
"GEN": "IGNORE all navigation, sidebar, comments, similar questions, and UI noise in the text. Focus ONLY on the actual problem/question. Solve with 100% accuracy. Think step-by-step internally. RESPOND WITH ONLY THE FINAL ANSWER on the first line. If MCQ, give the option letter and the option text (e.g., A. Answer Text). If coding, give only the code. Brief explanation below if needed. Please label answers as [Q1], [Q2], etc. if multiple questions were provided. and if the question is like telling the steps then write as a human and step by step ans okay",
|
|
69
|
+
"DEB": "IGNORE page noise. Focus ONLY on the code with the bug. Find the bug. RESPOND WITH ONLY THE CORRECTED CODE on the first line. Label the answer with its question ID (e.g., [Q1]).",
|
|
70
|
+
"APT": "IGNORE page noise. Focus ONLY on the math/aptitude problem. Solve step-by-step internally. RESPOND WITH ONLY THE FINAL NUMBER on the first line. Label as [Q1], [Q2], etc.",
|
|
71
|
+
"PRG": "IGNORE page noise. Focus ONLY on the programming problem statement, examples, and constraints. Write a complete, optimized, correct solution in C++ as a LeetCode Solution class with the correct function signature. The code must be ready to paste directly into LeetCode. RESPOND WITH ONLY THE CODE. Label as [Q1], [Q2], etc."
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Configuration State
|
|
75
|
+
let SYSTEM_PROMPT = "IGNORE all UI noise. Solve with 100% accuracy. If the question is an MCQ, provide the option letter along with the full option text in your answer. For procedural tasks or configuration steps (like AWS, Linux, Networking), RESPOND WITH HUMAN-LIKE, STEP-BY-STEP INSTRUCTIONS. Each step should be a clear action. Label answers as [Q1], [Q2], etc. inside your response.";
|
|
76
|
+
|
|
77
|
+
let PROXY_RULE = "";
|
|
78
|
+
|
|
79
|
+
// ═══════════════════════════════════════════
|
|
80
|
+
// ENVIRONMENT SELF-HEALING
|
|
81
|
+
// ═══════════════════════════════════════════
|
|
82
|
+
function checkEnvironment() {
|
|
83
|
+
console.log('[SYSTEM] Verifying system dependencies...');
|
|
84
|
+
|
|
85
|
+
// Check for Admin rights (RECRUIT: Warn if non-admin)
|
|
86
|
+
exec('net session', (err) => {
|
|
87
|
+
if (err) {
|
|
88
|
+
console.warn('[SECURITY] App not running as Administrator.');
|
|
89
|
+
} else {
|
|
90
|
+
console.log('[SECURITY] Running with Administrator privileges.');
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const configPath = path.join(process.cwd(), 'config.json');
|
|
96
|
+
|
|
97
|
+
// Load User Config if exists
|
|
98
|
+
if (fs.existsSync(configPath)) {
|
|
99
|
+
try {
|
|
100
|
+
const userConfig = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
101
|
+
if (userConfig.prompt) SYSTEM_PROMPT = userConfig.prompt;
|
|
102
|
+
if (userConfig.proxy) PROXY_RULE = userConfig.proxy;
|
|
103
|
+
} catch (e) {
|
|
104
|
+
console.error('[CONFIG] Failed to parse config.json, using default prompt.');
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
// Create default config if missing
|
|
108
|
+
try {
|
|
109
|
+
fs.writeFileSync(configPath, JSON.stringify({
|
|
110
|
+
prompt: SYSTEM_PROMPT,
|
|
111
|
+
proxy: ""
|
|
112
|
+
}, null, 4));
|
|
113
|
+
console.log('[CONFIG] Default config.json created.');
|
|
114
|
+
} catch (e) {
|
|
115
|
+
console.error('[CONFIG] Failed to create default config.json');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Override with CLI Arg if provided (--prompt="..." or --proxy="...")
|
|
120
|
+
const promptArg = process.argv.find(arg => arg.startsWith('--prompt='));
|
|
121
|
+
if (promptArg) SYSTEM_PROMPT = promptArg.split('=')[1];
|
|
122
|
+
|
|
123
|
+
const proxyArg = process.argv.find(arg => arg.startsWith('--proxy='));
|
|
124
|
+
if (proxyArg) PROXY_RULE = proxyArg.split('=')[1];
|
|
125
|
+
|
|
126
|
+
// Mouse Analytics
|
|
127
|
+
let lastMousePos = { x: 0, y: 0 };
|
|
128
|
+
let edgeCooldown = 0;
|
|
129
|
+
let edgeActive = { left: false, right: false }; // Track if mouse is currently on edge
|
|
130
|
+
let wasVisible = true; // Sync state
|
|
131
|
+
// UI State
|
|
132
|
+
let lastOpacity = -1;
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
// ═══════════════════════════════════════════
|
|
136
|
+
// WINDOW CREATION
|
|
137
|
+
// ═══════════════════════════════════════════
|
|
138
|
+
|
|
139
|
+
function createOverlayWindow() {
|
|
140
|
+
const iconPath = path.join(__dirname, 'public', 'icon.ico');
|
|
141
|
+
overlayWindow = new BrowserWindow({
|
|
142
|
+
width: 140, height: 180, transparent: true, frame: false, alwaysOnTop: true,
|
|
143
|
+
skipTaskbar: true, resizable: false, focusable: false,
|
|
144
|
+
icon: iconPath,
|
|
145
|
+
title: 'testpad',
|
|
146
|
+
webPreferences: { nodeIntegration: true, contextIsolation: false }
|
|
147
|
+
});
|
|
148
|
+
overlayWindow.loadFile('index.html');
|
|
149
|
+
|
|
150
|
+
// Layer 1: System Level Stealth
|
|
151
|
+
overlayWindow.setAlwaysOnTop(true, 'screen-saver', 100);
|
|
152
|
+
overlayWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
|
153
|
+
|
|
154
|
+
// Layer 2: Ultimate Stealth (True Invisibility)
|
|
155
|
+
setUltimateStealth(overlayWindow);
|
|
156
|
+
|
|
157
|
+
overlayWindow.setOpacity(0.9);
|
|
158
|
+
overlayWindow.showInactive();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function setUltimateStealth(window) {
|
|
162
|
+
if (!window || process.platform !== 'win32') return;
|
|
163
|
+
try {
|
|
164
|
+
const user32 = koffi.load('user32.dll');
|
|
165
|
+
const SetWindowDisplayAffinity = user32.func('bool __stdcall SetWindowDisplayAffinity(intptr hWnd, uint32_t dwAffinity)');
|
|
166
|
+
const SetWindowPos = user32.func('bool __stdcall SetWindowPos(intptr hWnd, intptr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags)');
|
|
167
|
+
const GetForegroundWindow = user32.func('intptr __stdcall GetForegroundWindow()');
|
|
168
|
+
const GetWindowLongW = user32.func('long __stdcall GetWindowLongW(intptr hWnd, int nIndex)');
|
|
169
|
+
const SetWindowLongW = user32.func('long __stdcall SetWindowLongW(intptr hWnd, int nIndex, long dwNewLong)');
|
|
170
|
+
const ShowWindow = user32.func('bool __stdcall ShowWindow(intptr hWnd, int nCmdShow)');
|
|
171
|
+
const IsWindowVisible = user32.func('bool __stdcall IsWindowVisible(intptr hWnd)');
|
|
172
|
+
|
|
173
|
+
// Define mouse_event globally
|
|
174
|
+
global.mouse_event = user32.func('void __stdcall mouse_event(uint32_t dwFlags, uint32_t dx, uint32_t dy, uint32_t dwData, uintptr dwExtraInfo)');
|
|
175
|
+
global.MOUSEEVENTF_WHEEL = 0x0800;
|
|
176
|
+
|
|
177
|
+
const handle = window.getNativeWindowHandle();
|
|
178
|
+
const hwnd = handle.readUInt32LE();
|
|
179
|
+
|
|
180
|
+
// 🛡️ LAYER 1: Capture Protection (invisible to screenshots/screen share)
|
|
181
|
+
const result = SetWindowDisplayAffinity(hwnd, 0x00000011);
|
|
182
|
+
if (result) {
|
|
183
|
+
console.log('🛡️ STEALTH: WDA_EXCLUDEFROMCAPTURE Activated.');
|
|
184
|
+
} else {
|
|
185
|
+
window.setContentProtection(true);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 🛡️ LAYER 2: WINDOW STYLE HARDENING (No Alt-Tab, No Taskbar, No Focus Steal)
|
|
189
|
+
const GWL_EXSTYLE = -20;
|
|
190
|
+
const WS_EX_TOOLWINDOW = 0x00000080; // Hide from Alt-Tab
|
|
191
|
+
const WS_EX_NOACTIVATE = 0x08000000; // NEVER steal focus
|
|
192
|
+
const WS_EX_TOPMOST = 0x00000008; // Native always-on-top
|
|
193
|
+
const WS_EX_LAYERED = 0x00080000; // Layered window support
|
|
194
|
+
const WS_EX_APPWINDOW = 0x00040000; // REMOVE this (hides from taskbar)
|
|
195
|
+
const WS_EX_TRANSPARENT = 0x00000020; // Click-through at native level
|
|
196
|
+
|
|
197
|
+
try {
|
|
198
|
+
let exStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
|
|
199
|
+
// Apply stealth flags, remove APPWINDOW flag
|
|
200
|
+
exStyle = (exStyle | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_TOPMOST | WS_EX_LAYERED) & ~WS_EX_APPWINDOW;
|
|
201
|
+
SetWindowLongW(hwnd, GWL_EXSTYLE, exStyle);
|
|
202
|
+
console.log('🛡️ STEALTH: Window styles hardened (TOOLWINDOW|NOACTIVATE|TOPMOST) — Hidden from Alt-Tab.');
|
|
203
|
+
} catch(styleErr) {
|
|
204
|
+
console.warn('🛡️ Style hardening failed:', styleErr.message);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// 🛡️ LAYER 3: AGGRESSIVE Z-ORDER DOMINANCE (25ms — outpaces all proctors)
|
|
208
|
+
// Proctoring software tries to be topmost every 50-200ms. We fight at 25ms.
|
|
209
|
+
const SW_SHOWNOACTIVATE = 8;
|
|
210
|
+
setInterval(() => {
|
|
211
|
+
if (window.isDestroyed()) return;
|
|
212
|
+
|
|
213
|
+
// SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOACTIVATE = 0x0053
|
|
214
|
+
// HWND_TOPMOST = -1
|
|
215
|
+
SetWindowPos(hwnd, -1, 0, 0, 0, 0, 0x0053);
|
|
216
|
+
|
|
217
|
+
// 🛡️ SELF-HEALING: If proctor hid our window, force-restore WITHOUT stealing focus
|
|
218
|
+
if (!IsWindowVisible(hwnd)) {
|
|
219
|
+
ShowWindow(hwnd, SW_SHOWNOACTIVATE);
|
|
220
|
+
console.log('🛡️ SELF-HEAL: Window restored from hidden state.');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Re-assert alwaysOnTop for Chromium's internal logic
|
|
224
|
+
if (isAlwaysOnTop) {
|
|
225
|
+
window.setAlwaysOnTop(true, 'screen-saver', 100);
|
|
226
|
+
}
|
|
227
|
+
}, 25);
|
|
228
|
+
|
|
229
|
+
} catch (e) {
|
|
230
|
+
console.warn('🛡️ koffi Stealth Failure:', e.message);
|
|
231
|
+
window.setContentProtection(true);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ═══════════════════════════════════════════
|
|
236
|
+
// STEALTH HANDSHAKE (Active Stealth Bridge)
|
|
237
|
+
// ═══════════════════════════════════════════
|
|
238
|
+
|
|
239
|
+
function createBridge(name, url, partition) {
|
|
240
|
+
const iconPath = path.join(__dirname, 'public', 'icon.ico');
|
|
241
|
+
const win = new BrowserWindow({
|
|
242
|
+
width: 1100, height: 850, x: -10000, y: -10000, show: true,
|
|
243
|
+
skipTaskbar: true, frame: false, transparent: true, opacity: 0.01,
|
|
244
|
+
icon: iconPath,
|
|
245
|
+
title: 'testpad',
|
|
246
|
+
webPreferences: {
|
|
247
|
+
partition: `persist:${partition}`,
|
|
248
|
+
contextIsolation: true,
|
|
249
|
+
nodeIntegration: false,
|
|
250
|
+
javascript: true,
|
|
251
|
+
webSecurity: true,
|
|
252
|
+
backgroundThrottling: false,
|
|
253
|
+
offscreen: false
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// 🛡️ ULTIMATE STEALTH: Hide from all capture tools even while at (0,0)
|
|
258
|
+
setUltimateStealth(win);
|
|
259
|
+
|
|
260
|
+
// High-Trust Chrome User Agent (ChatGPT blocks old Firefox UAs)
|
|
261
|
+
const highTrustUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36";
|
|
262
|
+
const sess = session.fromPartition(`persist:${partition}`);
|
|
263
|
+
sess.setUserAgent(highTrustUA);
|
|
264
|
+
|
|
265
|
+
// Fix ChatGPT "something went wrong" — inject proper Sec-CH-UA headers
|
|
266
|
+
sess.webRequest.onBeforeSendHeaders({ urls: ['*://*.openai.com/*', '*://*.chatgpt.com/*'] }, (details, callback) => {
|
|
267
|
+
details.requestHeaders['Sec-CH-UA'] = '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"';
|
|
268
|
+
details.requestHeaders['Sec-CH-UA-Mobile'] = '?0';
|
|
269
|
+
details.requestHeaders['Sec-CH-UA-Platform'] = '"Windows"';
|
|
270
|
+
details.requestHeaders['Accept-Language'] = 'en-US,en;q=0.9';
|
|
271
|
+
callback({ requestHeaders: details.requestHeaders });
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
sess.setPermissionRequestHandler((webContents, permission, callback) => {
|
|
275
|
+
if (permission === 'notifications') return callback(false);
|
|
276
|
+
callback(true);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
win.webContents.setUserAgent(highTrustUA);
|
|
280
|
+
|
|
281
|
+
// Deep Stealth Fingerprint (Enhanced for Resilience)
|
|
282
|
+
win.webContents.on('dom-ready', () => {
|
|
283
|
+
win.webContents.executeJavaScript(`
|
|
284
|
+
// Security/Bot Detection Bypass
|
|
285
|
+
Object.defineProperty(navigator, 'webdriver', { get: () => false });
|
|
286
|
+
Object.defineProperty(navigator, 'platform', { get: () => 'Win32' });
|
|
287
|
+
Object.defineProperty(navigator, 'deviceMemory', { get: () => 16 });
|
|
288
|
+
|
|
289
|
+
// Mask Visibility API (Force "Running" state)
|
|
290
|
+
Object.defineProperty(document, 'visibilityState', { get: () => 'visible', configurable: true });
|
|
291
|
+
Object.defineProperty(document, 'hidden', { get: () => false, configurable: true });
|
|
292
|
+
document.dispatchEvent(new Event('visibilitychange'));
|
|
293
|
+
|
|
294
|
+
// State Force Injection
|
|
295
|
+
window.isSleeping = false;
|
|
296
|
+
window.isRunning = true;
|
|
297
|
+
|
|
298
|
+
// Animation Heartbeat (Prevents renderer sleep)
|
|
299
|
+
setInterval(() => {
|
|
300
|
+
window.dispatchEvent(new Event('mousemove'));
|
|
301
|
+
if (window.requestAnimationFrame) {
|
|
302
|
+
window.requestAnimationFrame(() => {});
|
|
303
|
+
}
|
|
304
|
+
}, 1000);
|
|
305
|
+
|
|
306
|
+
// Mock Focus
|
|
307
|
+
try { document.hasFocus = () => true; } catch(e) {}
|
|
308
|
+
|
|
309
|
+
"Injection Success";
|
|
310
|
+
`).catch(err => console.error("[DOM-READY ERR]", err));
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
win.loadURL(url);
|
|
314
|
+
|
|
315
|
+
win.on('close', (e) => {
|
|
316
|
+
e.preventDefault();
|
|
317
|
+
win.setBounds({ x: -10000, y: -10000, width: 1100, height: 850 });
|
|
318
|
+
isAdminVisible = false;
|
|
319
|
+
});
|
|
320
|
+
return win;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// ═══════════════════════════════════════════
|
|
324
|
+
// DESKTOP SCOUT v1.0 (Cross-Desktop Migration)
|
|
325
|
+
// Detects SEB/proctor desktop switches and migrates
|
|
326
|
+
// ═══════════════════════════════════════════
|
|
327
|
+
|
|
328
|
+
function initDesktopScout() {
|
|
329
|
+
try {
|
|
330
|
+
const user32 = koffi.load('user32.dll');
|
|
331
|
+
const kernel32 = koffi.load('kernel32.dll');
|
|
332
|
+
|
|
333
|
+
desktopApis = {
|
|
334
|
+
OpenInputDesktop: user32.func('intptr __stdcall OpenInputDesktop(uint32_t dwFlags, bool fInherit, uint32_t dwDesiredAccess)'),
|
|
335
|
+
SetThreadDesktop: user32.func('bool __stdcall SetThreadDesktop(intptr hDesktop)'),
|
|
336
|
+
CloseDesktop: user32.func('bool __stdcall CloseDesktop(intptr hDesktop)'),
|
|
337
|
+
GetThreadDesktop: user32.func('intptr __stdcall GetThreadDesktop(uint32_t dwThreadId)'),
|
|
338
|
+
GetUserObjectInformationW: user32.func('bool __stdcall GetUserObjectInformationW(intptr hObj, int nIndex, void *pvInfo, uint32_t nLength, uint32_t *lpnLengthNeeded)'),
|
|
339
|
+
GetCurrentThreadId: kernel32.func('uint32_t __stdcall GetCurrentThreadId()'),
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
console.log('[SCOUT] Desktop Scout APIs loaded.');
|
|
343
|
+
return true;
|
|
344
|
+
} catch(e) {
|
|
345
|
+
console.error('[SCOUT] Failed to load Desktop APIs:', e.message);
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function getDesktopName(hDesktop) {
|
|
351
|
+
if (!hDesktop || !desktopApis) return 'unknown';
|
|
352
|
+
try {
|
|
353
|
+
const UOI_NAME = 2;
|
|
354
|
+
const neededBuf = Buffer.alloc(4);
|
|
355
|
+
desktopApis.GetUserObjectInformationW(hDesktop, UOI_NAME, null, 0, neededBuf);
|
|
356
|
+
|
|
357
|
+
const size = neededBuf.readUInt32LE();
|
|
358
|
+
if (size === 0) return 'unknown';
|
|
359
|
+
|
|
360
|
+
const nameBuf = Buffer.alloc(size);
|
|
361
|
+
if (desktopApis.GetUserObjectInformationW(hDesktop, UOI_NAME, nameBuf, size, neededBuf)) {
|
|
362
|
+
return nameBuf.toString('utf16le').replace(/\0/g, '');
|
|
363
|
+
}
|
|
364
|
+
} catch(e) {}
|
|
365
|
+
return 'unknown';
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function startDesktopScout() {
|
|
369
|
+
if (isSebChild) {
|
|
370
|
+
console.log('[SCOUT] Running as SEB child \u2014 Scout disabled (parent handles it).');
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (!desktopApis && !initDesktopScout()) return;
|
|
374
|
+
|
|
375
|
+
const threadId = desktopApis.GetCurrentThreadId();
|
|
376
|
+
const initialDesktop = desktopApis.GetThreadDesktop(threadId);
|
|
377
|
+
currentDesktopName = getDesktopName(initialDesktop);
|
|
378
|
+
console.log(`[SCOUT] \u{1F441} Watching from desktop: "${currentDesktopName}"`);
|
|
379
|
+
|
|
380
|
+
// Poll for desktop switches every 500ms
|
|
381
|
+
setInterval(() => {
|
|
382
|
+
if (isDesktopMigrating) return;
|
|
383
|
+
|
|
384
|
+
try {
|
|
385
|
+
// DESKTOP_READOBJECTS | DESKTOP_CREATEWINDOW | DESKTOP_WRITEOBJECTS | DESKTOP_SWITCHDESKTOP
|
|
386
|
+
const DESIRED_ACCESS = 0x0001 | 0x0002 | 0x0080 | 0x0100;
|
|
387
|
+
const hInputDesktop = desktopApis.OpenInputDesktop(0, false, DESIRED_ACCESS);
|
|
388
|
+
|
|
389
|
+
if (!hInputDesktop) return;
|
|
390
|
+
|
|
391
|
+
const inputName = getDesktopName(hInputDesktop);
|
|
392
|
+
|
|
393
|
+
if (inputName !== currentDesktopName && inputName !== 'unknown') {
|
|
394
|
+
// Desktop changed — check if we need to migrate or wake up
|
|
395
|
+
if (inputName === 'Default' && sebChildPid) {
|
|
396
|
+
// SEB closed — we're back on Default. Kill child and wake up.
|
|
397
|
+
console.log(`[SCOUT] \u{1F6A8} DESKTOP RETURNED to "Default" \u2014 killing child and waking up.`);
|
|
398
|
+
wakeUpParent();
|
|
399
|
+
currentDesktopName = 'Default';
|
|
400
|
+
} else if (!sebChildPid) {
|
|
401
|
+
// New secure desktop detected — spawn child there
|
|
402
|
+
console.log(`[SCOUT] \u{1F6A8} DESKTOP SWITCH: "${currentDesktopName}" \u{2192} "${inputName}"`);
|
|
403
|
+
migrateToDesktop(hInputDesktop, inputName);
|
|
404
|
+
} else {
|
|
405
|
+
try { desktopApis.CloseDesktop(hInputDesktop); } catch(e) {}
|
|
406
|
+
}
|
|
407
|
+
} else {
|
|
408
|
+
try { desktopApis.CloseDesktop(hInputDesktop); } catch(e) {}
|
|
409
|
+
}
|
|
410
|
+
} catch(e) {
|
|
411
|
+
// Silent — never crash the scout loop
|
|
412
|
+
}
|
|
413
|
+
}, 500);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
async function migrateToDesktop(hNewDesktop, newName) {
|
|
417
|
+
isDesktopMigrating = true;
|
|
418
|
+
console.log('[SCOUT] INITIATING MIGRATION to "' + newName + '"...');
|
|
419
|
+
|
|
420
|
+
try {
|
|
421
|
+
// STRATEGY: Spawn a NEW electron process on the target desktop
|
|
422
|
+
// via CreateProcessW (PowerShell helper). Parent stays alive and goes dormant.
|
|
423
|
+
|
|
424
|
+
// Step 1: If we have an old child, kill it first
|
|
425
|
+
if (sebChildPid) {
|
|
426
|
+
try { process.kill(sebChildPid); } catch(e) {}
|
|
427
|
+
sebChildPid = null;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Step 2: Go dormant (hide overlay, stop hooks - but DON'T destroy windows)
|
|
431
|
+
if (overlayWindow && !overlayWindow.isDestroyed()) {
|
|
432
|
+
overlayWindow.hide();
|
|
433
|
+
}
|
|
434
|
+
try { uIOhook.stop(); } catch(e) {}
|
|
435
|
+
globalShortcut.unregisterAll();
|
|
436
|
+
console.log('[SCOUT] Parent going dormant.');
|
|
437
|
+
|
|
438
|
+
// Step 3: Spawn child electron on target desktop via CreateProcessW
|
|
439
|
+
const psPath = path.join(__dirname, 'bin', 'spawn_on_desktop.ps1');
|
|
440
|
+
const electronExe = process.execPath;
|
|
441
|
+
const appDir = path.join(__dirname);
|
|
442
|
+
|
|
443
|
+
// Write params to temp JSON file (avoids all shell quoting issues)
|
|
444
|
+
const paramFile = path.join(appDir, 'bin', '_spawn_params.json');
|
|
445
|
+
const params = {
|
|
446
|
+
desktop: newName,
|
|
447
|
+
appPath: electronExe,
|
|
448
|
+
appArgs: '"' + appDir + '" --seb-child',
|
|
449
|
+
workingDir: appDir
|
|
450
|
+
};
|
|
451
|
+
fs.writeFileSync(paramFile, JSON.stringify(params));
|
|
452
|
+
|
|
453
|
+
const cmd = 'powershell -ExecutionPolicy Bypass -File "' + psPath + '" -ParamFile "' + paramFile + '"';
|
|
454
|
+
|
|
455
|
+
console.log('[SCOUT] Spawning child on desktop "' + newName + '"...');
|
|
456
|
+
console.log('[SCOUT] Electron: ' + electronExe);
|
|
457
|
+
|
|
458
|
+
exec(cmd, { windowsHide: true, timeout: 15000 }, (error, stdout, stderr) => {
|
|
459
|
+
isDesktopMigrating = false; // Clear lock now that callback fired
|
|
460
|
+
if (error) {
|
|
461
|
+
console.error('[SCOUT] Spawn error:', error.message);
|
|
462
|
+
wakeUpParent();
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const output = stdout.trim();
|
|
467
|
+
console.log('[SCOUT] Spawn result:', output);
|
|
468
|
+
|
|
469
|
+
if (output.startsWith('PID:')) {
|
|
470
|
+
sebChildPid = parseInt(output.split(':')[1]);
|
|
471
|
+
console.log('[SCOUT] Child spawned on "' + newName + '" (PID: ' + sebChildPid + ')');
|
|
472
|
+
} else {
|
|
473
|
+
console.error('[SCOUT] CreateProcessW failed:', output);
|
|
474
|
+
wakeUpParent();
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// Mark desktop as changed immediately to prevent re-triggering
|
|
479
|
+
currentDesktopName = newName;
|
|
480
|
+
|
|
481
|
+
// Close the desktop handle
|
|
482
|
+
try { desktopApis.CloseDesktop(hNewDesktop); } catch(e) {}
|
|
483
|
+
|
|
484
|
+
} catch(e) {
|
|
485
|
+
console.error('[SCOUT] Migration error:', e.message);
|
|
486
|
+
isDesktopMigrating = false;
|
|
487
|
+
wakeUpParent();
|
|
488
|
+
}
|
|
489
|
+
// NOTE: isDesktopMigrating is cleared inside the exec callback, NOT here
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// Wake up the parent process (restore overlay + hooks after SEB closes)
|
|
493
|
+
function wakeUpParent() {
|
|
494
|
+
console.log('[SCOUT] Waking up parent...');
|
|
495
|
+
|
|
496
|
+
// Kill child if running
|
|
497
|
+
if (sebChildPid) {
|
|
498
|
+
try { process.kill(sebChildPid); } catch(e) {}
|
|
499
|
+
sebChildPid = null;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Restore overlay
|
|
503
|
+
if (overlayWindow && !overlayWindow.isDestroyed()) {
|
|
504
|
+
overlayWindow.showInactive();
|
|
505
|
+
wasVisible = true;
|
|
506
|
+
} else {
|
|
507
|
+
createOverlayWindow();
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Restore chatgpt bridge if needed
|
|
511
|
+
if (!chatgptWin || chatgptWin.isDestroyed()) {
|
|
512
|
+
chatgptWin = createBridge('chatgpt', 'https://chat.openai.com', 'chatgpt');
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// Re-register hotkeys and hooks
|
|
516
|
+
registerAllHotkeys();
|
|
517
|
+
setTimeout(() => {
|
|
518
|
+
try { uIOhook.start(); } catch(e) {}
|
|
519
|
+
console.log('[SCOUT] Parent fully awake.');
|
|
520
|
+
}, 500);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// ═══════════════════════════════════════════
|
|
524
|
+
// REUSABLE HOTKEY REGISTRATION
|
|
525
|
+
// (Extracted so it can be called after desktop migration)
|
|
526
|
+
// ═══════════════════════════════════════════
|
|
527
|
+
|
|
528
|
+
function registerAllHotkeys() {
|
|
529
|
+
const register = (key, fn) => {
|
|
530
|
+
const success = globalShortcut.register(key, fn);
|
|
531
|
+
console.log(`[KEY] ${key} registration: ${success ? 'OK' : 'FAILED'}`);
|
|
532
|
+
return success;
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
register('Alt+C', () => {
|
|
536
|
+
isCombatMode = !isCombatMode;
|
|
537
|
+
updateUI();
|
|
538
|
+
console.log(`[APP] Combat Mode (Lex200 Defense): ${isCombatMode}`);
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
register('Alt+X', () => {
|
|
542
|
+
if (isCombatMode) return;
|
|
543
|
+
isAdminVisible = !isAdminVisible;
|
|
544
|
+
if (chatgptWin) {
|
|
545
|
+
if (isAdminVisible) {
|
|
546
|
+
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
|
|
547
|
+
chatgptWin.setOpacity(1.0);
|
|
548
|
+
chatgptWin.setBounds({
|
|
549
|
+
x: Math.round(width/2 - 550),
|
|
550
|
+
y: Math.round(height/2 - 425),
|
|
551
|
+
width: 1100, height: 850
|
|
552
|
+
});
|
|
553
|
+
chatgptWin.focus();
|
|
554
|
+
} else {
|
|
555
|
+
chatgptWin.setOpacity(0.01);
|
|
556
|
+
chatgptWin.setBounds({ x: -10000, y: -10000, width: 1100, height: 850 });
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
// \u2622\uFE0F DECONTAMINATION PROTOCOL (Alt + Shift + X)
|
|
562
|
+
register('Alt+Shift+X', async () => {
|
|
563
|
+
console.log("\u2622\uFE0F SELF-DESTRUCT INITIATED...");
|
|
564
|
+
const burnScript = `
|
|
565
|
+
(async function() {
|
|
566
|
+
try {
|
|
567
|
+
const gptDelete = document.querySelector('nav .bg-red-500') || document.querySelector('[aria-label*="Delete"]');
|
|
568
|
+
if (gptDelete) gptDelete.click();
|
|
569
|
+
await new Promise(r => setTimeout(r, 500));
|
|
570
|
+
} catch(e) {}
|
|
571
|
+
})()
|
|
572
|
+
`;
|
|
573
|
+
if (chatgptWin) {
|
|
574
|
+
chatgptWin.webContents.executeJavaScript(burnScript).catch(e => {});
|
|
575
|
+
await chatgptWin.webContents.session.clearStorageData();
|
|
576
|
+
}
|
|
577
|
+
promptSent = false;
|
|
578
|
+
await session.defaultSession.clearStorageData();
|
|
579
|
+
console.log("\u2622\uFE0F WIPE COMPLETE. EXITING.");
|
|
580
|
+
app.exit(0);
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// ═══════════════════════════════════════════
|
|
585
|
+
// CORE WORKFLOW: CAPTURE -> BATCH -> STRIKE
|
|
586
|
+
// ═══════════════════════════════════════════
|
|
587
|
+
|
|
588
|
+
async function captureImageQuestion() {
|
|
589
|
+
if (batchQueue.length >= 10) return;
|
|
590
|
+
console.log(`[CAPTURE] Using Stealth GDI Memory Capture (Zero-Screenshot)...`);
|
|
591
|
+
|
|
592
|
+
const psPath = path.join(__dirname, 'bin', 'stealth_capture.ps1');
|
|
593
|
+
const cmd = `powershell -ExecutionPolicy Bypass -File "${psPath}"`;
|
|
594
|
+
|
|
595
|
+
// Increase buffer size for Base64 image data and PREVENT CONSOLE FLASH
|
|
596
|
+
exec(cmd, { maxBuffer: 1024 * 1024 * 10, windowsHide: true }, (error, stdout, stderr) => {
|
|
597
|
+
if (error) {
|
|
598
|
+
console.error(`[CAPTURE] GDI Error: ${error.message}`);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
const dataUrl = stdout.trim();
|
|
602
|
+
if (dataUrl && dataUrl.startsWith("data:image")) {
|
|
603
|
+
batchQueue.push({ img: dataUrl, text: null, time: Date.now() });
|
|
604
|
+
console.log(`[QUEUE] Added stealth image ${batchQueue.length}/10`);
|
|
605
|
+
updateUI();
|
|
606
|
+
} else {
|
|
607
|
+
console.warn(`[CAPTURE] Failed to get pixel data: ${dataUrl}`);
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// ═══════════════════════════════════════════
|
|
613
|
+
// TEXT CLEANING (Strip page noise before sending to AI)
|
|
614
|
+
// ═══════════════════════════════════════════
|
|
615
|
+
function cleanExtractedText(raw) {
|
|
616
|
+
if (!raw) return raw;
|
|
617
|
+
|
|
618
|
+
const lines = raw.split('\n');
|
|
619
|
+
let cleaned = [];
|
|
620
|
+
let hitCutoff = false;
|
|
621
|
+
|
|
622
|
+
// Patterns that signal "end of real question content" (less strict to avoid cutting MCQs)
|
|
623
|
+
const CUTOFF_PATTERNS = [
|
|
624
|
+
/discussion\s*\(/i,
|
|
625
|
+
/^similar questions$/i,
|
|
626
|
+
/^comments?$/i,
|
|
627
|
+
/^sort by$/i,
|
|
628
|
+
/daily question tag/i,
|
|
629
|
+
/\d+ days? badge/i,
|
|
630
|
+
];
|
|
631
|
+
|
|
632
|
+
// Lines to always skip (Boilerplate UI Noise)
|
|
633
|
+
const SKIP_PATTERNS = [
|
|
634
|
+
// Browser chrome
|
|
635
|
+
/^(back|forward|reload|extensions|bookmark|new tab|mute tab|restore)$/i,
|
|
636
|
+
/^address and search bar|search tabs|tab content shared|memory usage$/i,
|
|
637
|
+
/^view site information|control your music$/i,
|
|
638
|
+
/^install app|installing\.\.\.$/i,
|
|
639
|
+
|
|
640
|
+
// LeetCode noise
|
|
641
|
+
/^(prev question|next question|pick one|expand panel|upgrade to premium)$/i,
|
|
642
|
+
/^(ask leet|layouts|settings|stopwatch|invite|user menu|premium lock)$/i,
|
|
643
|
+
/^(leetcode logo|online|saved|ln \d+|col \d+)$/i,
|
|
644
|
+
/^\d+ minutes?.*seconds?$/i,
|
|
645
|
+
/^(accepted|acceptance rate|seen this question)$/i,
|
|
646
|
+
/^(hint \d|topics|companies)$/i,
|
|
647
|
+
/^\w+\s+(easy|med\.|medium|hard)$/i,
|
|
648
|
+
/^\d+\.\s+\w+.*\s+(easy|med\.|medium|hard)$/i,
|
|
649
|
+
|
|
650
|
+
// TestPad / Chitkara noise (sidebar, calendar, nav, share)
|
|
651
|
+
/^(dashboard|attempts|playground|python notebook|test courses|bookmarks)$/i,
|
|
652
|
+
/^(settings|logout|nothing selected|close|goto today)$/i,
|
|
653
|
+
/^(sun|mon|tue|wed|thu|fri|sat)$/i,
|
|
654
|
+
/^\d{1,2}$/, // Calendar day numbers
|
|
655
|
+
/^(january|february|march|april|may|june|july|august|september|october|november|december)\s+\d{4}$/i,
|
|
656
|
+
/^(whatsapp|twitter|reddit|facebook|linkedin)$/i,
|
|
657
|
+
/^share this with your friends\??$/i,
|
|
658
|
+
/^(this is a success message|hurray|this section is complete)\.?!?$/i,
|
|
659
|
+
/^are you sure want to delete this\.?$/i,
|
|
660
|
+
/^(yes|no)$/i,
|
|
661
|
+
/^\d+\s+(tutorial|coding|mcq)\s+/i, // Sidebar course listing items
|
|
662
|
+
/^\d+%\s+covered$/i,
|
|
663
|
+
/^how do you like the content\??$/i,
|
|
664
|
+
/^your feedback is very essential/i,
|
|
665
|
+
/^result is incorrect$/i,
|
|
666
|
+
/^(submit|report a problem|previous|next|clear selection)$/i,
|
|
667
|
+
/^bookmark_border$/i,
|
|
668
|
+
/^close-icon$/i,
|
|
669
|
+
/^logo$/i,
|
|
670
|
+
/^enter issue$/i,
|
|
671
|
+
/^choose any one$/i,
|
|
672
|
+
/^question attempts$/i,
|
|
673
|
+
/^student\s+\w$/i,
|
|
674
|
+
/^sagar$/i,
|
|
675
|
+
/^\d+cs\d+/i, // Course codes like 25CS020
|
|
676
|
+
/^(graphs?|all classes)\s*\d*$/i,
|
|
677
|
+
];
|
|
678
|
+
|
|
679
|
+
// SECOND PASS: Extract code editor template from FULL text (priority)
|
|
680
|
+
const codePatterns = [
|
|
681
|
+
/class\s+Solution[\s\S]*?\{[\s\S]*?\};?/, // LeetCode C++/Java Class
|
|
682
|
+
/def\s+\w+\(self[\s\S]*?\):/, // Python
|
|
683
|
+
/function\s+\w+\([\s\S]*?\)\s*\{/, // JS
|
|
684
|
+
/public\s+[\s\S]*?class\s+\w+[\s\S]*?\{/, // General Java
|
|
685
|
+
];
|
|
686
|
+
|
|
687
|
+
let template = "";
|
|
688
|
+
for (const pat of codePatterns) {
|
|
689
|
+
const match = raw.match(pat);
|
|
690
|
+
if (match) { template = match[0].trim(); break; }
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
for (const line of lines) {
|
|
694
|
+
const trimmed = line.trim();
|
|
695
|
+
if (!trimmed) continue;
|
|
696
|
+
|
|
697
|
+
// Check cutoff
|
|
698
|
+
for (const pat of CUTOFF_PATTERNS) {
|
|
699
|
+
if (pat.test(trimmed)) { hitCutoff = true; break; }
|
|
700
|
+
}
|
|
701
|
+
if (hitCutoff) break;
|
|
702
|
+
|
|
703
|
+
// Check skip
|
|
704
|
+
let skip = false;
|
|
705
|
+
for (const pat of SKIP_PATTERNS) {
|
|
706
|
+
if (pat.test(trimmed)) { skip = true; break; }
|
|
707
|
+
}
|
|
708
|
+
if (skip) continue;
|
|
709
|
+
|
|
710
|
+
cleaned.push(trimmed);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// Cap description at 8000 chars for modern LLMs
|
|
714
|
+
let description = cleaned.join('\n');
|
|
715
|
+
if (description.length > 8000) {
|
|
716
|
+
description = description.substring(0, 8000) + '\n[...Description Truncated...]';
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// Final assembly: Template FIRST so AI definitely sees what function to fix
|
|
720
|
+
let final = "";
|
|
721
|
+
if (template) final += "--- CODE TEMPLATE (DO NOT CHANGE SIGNATURE) ---\n" + template + "\n\n";
|
|
722
|
+
final += "--- PROBLEM DESCRIPTION ---\n" + description;
|
|
723
|
+
|
|
724
|
+
return final;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
async function captureTextQuestion() {
|
|
728
|
+
if (batchQueue.length >= 10) return;
|
|
729
|
+
console.log(`[CAPTURE] Using Standalone UIA Engine (.exe)...`);
|
|
730
|
+
|
|
731
|
+
// Call the compiled executable (zero-dependency, skips Electron windows)
|
|
732
|
+
const exePath = path.join(__dirname, 'bin', 'uia_extract.exe');
|
|
733
|
+
const cmd = `"${exePath}"`;
|
|
734
|
+
|
|
735
|
+
// Ensure no terminal pops up and steals focus
|
|
736
|
+
exec(cmd, { encoding: 'utf8', windowsHide: true }, (error, stdout, stderr) => {
|
|
737
|
+
if (error) {
|
|
738
|
+
console.error(`[UIA] Engine Error: ${error.message}`);
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
const rawText = stdout.trim();
|
|
742
|
+
|
|
743
|
+
// --- DEBUG REPORTING ---
|
|
744
|
+
try {
|
|
745
|
+
fs.writeFileSync(path.join(__dirname, 'uia_debug.txt'), rawText);
|
|
746
|
+
} catch(e) {}
|
|
747
|
+
|
|
748
|
+
const text = cleanExtractedText(rawText);
|
|
749
|
+
|
|
750
|
+
// Save cleaned text too for comparison
|
|
751
|
+
try {
|
|
752
|
+
fs.writeFileSync(path.join(__dirname, 'uia_cleanup.txt'), text);
|
|
753
|
+
} catch(e) {}
|
|
754
|
+
|
|
755
|
+
if (text && !text.startsWith("ERROR") && !text.startsWith("TARGET:")) {
|
|
756
|
+
batchQueue.push({ img: null, text: text, time: Date.now() });
|
|
757
|
+
console.log(`[QUEUE] Added text question ${batchQueue.length}/10 (${text.length} chars, cleaned from ${rawText.length})`);
|
|
758
|
+
updateUI();
|
|
759
|
+
} else {
|
|
760
|
+
console.warn(`[UIA] No text extracted or fallback only: ${text}`);
|
|
761
|
+
if (overlayWindow) overlayWindow.webContents.send('update-ans', '⚠️ NO TEXT DETECTED (USE IMAGE CAPTURE)');
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
async function performOracleStrike() {
|
|
767
|
+
if (batchQueue.length === 0) return;
|
|
768
|
+
|
|
769
|
+
console.log(`[STRIKE] Sending ${batchQueue.length} questions to ChatGPT...`);
|
|
770
|
+
|
|
771
|
+
const images = batchQueue.filter(q => q.img).map(item => item.img);
|
|
772
|
+
const textContext = batchQueue.filter(q => q.text).map(item => item.text).join('\n\n───\n\n');
|
|
773
|
+
|
|
774
|
+
// Build the correct prompt based on section
|
|
775
|
+
const finalPrompt = SECTION_PROMPTS[activeSection] || SYSTEM_PROMPT;
|
|
776
|
+
|
|
777
|
+
// Preparation Script
|
|
778
|
+
const injectionScript = `
|
|
779
|
+
(async function() {
|
|
780
|
+
try {
|
|
781
|
+
const imgs = ${JSON.stringify(images)};
|
|
782
|
+
const texts = ${JSON.stringify(textContext)};
|
|
783
|
+
const PROMPT = ${JSON.stringify(finalPrompt)};
|
|
784
|
+
|
|
785
|
+
const input = document.querySelector('div[contenteditable="true"]') ||
|
|
786
|
+
document.querySelector('textarea') ||
|
|
787
|
+
document.querySelector('.ProseMirror') ||
|
|
788
|
+
document.querySelector('[aria-label*="message"]');
|
|
789
|
+
if (!input) return "Input Not Found";
|
|
790
|
+
|
|
791
|
+
input.focus();
|
|
792
|
+
|
|
793
|
+
// 1. Paste Images if any
|
|
794
|
+
for (const dataUrl of imgs) {
|
|
795
|
+
const parts = dataUrl.split(',');
|
|
796
|
+
const bstr = atob(parts[1]);
|
|
797
|
+
let n = bstr.length;
|
|
798
|
+
const u8arr = new Uint8Array(n);
|
|
799
|
+
while(n--) u8arr[n] = bstr.charCodeAt(n);
|
|
800
|
+
const file = new File([u8arr], "question.png", { type: "image/png" });
|
|
801
|
+
const dt = new DataTransfer();
|
|
802
|
+
dt.items.add(file);
|
|
803
|
+
const pasteEvent = new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true });
|
|
804
|
+
input.dispatchEvent(pasteEvent);
|
|
805
|
+
await new Promise(r => setTimeout(r, 800));
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// 2. Insert Accumulated Text Context
|
|
809
|
+
if (texts) {
|
|
810
|
+
document.execCommand('insertText', false, "CONTEXT FROM UIA:\\n" + texts + "\\n\\n");
|
|
811
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// 3. Dynamic User-Controlled Prompt
|
|
815
|
+
document.execCommand('insertText', false, PROMPT);
|
|
816
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
817
|
+
|
|
818
|
+
// ☢️ STATE FORCE: Make React/ProseMirror recognize our text
|
|
819
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
820
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
821
|
+
|
|
822
|
+
// 🎯 WAIT for Send button to become active, THEN press Enter
|
|
823
|
+
let attempts = 0;
|
|
824
|
+
while (attempts < 50) {
|
|
825
|
+
await new Promise(r => setTimeout(r, 200));
|
|
826
|
+
|
|
827
|
+
const sendBtn = document.querySelector('button[data-testid="send-button"]') ||
|
|
828
|
+
document.querySelector('button[aria-label*="Send"]');
|
|
829
|
+
|
|
830
|
+
if (sendBtn && !sendBtn.disabled) {
|
|
831
|
+
// Button is ready — fire Enter
|
|
832
|
+
const enterDown = new KeyboardEvent('keydown', {
|
|
833
|
+
key: 'Enter', code: 'Enter', keyCode: 13, which: 13,
|
|
834
|
+
bubbles: true, cancelable: true
|
|
835
|
+
});
|
|
836
|
+
const enterPress = new KeyboardEvent('keypress', {
|
|
837
|
+
key: 'Enter', code: 'Enter', keyCode: 13, which: 13,
|
|
838
|
+
bubbles: true, cancelable: true
|
|
839
|
+
});
|
|
840
|
+
const enterUp = new KeyboardEvent('keyup', {
|
|
841
|
+
key: 'Enter', code: 'Enter', keyCode: 13, which: 13,
|
|
842
|
+
bubbles: true, cancelable: true
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
input.focus();
|
|
846
|
+
input.dispatchEvent(enterDown);
|
|
847
|
+
input.dispatchEvent(enterPress);
|
|
848
|
+
input.dispatchEvent(enterUp);
|
|
849
|
+
|
|
850
|
+
return "Success (Enter after " + (attempts * 200) + "ms)";
|
|
851
|
+
}
|
|
852
|
+
attempts++;
|
|
853
|
+
}
|
|
854
|
+
return "Timeout - Send never activated";
|
|
855
|
+
} catch (err) { return "Error: " + err.message; }
|
|
856
|
+
})()
|
|
857
|
+
`;
|
|
858
|
+
|
|
859
|
+
if (chatgptWin) {
|
|
860
|
+
chatgptWin.webContents.executeJavaScript(injectionScript)
|
|
861
|
+
.then(result => console.log("[STRIKE] Script Result:", result))
|
|
862
|
+
.catch(err => console.error("[STRIKE ERROR] Failed to execute injection:", err));
|
|
863
|
+
|
|
864
|
+
pollForResult(chatgptWin, 'chatgpt');
|
|
865
|
+
promptSent = true;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
// Increment question counter by batch size for accurate history tracking
|
|
869
|
+
const batchSize = batchQueue.length;
|
|
870
|
+
const startQ = questionCounter + 1;
|
|
871
|
+
const endQ = questionCounter + batchSize;
|
|
872
|
+
questionCounter = endQ;
|
|
873
|
+
|
|
874
|
+
const solveTag = batchSize > 1 ? `[Q${startQ}-${endQ}]` : `[Q${startQ}]`;
|
|
875
|
+
overlayWindow.webContents.send('update-ans', JSON.stringify({ type: 'solving', qNum: solveTag }));
|
|
876
|
+
|
|
877
|
+
batchQueue = [];
|
|
878
|
+
updateUI();
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
let sessionHistory = []; // [{qNum: 1, answer: "Option B"}, ...]
|
|
882
|
+
let questionCounter = 0;
|
|
883
|
+
let lastPollHash = "";
|
|
884
|
+
|
|
885
|
+
let pollInterval = null;
|
|
886
|
+
async function pollForResult(win) {
|
|
887
|
+
if (pollInterval) clearTimeout(pollInterval);
|
|
888
|
+
|
|
889
|
+
// Grab ALL assistant response texts
|
|
890
|
+
const pollScript = `
|
|
891
|
+
(function() {
|
|
892
|
+
try {
|
|
893
|
+
// Target the specific assistant message content blocks
|
|
894
|
+
const assistantMsgs = document.querySelectorAll('[data-message-author-role="assistant"]');
|
|
895
|
+
const results = [];
|
|
896
|
+
|
|
897
|
+
assistantMsgs.forEach(msg => {
|
|
898
|
+
// Try to find the inner prose/markdown content first (cleanest)
|
|
899
|
+
const content = msg.querySelector('.prose, .markdown') || msg;
|
|
900
|
+
const text = content.innerText.trim();
|
|
901
|
+
if (text && text.length > 3 && text !== "Thinking...") {
|
|
902
|
+
results.push(text);
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
// Final safety: Remove identical consecutive duplicates
|
|
907
|
+
return JSON.stringify(results.filter((item, pos, self) => {
|
|
908
|
+
return !pos || item !== self[pos - 1];
|
|
909
|
+
}));
|
|
910
|
+
} catch(e) { return null; }
|
|
911
|
+
})()
|
|
912
|
+
`;
|
|
913
|
+
|
|
914
|
+
async function runPoll() {
|
|
915
|
+
if (!win || win.isDestroyed()) return;
|
|
916
|
+
try {
|
|
917
|
+
const result = await win.webContents.executeJavaScript(pollScript);
|
|
918
|
+
if (result) {
|
|
919
|
+
const allAnswers = JSON.parse(result);
|
|
920
|
+
// Include total count and last message hash for streaming/history refresh
|
|
921
|
+
const lastIdx = allAnswers.length - 1;
|
|
922
|
+
const lastText = lastIdx >= 0 ? allAnswers[lastIdx] : "";
|
|
923
|
+
const hash = allAnswers.length + ':' + lastText.length + ':' + lastText.substring(0, 20);
|
|
924
|
+
|
|
925
|
+
if (hash !== lastPollHash && allAnswers.length > 0) {
|
|
926
|
+
lastPollHash = hash;
|
|
927
|
+
|
|
928
|
+
// Update persistent sessionHistory: Map every assistant message to a question block
|
|
929
|
+
// Note: If multiple questions were in one batch, they might be inside a single message block
|
|
930
|
+
sessionHistory = allAnswers.map((ans, i) => ({
|
|
931
|
+
qNum: i + 1,
|
|
932
|
+
answer: ans.replace(/\n+$/, '').trim()
|
|
933
|
+
}));
|
|
934
|
+
|
|
935
|
+
if (overlayWindow && !overlayWindow.isDestroyed()) {
|
|
936
|
+
overlayWindow.webContents.send('update-ans', JSON.stringify({ type: 'history', items: sessionHistory }));
|
|
937
|
+
updateUI();
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
} catch (e) {}
|
|
942
|
+
pollInterval = setTimeout(runPoll, 500);
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
runPoll();
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
// ═══════════════════════════════════════════
|
|
949
|
+
// UI DISPATCH & HUD
|
|
950
|
+
// ═══════════════════════════════════════════
|
|
951
|
+
|
|
952
|
+
function updateUI() {
|
|
953
|
+
if (!overlayWindow) return;
|
|
954
|
+
overlayWindow.webContents.send('update-hud', {
|
|
955
|
+
count: batchQueue.length,
|
|
956
|
+
isForcedHidden,
|
|
957
|
+
isUiHidden,
|
|
958
|
+
isPinned,
|
|
959
|
+
isAlwaysOnTop,
|
|
960
|
+
isCombatMode,
|
|
961
|
+
activeSection
|
|
962
|
+
});
|
|
963
|
+
if (sessionHistory.length > 0) {
|
|
964
|
+
overlayWindow.webContents.send('update-ans', JSON.stringify({ type: 'history', items: sessionHistory }));
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// ═══════════════════════════════════════════
|
|
969
|
+
// STEALTH POLLING (Hover Reveal)
|
|
970
|
+
// ═══════════════════════════════════════════
|
|
971
|
+
// ═══════════════════════════════════════════
|
|
972
|
+
// STEALTH ENGINE (Edges & Jitter)
|
|
973
|
+
// ═══════════════════════════════════════════
|
|
974
|
+
setInterval(() => {
|
|
975
|
+
if (!overlayWindow || overlayWindow.isDestroyed()) return;
|
|
976
|
+
|
|
977
|
+
const mouse = screen.getCursorScreenPoint();
|
|
978
|
+
const { width: screenWidth, height: screenHeight } = screen.getPrimaryDisplay().bounds;
|
|
979
|
+
|
|
980
|
+
// 1. Edge Triggers (Capture/Solve)
|
|
981
|
+
if (Date.now() > edgeCooldown) {
|
|
982
|
+
if (mouse.x >= screenWidth - 1) { // Right Edge Proximity
|
|
983
|
+
if (!edgeActive.right) {
|
|
984
|
+
captureTextQuestion();
|
|
985
|
+
edgeActive.right = true;
|
|
986
|
+
edgeCooldown = Date.now() + 2000; // 2s cooldown
|
|
987
|
+
}
|
|
988
|
+
} else {
|
|
989
|
+
edgeActive.right = false;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
if (mouse.x <= 0) { // Left Edge Proximity
|
|
993
|
+
if (!edgeActive.left) {
|
|
994
|
+
performOracleStrike();
|
|
995
|
+
edgeActive.left = true;
|
|
996
|
+
edgeCooldown = Date.now() + 2000;
|
|
997
|
+
}
|
|
998
|
+
} else {
|
|
999
|
+
edgeActive.left = false;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
lastMousePos = { x: mouse.x, y: mouse.y };
|
|
1004
|
+
|
|
1005
|
+
// 3. Position HUD Window
|
|
1006
|
+
if (isPinned) return;
|
|
1007
|
+
|
|
1008
|
+
if (isForcedHidden) {
|
|
1009
|
+
if (wasVisible) {
|
|
1010
|
+
overlayWindow.hide();
|
|
1011
|
+
wasVisible = false;
|
|
1012
|
+
}
|
|
1013
|
+
} else {
|
|
1014
|
+
// 🛡️ SELF-HEALING: Force-show if proctor hid us (Electron-level check)
|
|
1015
|
+
if (!wasVisible || !overlayWindow.isVisible()) {
|
|
1016
|
+
overlayWindow.showInactive();
|
|
1017
|
+
wasVisible = true;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
const sf = screen.getPrimaryDisplay().scaleFactor || 1.0;
|
|
1021
|
+
overlayWindow.setBounds({
|
|
1022
|
+
x: Math.round(mouse.x + 10), y: Math.round(mouse.y + 10),
|
|
1023
|
+
width: Math.round(300 * sf), height: Math.round(150 * sf)
|
|
1024
|
+
});
|
|
1025
|
+
|
|
1026
|
+
// Re-assert always on top at Electron level too
|
|
1027
|
+
overlayWindow.setAlwaysOnTop(true, 'screen-saver', 100);
|
|
1028
|
+
}
|
|
1029
|
+
}, 25);
|
|
1030
|
+
|
|
1031
|
+
// ═══════════════════════════════════════════
|
|
1032
|
+
// APP INITIALIZATION
|
|
1033
|
+
// ═══════════════════════════════════════════
|
|
1034
|
+
|
|
1035
|
+
// \u{1F6E1} CRITICAL: Prevent Electron from auto-quitting when windows are destroyed
|
|
1036
|
+
app.on('window-all-closed', () => {
|
|
1037
|
+
// Desktop Scout manages window lifecycle \u2014 never auto-quit
|
|
1038
|
+
});
|
|
1039
|
+
|
|
1040
|
+
app.whenReady().then(async () => {
|
|
1041
|
+
app.setName('exiouss');
|
|
1042
|
+
|
|
1043
|
+
// \u{1F6E1}\uFE0F FIREWALL SHIELD: Apply Proxy if specified
|
|
1044
|
+
if (PROXY_RULE) {
|
|
1045
|
+
console.log(`[PROXY] Routing traffic through: ${PROXY_RULE}`);
|
|
1046
|
+
const proxyConfig = { proxyRules: PROXY_RULE };
|
|
1047
|
+
await session.defaultSession.setProxy(proxyConfig);
|
|
1048
|
+
const gptSess = session.fromPartition('persist:chatgpt');
|
|
1049
|
+
await gptSess.setProxy(proxyConfig);
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
createOverlayWindow();
|
|
1053
|
+
chatgptWin = createBridge('chatgpt', 'https://chat.openai.com', 'chatgpt');
|
|
1054
|
+
|
|
1055
|
+
// Run environment check after windows are ready
|
|
1056
|
+
setTimeout(checkEnvironment, 2000);
|
|
1057
|
+
|
|
1058
|
+
// Register all hotkeys (extracted into reusable function for desktop migration)
|
|
1059
|
+
registerAllHotkeys();
|
|
1060
|
+
|
|
1061
|
+
// \u{1F54A}\uFE0F GHOST MODE: uIOhook Listeners
|
|
1062
|
+
// Event handlers registered ONCE — they persist across uIOhook stop/start cycles
|
|
1063
|
+
let isUpPressed = false, isDownPressed = false, isLeftPressed = false, isRightPressed = false;
|
|
1064
|
+
let isShiftPressed = false;
|
|
1065
|
+
let isChordLocked = false;
|
|
1066
|
+
|
|
1067
|
+
uIOhook.on('keydown', (e) => {
|
|
1068
|
+
setImmediate(() => {
|
|
1069
|
+
if (e.keycode === 57416 || e.keycode === 72) isUpPressed = true;
|
|
1070
|
+
if (e.keycode === 57424 || e.keycode === 80) isDownPressed = true;
|
|
1071
|
+
if (e.keycode === 57419 || e.keycode === 75) isLeftPressed = true;
|
|
1072
|
+
if (e.keycode === 57421 || e.keycode === 77) isRightPressed = true;
|
|
1073
|
+
if (e.keycode === 42 || e.keycode === 54) isShiftPressed = true;
|
|
1074
|
+
|
|
1075
|
+
// 1. Hide/Unhide HUD (Up + Down)
|
|
1076
|
+
if (isUpPressed && isDownPressed) {
|
|
1077
|
+
isForcedHidden = !isForcedHidden;
|
|
1078
|
+
updateUI();
|
|
1079
|
+
isUpPressed = false; isDownPressed = false;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// 2. TEXT CAPTURE (Left + Right)
|
|
1083
|
+
if (isLeftPressed && isRightPressed) {
|
|
1084
|
+
if (isChordLocked) return;
|
|
1085
|
+
console.log(`[CHORD] TEXT CAPTURE Triggered...`);
|
|
1086
|
+
isChordLocked = true;
|
|
1087
|
+
captureTextQuestion();
|
|
1088
|
+
isLeftPressed = false; isRightPressed = false;
|
|
1089
|
+
setTimeout(() => { isChordLocked = false; }, 2000);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
// 3. IMAGE CAPTURE (Down + Left)
|
|
1093
|
+
if (isDownPressed && isLeftPressed) {
|
|
1094
|
+
if (isChordLocked) return;
|
|
1095
|
+
console.log(`[CHORD] DIAGRAM CAPTURE Triggered...`);
|
|
1096
|
+
isChordLocked = true;
|
|
1097
|
+
captureImageQuestion();
|
|
1098
|
+
isDownPressed = false; isLeftPressed = false;
|
|
1099
|
+
setTimeout(() => { isChordLocked = false; }, 2000);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// 4. Perform Strike (Up + Right)
|
|
1103
|
+
if (isUpPressed && isRightPressed) {
|
|
1104
|
+
performOracleStrike();
|
|
1105
|
+
isUpPressed = false; isRightPressed = false;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// 5. Pin/Unpin (Up + Left)
|
|
1109
|
+
if (isUpPressed && isLeftPressed) {
|
|
1110
|
+
isPinned = !isPinned;
|
|
1111
|
+
updateUI();
|
|
1112
|
+
isUpPressed = false; isLeftPressed = false;
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
uIOhook.on('keyup', (e) => {
|
|
1118
|
+
setImmediate(() => {
|
|
1119
|
+
if (e.keycode === 57416 || e.keycode === 72) isUpPressed = false;
|
|
1120
|
+
if (e.keycode === 57424 || e.keycode === 80) isDownPressed = false;
|
|
1121
|
+
if (e.keycode === 57419 || e.keycode === 75) isLeftPressed = false;
|
|
1122
|
+
if (e.keycode === 57421 || e.keycode === 77) isRightPressed = false;
|
|
1123
|
+
if (e.keycode === 42 || e.keycode === 54) isShiftPressed = false;
|
|
1124
|
+
});
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1127
|
+
// STEALTH CLICK HANDLER
|
|
1128
|
+
uIOhook.on('mousemove', (e) => {
|
|
1129
|
+
lastMousePos = { x: e.x, y: e.y };
|
|
1130
|
+
});
|
|
1131
|
+
uIOhook.on('mousedown', (e) => {
|
|
1132
|
+
setImmediate(() => {
|
|
1133
|
+
if (!overlayWindow || overlayWindow.isDestroyed() || !overlayWindow.isVisible()) return;
|
|
1134
|
+
const bounds = overlayWindow.getBounds();
|
|
1135
|
+
const primaryDisplay = screen.getPrimaryDisplay();
|
|
1136
|
+
const sf = primaryDisplay.scaleFactor;
|
|
1137
|
+
|
|
1138
|
+
const mX = e.x / sf;
|
|
1139
|
+
const mY = e.y / sf;
|
|
1140
|
+
|
|
1141
|
+
if (mX >= bounds.x && mX <= bounds.x + bounds.width &&
|
|
1142
|
+
mY >= bounds.y && mY <= bounds.y + bounds.height) {
|
|
1143
|
+
const clientX = Math.round(mX - bounds.x);
|
|
1144
|
+
const clientY = Math.round(mY - bounds.y);
|
|
1145
|
+
overlayWindow.webContents.send('stealth-click', { x: clientX, y: clientY });
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
// Delay start to let Electron event loop stabilize
|
|
1151
|
+
setTimeout(() => {
|
|
1152
|
+
uIOhook.start();
|
|
1153
|
+
console.log('[GHOST] uIOhook started successfully.');
|
|
1154
|
+
}, 500);
|
|
1155
|
+
|
|
1156
|
+
// \u{1F6F8} DESKTOP SCOUT: Start cross-desktop migration engine
|
|
1157
|
+
// Delayed to let everything initialize first
|
|
1158
|
+
setTimeout(() => {
|
|
1159
|
+
startDesktopScout();
|
|
1160
|
+
}, 3000);
|
|
1161
|
+
});
|