@jshookmcp/jshook 0.1.5 → 0.1.6
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/LICENSE +661 -661
- package/README.md +72 -40
- package/README.zh.md +77 -40
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +13 -1
- package/dist/modules/analyzer/IntelligentAnalyzer.js +19 -11
- package/dist/modules/browser/BrowserModeManager.d.ts +5 -0
- package/dist/modules/browser/BrowserModeManager.js +96 -10
- package/dist/modules/browser/CamoufoxBrowserManager.d.ts +4 -0
- package/dist/modules/browser/CamoufoxBrowserManager.js +64 -3
- package/dist/modules/browser/TabRegistry.js +3 -2
- package/dist/modules/browser/UnifiedBrowserManager.d.ts +5 -0
- package/dist/modules/browser/UnifiedBrowserManager.js +62 -9
- package/dist/modules/captcha/AICaptchaDetector.js +185 -185
- package/dist/modules/debugger/DebuggerSessionManager.d.ts +4 -0
- package/dist/modules/debugger/DebuggerSessionManager.js +29 -19
- package/dist/modules/debugger/ScriptManager.impl.class.d.ts +4 -0
- package/dist/modules/debugger/ScriptManager.impl.class.js +46 -21
- package/dist/modules/emulator/EnvironmentEmulator.js +2 -2
- package/dist/modules/monitor/NetworkMonitor.impl.d.ts +1 -0
- package/dist/modules/monitor/NetworkMonitor.impl.js +22 -15
- package/dist/modules/monitor/PerformanceMonitor.js +64 -32
- package/dist/modules/process/LinuxProcessManager.d.ts +3 -1
- package/dist/modules/process/LinuxProcessManager.js +7 -3
- package/dist/modules/process/MacProcessManager.d.ts +3 -1
- package/dist/modules/process/MacProcessManager.js +32 -28
- package/dist/modules/process/ProcessManager.impl.d.ts +5 -1
- package/dist/modules/process/ProcessManager.impl.js +54 -13
- package/dist/modules/process/index.d.ts +3 -1
- package/dist/modules/process/index.js +2 -2
- package/dist/modules/process/memory/AuditTrail.d.ts +25 -0
- package/dist/modules/process/memory/AuditTrail.js +44 -0
- package/dist/modules/process/memory/availability.js +49 -49
- package/dist/modules/process/memory/injector.js +185 -185
- package/dist/modules/process/memory/linux/mapsParser.d.ts +16 -0
- package/dist/modules/process/memory/linux/mapsParser.js +28 -0
- package/dist/modules/process/memory/reader.js +50 -50
- package/dist/modules/process/memory/regions.enumerate.js +45 -1
- package/dist/modules/process/memory/regions.protection.js +48 -2
- package/dist/modules/process/memory/scanner.d.ts +4 -1
- package/dist/modules/process/memory/scanner.js +383 -182
- package/dist/modules/process/memory/writer.js +54 -54
- package/dist/native/NativeMemoryManager.impl.d.ts +4 -0
- package/dist/native/NativeMemoryManager.impl.js +72 -24
- package/dist/native/NativeMemoryManager.utils.d.ts +1 -0
- package/dist/native/NativeMemoryManager.utils.js +44 -1
- package/dist/native/scripts/linux/enum-windows.sh +12 -12
- package/dist/native/scripts/macos/enum-windows.applescript +22 -22
- package/dist/native/scripts/windows/enum-windows-by-class.ps1 +51 -51
- package/dist/native/scripts/windows/enum-windows.ps1 +44 -44
- package/dist/native/scripts/windows/inject-dll.ps1 +21 -21
- package/dist/server/MCPServer.search.d.ts +3 -0
- package/dist/server/MCPServer.search.js +21 -2
- package/dist/server/ToolCallContextGuard.d.ts +2 -0
- package/dist/server/ToolCallContextGuard.js +29 -14
- package/dist/server/ToolSearch.js +11 -5
- package/dist/server/domains/browser/definitions.tools.page-core.js +53 -53
- package/dist/server/domains/browser/definitions.tools.runtime.js +40 -40
- package/dist/server/domains/browser/definitions.tools.security.js +76 -76
- package/dist/server/domains/browser/handlers/tab-workflow.js +6 -4
- package/dist/server/domains/maintenance/handlers.extensions.js +46 -26
- package/dist/server/domains/process/definitions.js +20 -7
- package/dist/server/domains/process/handlers.impl.core.runtime.base.d.ts +35 -0
- package/dist/server/domains/process/handlers.impl.core.runtime.base.js +107 -1
- package/dist/server/domains/process/handlers.impl.core.runtime.inject.js +111 -2
- package/dist/server/domains/process/handlers.impl.core.runtime.memory.d.ts +9 -0
- package/dist/server/domains/process/handlers.impl.core.runtime.memory.js +282 -31
- package/dist/server/domains/process/manifest.js +1 -0
- package/dist/server/domains/transform/handlers.impl.transform-base.js +102 -102
- package/dist/server/domains/workflow/handlers.impl.workflow-api.js +14 -4
- package/dist/server/domains/workflow/handlers.impl.workflow-base.js +51 -51
- package/dist/server/registry/discovery.js +17 -12
- package/dist/server/registry/index.js +10 -2
- package/dist/utils/TokenBudgetManager.d.ts +1 -0
- package/dist/utils/TokenBudgetManager.js +22 -0
- package/package.json +5 -1
- package/src/native/scripts/linux/enum-windows.sh +12 -12
- package/src/native/scripts/macos/enum-windows.applescript +22 -22
- package/src/native/scripts/windows/enum-windows-by-class.ps1 +51 -51
- package/src/native/scripts/windows/enum-windows.ps1 +44 -44
- package/src/native/scripts/windows/inject-dll.ps1 +21 -21
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
1
2
|
import { logger } from '../../../utils/logger.js';
|
|
2
3
|
import { execAsync, executePowerShellScript } from '../../process/memory/types.js';
|
|
4
|
+
import { parseProcMaps, formatLinuxProtection } from './linux/mapsParser.js';
|
|
5
|
+
import { nativeMemoryManager } from '../../../native/NativeMemoryManager.js';
|
|
6
|
+
import { isKoffiAvailable } from '../../../native/NativeMemoryManager.utils.js';
|
|
3
7
|
function buildProtectionCheckScript(pid, address) {
|
|
4
8
|
return `
|
|
5
9
|
Add-Type @"
|
|
@@ -110,8 +114,28 @@ try {
|
|
|
110
114
|
`.trim();
|
|
111
115
|
}
|
|
112
116
|
export async function checkMemoryProtection(platform, pid, address) {
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
const addrNum = BigInt(address.startsWith('0x') ? address : `0x${address}`);
|
|
118
|
+
if (platform === 'linux') {
|
|
119
|
+
try {
|
|
120
|
+
const mapsContent = readFileSync(`/proc/${pid}/maps`, 'utf-8');
|
|
121
|
+
const regions = parseProcMaps(mapsContent);
|
|
122
|
+
const region = regions.find(r => addrNum >= r.start && addrNum < r.end);
|
|
123
|
+
if (!region) {
|
|
124
|
+
return { success: false, error: `Address ${address} not found in any memory region` };
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
success: true,
|
|
128
|
+
protection: formatLinuxProtection(region.permissions),
|
|
129
|
+
isReadable: region.permissions.read,
|
|
130
|
+
isWritable: region.permissions.write,
|
|
131
|
+
isExecutable: region.permissions.exec,
|
|
132
|
+
regionStart: `0x${region.start.toString(16)}`,
|
|
133
|
+
regionSize: Number(region.end - region.start),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
138
|
+
}
|
|
115
139
|
}
|
|
116
140
|
if (platform === 'darwin') {
|
|
117
141
|
try {
|
|
@@ -145,6 +169,28 @@ export async function checkMemoryProtection(platform, pid, address) {
|
|
|
145
169
|
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
146
170
|
}
|
|
147
171
|
}
|
|
172
|
+
if (isKoffiAvailable()) {
|
|
173
|
+
try {
|
|
174
|
+
const nativeResult = await nativeMemoryManager.checkMemoryProtection(pid, address);
|
|
175
|
+
if (nativeResult.success) {
|
|
176
|
+
return nativeResult;
|
|
177
|
+
}
|
|
178
|
+
logger.warn('Native Windows memory protection check failed, falling back to PowerShell', {
|
|
179
|
+
pid,
|
|
180
|
+
address,
|
|
181
|
+
error: nativeResult.error,
|
|
182
|
+
nativeAvailable: isKoffiAvailable(),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
logger.warn('Native Windows memory protection check threw, falling back to PowerShell', {
|
|
187
|
+
pid,
|
|
188
|
+
address,
|
|
189
|
+
error: error instanceof Error ? error.message : String(error),
|
|
190
|
+
nativeAvailable: isKoffiAvailable(),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
148
194
|
try {
|
|
149
195
|
const addrNum = parseInt(address, 16);
|
|
150
196
|
if (isNaN(addrNum)) {
|
|
@@ -3,7 +3,10 @@ export declare function buildPatternBytesAndMask(pattern: string, patternType: s
|
|
|
3
3
|
patternBytes: number[];
|
|
4
4
|
mask: number[];
|
|
5
5
|
};
|
|
6
|
-
export declare function patternToBytesMac(pattern: string, patternType: string):
|
|
6
|
+
export declare function patternToBytesMac(pattern: string, patternType: string): {
|
|
7
|
+
bytes: number[];
|
|
8
|
+
mask: number[];
|
|
9
|
+
};
|
|
7
10
|
export declare function scanMemory(platform: Platform, pid: number, pattern: string, patternType?: PatternType): Promise<MemoryScanResult>;
|
|
8
11
|
export declare function scanMemoryFiltered(pid: number, pattern: string, addresses: string[], patternType: PatternType | undefined, _readMemoryFn: (pid: number, address: string, size: number) => Promise<{
|
|
9
12
|
success: boolean;
|