@jshookmcp/jshook 0.1.6 → 0.1.7

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.
Files changed (25) hide show
  1. package/LICENSE +661 -661
  2. package/dist/index.js +0 -0
  3. package/dist/modules/captcha/AICaptchaDetector.js +185 -185
  4. package/dist/modules/process/MacProcessManager.js +25 -25
  5. package/dist/modules/process/memory/availability.js +49 -49
  6. package/dist/modules/process/memory/injector.js +185 -185
  7. package/dist/modules/process/memory/reader.js +50 -50
  8. package/dist/modules/process/memory/scanner.js +165 -165
  9. package/dist/modules/process/memory/writer.js +54 -54
  10. package/dist/native/scripts/linux/enum-windows.sh +12 -12
  11. package/dist/native/scripts/macos/enum-windows.applescript +22 -22
  12. package/dist/native/scripts/windows/enum-windows-by-class.ps1 +51 -51
  13. package/dist/native/scripts/windows/enum-windows.ps1 +44 -44
  14. package/dist/native/scripts/windows/inject-dll.ps1 +21 -21
  15. package/dist/server/domains/browser/definitions.tools.page-core.js +53 -53
  16. package/dist/server/domains/browser/definitions.tools.runtime.js +40 -40
  17. package/dist/server/domains/browser/definitions.tools.security.js +76 -76
  18. package/dist/server/domains/transform/handlers.impl.transform-base.js +102 -102
  19. package/dist/server/domains/workflow/handlers.impl.workflow-base.js +51 -51
  20. package/package.json +26 -43
  21. package/src/native/scripts/linux/enum-windows.sh +12 -12
  22. package/src/native/scripts/macos/enum-windows.applescript +22 -22
  23. package/src/native/scripts/windows/enum-windows-by-class.ps1 +51 -51
  24. package/src/native/scripts/windows/enum-windows.ps1 +44 -44
  25. package/src/native/scripts/windows/inject-dll.ps1 +21 -21
package/dist/index.js CHANGED
File without changes
@@ -135,194 +135,194 @@ export class AICaptchaDetector {
135
135
  bodyTextPreview: `${pageInfo.bodyText.substring(0, 200)}...`,
136
136
  };
137
137
  return `#
138
-
139
- ##
140
- ,(CAPTCHA),。
141
-
142
- ##
138
+
139
+ ##
140
+ ,(CAPTCHA),。
141
+
142
+ ##
143
143
  \`\`\`json
144
144
  ${JSON.stringify(promptPayload, null, 2)}
145
145
  \`\`\`
146
-
147
- ##
148
-
149
- ### 1. (Interactive CAPTCHA)
150
- **1.1 (Slider CAPTCHA)**
151
- - ****: 、
152
- - ****: (Geetest)、、、
153
- - ****: 、、""
154
- - **DOM**: \`.geetest_slider\`, \`.nc_1_wrapper\`, \`.tcaptcha-transform\`
155
-
156
- **1.2 (Image CAPTCHA)**
157
- - ****: ("")
158
- - ****: reCAPTCHA v2、hCaptcha
159
- - ****: 3x34x4、
160
- - **DOM**: \`iframe[src*="recaptcha"]\`, \`.h-captcha\`
161
-
162
- **1.3 (Text CAPTCHA)**
163
- - ****: /
164
- - ****: 、
165
- - ****: ""
166
-
167
- ### 2. (Automatic CAPTCHA)
168
- **2.1 reCAPTCHA v3**
169
- - ****: ,reCAPTCHA
170
- - ****: "Protected by reCAPTCHA"
171
-
172
- **2.2 Cloudflare Turnstile**
173
- - ****: "" / "Checking your browser"
174
- - ****: Cloudflare logo、、Ray ID
175
-
176
- ### 3. (False Positives - )
177
- **3.1 **
178
- - 、、
179
- - ""()
180
- - ""()
181
-
182
- **3.2 **
183
- - 、
184
- - 、
185
- -
186
-
187
- **3.3 UI**
188
- - Range slider、Progress bar
189
- - Carousel、Swiper
190
- - 、
191
-
192
- ##
193
-
194
- ### Step 1:
195
- 1. :
196
- - +
197
- - +
198
- - ""
199
- - ""
200
- - Cloudflare/reCAPTCHA logo
201
-
202
- ### Step 2:
203
- 1. URL:
204
- - \`/captcha\`, \`/challenge\`, \`/verify\`
205
- - \`cdn-cgi/challenge\` (Cloudflare)
206
- - \`recaptcha.net\`, \`hcaptcha.com\`
207
-
208
- 2. :
209
- - ""、""、""
210
- - "Verify", "Challenge", "Security Check"
211
-
212
- 3. :
213
- - suspiciousElements →
214
- - →
215
-
216
- ### Step 3:
217
- 1. :
218
- - ""、""
219
- - ,
220
- - → \`detected: false\`
221
-
222
- 2. /UI:
223
- - 、、
224
- - → \`detected: false\`
225
-
226
- ### Step 4:
227
- - **90-100%**: + DOM
228
- - **70-89%**: ,DOM
229
- - **50-69%**: ,
230
- - **0-49%**:
231
-
232
- ##
233
-
234
- **JSON Schema**:
235
-
236
- \`\`\`json
237
- {
238
- "detected": boolean,
239
- "type": "slider" | "image" | "recaptcha" | "hcaptcha" | "cloudflare" | "text_input" | "none",
240
- "confidence": number,
241
- "reasoning": string,
242
- "location": {
243
- "x": number,
244
- "y": number,
245
- "width": number,
246
- "height": number
247
- } | null,
248
- "vendor": "geetest" | "tencent" | "aliyun" | "recaptcha" | "hcaptcha" | "cloudflare" | "unknown",
249
- "suggestions": string[]
250
- }
251
- \`\`\`
252
-
253
- ###
254
- - **detected**: ()
255
- - **type**: ()
256
- - **confidence**: (0-100)
257
- - **reasoning**: (200,)
258
- - **location**: (,null)
259
- - **vendor**: ("unknown")
260
- - **suggestions**: (,2-3)
261
-
262
- ###
263
-
264
- **1: **
265
- \`\`\`json
266
- {
267
- "detected": true,
268
- "type": "slider",
269
- "confidence": 95,
270
- "reasoning": ":1) ;2) '';3) DOM.geetest_slider。。",
271
- "location": {
272
- "x": 450,
273
- "y": 300,
274
- "width": 320,
275
- "height": 180
276
- },
277
- "vendor": "geetest",
278
- "suggestions": [
279
- "",
280
- "captcha_wait",
281
- ","
282
- ]
283
- }
284
- \`\`\`
285
-
286
- **2: - **
287
- \`\`\`json
288
- {
289
- "detected": false,
290
- "type": "none",
291
- "confidence": 95,
292
- "reasoning": "'''',,。,。",
293
- "location": null,
294
- "vendor": "unknown",
295
- "suggestions": [
296
- ",",
297
- ""
298
- ]
299
- }
300
- \`\`\`
301
-
302
- **3: **
303
- \`\`\`json
304
- {
305
- "detected": false,
306
- "type": "none",
307
- "confidence": 98,
308
- "reasoning": ",、。,suspiciousElements,URL。",
309
- "location": null,
310
- "vendor": "unknown",
311
- "suggestions": [
312
- ",",
313
- ""
314
- ]
315
- }
316
- \`\`\`
317
-
318
- ##
319
-
320
- 1. ****: \`detected: false\`,
321
- 2. ****: > DOM >
322
- 3. ****: URL、、DOM、
323
- 4. ****: reasoning
324
- 5. ****: suggestions
325
-
146
+
147
+ ##
148
+
149
+ ### 1. (Interactive CAPTCHA)
150
+ **1.1 (Slider CAPTCHA)**
151
+ - ****: 、
152
+ - ****: (Geetest)、、、
153
+ - ****: 、、""
154
+ - **DOM**: \`.geetest_slider\`, \`.nc_1_wrapper\`, \`.tcaptcha-transform\`
155
+
156
+ **1.2 (Image CAPTCHA)**
157
+ - ****: ("")
158
+ - ****: reCAPTCHA v2、hCaptcha
159
+ - ****: 3x34x4、
160
+ - **DOM**: \`iframe[src*="recaptcha"]\`, \`.h-captcha\`
161
+
162
+ **1.3 (Text CAPTCHA)**
163
+ - ****: /
164
+ - ****: 、
165
+ - ****: ""
166
+
167
+ ### 2. (Automatic CAPTCHA)
168
+ **2.1 reCAPTCHA v3**
169
+ - ****: ,reCAPTCHA
170
+ - ****: "Protected by reCAPTCHA"
171
+
172
+ **2.2 Cloudflare Turnstile**
173
+ - ****: "" / "Checking your browser"
174
+ - ****: Cloudflare logo、、Ray ID
175
+
176
+ ### 3. (False Positives - )
177
+ **3.1 **
178
+ - 、、
179
+ - ""()
180
+ - ""()
181
+
182
+ **3.2 **
183
+ - 、
184
+ - 、
185
+ -
186
+
187
+ **3.3 UI**
188
+ - Range slider、Progress bar
189
+ - Carousel、Swiper
190
+ - 、
191
+
192
+ ##
193
+
194
+ ### Step 1:
195
+ 1. :
196
+ - +
197
+ - +
198
+ - ""
199
+ - ""
200
+ - Cloudflare/reCAPTCHA logo
201
+
202
+ ### Step 2:
203
+ 1. URL:
204
+ - \`/captcha\`, \`/challenge\`, \`/verify\`
205
+ - \`cdn-cgi/challenge\` (Cloudflare)
206
+ - \`recaptcha.net\`, \`hcaptcha.com\`
207
+
208
+ 2. :
209
+ - ""、""、""
210
+ - "Verify", "Challenge", "Security Check"
211
+
212
+ 3. :
213
+ - suspiciousElements →
214
+ - →
215
+
216
+ ### Step 3:
217
+ 1. :
218
+ - ""、""
219
+ - ,
220
+ - → \`detected: false\`
221
+
222
+ 2. /UI:
223
+ - 、、
224
+ - → \`detected: false\`
225
+
226
+ ### Step 4:
227
+ - **90-100%**: + DOM
228
+ - **70-89%**: ,DOM
229
+ - **50-69%**: ,
230
+ - **0-49%**:
231
+
232
+ ##
233
+
234
+ **JSON Schema**:
235
+
236
+ \`\`\`json
237
+ {
238
+ "detected": boolean,
239
+ "type": "slider" | "image" | "recaptcha" | "hcaptcha" | "cloudflare" | "text_input" | "none",
240
+ "confidence": number,
241
+ "reasoning": string,
242
+ "location": {
243
+ "x": number,
244
+ "y": number,
245
+ "width": number,
246
+ "height": number
247
+ } | null,
248
+ "vendor": "geetest" | "tencent" | "aliyun" | "recaptcha" | "hcaptcha" | "cloudflare" | "unknown",
249
+ "suggestions": string[]
250
+ }
251
+ \`\`\`
252
+
253
+ ###
254
+ - **detected**: ()
255
+ - **type**: ()
256
+ - **confidence**: (0-100)
257
+ - **reasoning**: (200,)
258
+ - **location**: (,null)
259
+ - **vendor**: ("unknown")
260
+ - **suggestions**: (,2-3)
261
+
262
+ ###
263
+
264
+ **1: **
265
+ \`\`\`json
266
+ {
267
+ "detected": true,
268
+ "type": "slider",
269
+ "confidence": 95,
270
+ "reasoning": ":1) ;2) '';3) DOM.geetest_slider。。",
271
+ "location": {
272
+ "x": 450,
273
+ "y": 300,
274
+ "width": 320,
275
+ "height": 180
276
+ },
277
+ "vendor": "geetest",
278
+ "suggestions": [
279
+ "",
280
+ "captcha_wait",
281
+ ","
282
+ ]
283
+ }
284
+ \`\`\`
285
+
286
+ **2: - **
287
+ \`\`\`json
288
+ {
289
+ "detected": false,
290
+ "type": "none",
291
+ "confidence": 95,
292
+ "reasoning": "'''',,。,。",
293
+ "location": null,
294
+ "vendor": "unknown",
295
+ "suggestions": [
296
+ ",",
297
+ ""
298
+ ]
299
+ }
300
+ \`\`\`
301
+
302
+ **3: **
303
+ \`\`\`json
304
+ {
305
+ "detected": false,
306
+ "type": "none",
307
+ "confidence": 98,
308
+ "reasoning": ",、。,suspiciousElements,URL。",
309
+ "location": null,
310
+ "vendor": "unknown",
311
+ "suggestions": [
312
+ ",",
313
+ ""
314
+ ]
315
+ }
316
+ \`\`\`
317
+
318
+ ##
319
+
320
+ 1. ****: \`detected: false\`,
321
+ 2. ****: > DOM >
322
+ 3. ****: URL、、DOM、
323
+ 4. ****: reasoning
324
+ 5. ****: suggestions
325
+
326
326
  ,JSON。`;
327
327
  }
328
328
  parseAIResponse(response, screenshotPath) {
@@ -103,31 +103,31 @@ export class MacProcessManager {
103
103
  if (!process) {
104
104
  return [];
105
105
  }
106
- const appleScript = `
107
- tell application "System Events"
108
- set processList to {}
109
- try
110
- set targetProcess to first process whose unix id is ${pid}
111
- set procName to name of targetProcess
112
- set windowList to {}
113
-
114
- tell targetProcess
115
- repeat with win in windows
116
- set winInfo to {|
117
- title:name of win,
118
- className:procName,
119
- processId:${pid},
120
- handle:"applescript-window"
121
- |}
122
- set end of windowList to winInfo
123
- end repeat
124
- end tell
125
-
126
- return windowList
127
- on error
128
- return {}
129
- end try
130
- end tell
106
+ const appleScript = `
107
+ tell application "System Events"
108
+ set processList to {}
109
+ try
110
+ set targetProcess to first process whose unix id is ${pid}
111
+ set procName to name of targetProcess
112
+ set windowList to {}
113
+
114
+ tell targetProcess
115
+ repeat with win in windows
116
+ set winInfo to {|
117
+ title:name of win,
118
+ className:procName,
119
+ processId:${pid},
120
+ handle:"applescript-window"
121
+ |}
122
+ set end of windowList to winInfo
123
+ end repeat
124
+ end tell
125
+
126
+ return windowList
127
+ on error
128
+ return {}
129
+ end try
130
+ end tell
131
131
  `;
132
132
  const { stdout } = await execAsync(`osascript -e '${appleScript.replace(/'/g, "'\"'\"'")}' 2>/dev/null || echo "[]"`, { timeout: 5000 });
133
133
  const windows = [];
@@ -103,55 +103,55 @@ export async function checkDebugPort(platform, pid) {
103
103
  return { success: false, error: 'Debug port check currently only implemented for Windows' };
104
104
  }
105
105
  try {
106
- const psScript = `
107
- Add-Type @"
108
- using System;
109
- using System.Runtime.InteropServices;
110
- using System.ComponentModel;
111
-
112
- public class DebugChecker {
113
- [DllImport("ntdll.dll")]
114
- public static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, out IntPtr processInformation, int processInformationLength, out int returnLength);
115
-
116
- [DllImport("kernel32.dll", SetLastError = true)]
117
- public static extern IntPtr OpenProcess(int access, bool inherit, int pid);
118
-
119
- [DllImport("kernel32.dll", SetLastError = true)]
120
- public static extern bool CloseHandle(IntPtr handle);
121
-
122
- const int PROCESS_QUERY_INFORMATION = 0x0400;
123
- const int ProcessDebugPort = 7;
124
-
125
- public static object Check(int pid) {
126
- IntPtr hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, false, pid);
127
- if (hProcess == IntPtr.Zero) {
128
- int error = Marshal.GetLastWin32Error();
129
- throw new Win32Exception(error, "Failed to open process");
130
- }
131
-
132
- try {
133
- IntPtr debugPort;
134
- int returnLength;
135
- int status = NtQueryInformationProcess(hProcess, ProcessDebugPort, out debugPort, IntPtr.Size, out returnLength);
136
-
137
- if (status != 0) {
138
- return new { success = false, error = "NtQueryInformationProcess failed with status: 0x" + status.ToString("X") };
139
- }
140
-
141
- return new { success = true, isDebugged = debugPort != IntPtr.Zero };
142
- } finally {
143
- CloseHandle(hProcess);
144
- }
145
- }
146
- }
147
- "@
148
-
149
- try {
150
- $result = [DebugChecker]::Check(${pid})
151
- $result | ConvertTo-Json -Compress
152
- } catch {
153
- @{ success = $false; error = $_.Exception.Message } | ConvertTo-Json -Compress
154
- }
106
+ const psScript = `
107
+ Add-Type @"
108
+ using System;
109
+ using System.Runtime.InteropServices;
110
+ using System.ComponentModel;
111
+
112
+ public class DebugChecker {
113
+ [DllImport("ntdll.dll")]
114
+ public static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, out IntPtr processInformation, int processInformationLength, out int returnLength);
115
+
116
+ [DllImport("kernel32.dll", SetLastError = true)]
117
+ public static extern IntPtr OpenProcess(int access, bool inherit, int pid);
118
+
119
+ [DllImport("kernel32.dll", SetLastError = true)]
120
+ public static extern bool CloseHandle(IntPtr handle);
121
+
122
+ const int PROCESS_QUERY_INFORMATION = 0x0400;
123
+ const int ProcessDebugPort = 7;
124
+
125
+ public static object Check(int pid) {
126
+ IntPtr hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, false, pid);
127
+ if (hProcess == IntPtr.Zero) {
128
+ int error = Marshal.GetLastWin32Error();
129
+ throw new Win32Exception(error, "Failed to open process");
130
+ }
131
+
132
+ try {
133
+ IntPtr debugPort;
134
+ int returnLength;
135
+ int status = NtQueryInformationProcess(hProcess, ProcessDebugPort, out debugPort, IntPtr.Size, out returnLength);
136
+
137
+ if (status != 0) {
138
+ return new { success = false, error = "NtQueryInformationProcess failed with status: 0x" + status.ToString("X") };
139
+ }
140
+
141
+ return new { success = true, isDebugged = debugPort != IntPtr.Zero };
142
+ } finally {
143
+ CloseHandle(hProcess);
144
+ }
145
+ }
146
+ }
147
+ "@
148
+
149
+ try {
150
+ $result = [DebugChecker]::Check(${pid})
151
+ $result | ConvertTo-Json -Compress
152
+ } catch {
153
+ @{ success = $false; error = $_.Exception.Message } | ConvertTo-Json -Compress
154
+ }
155
155
  `;
156
156
  const { stdout } = await executePowerShellScript(psScript, { maxBuffer: 1024 * 1024, timeout: 10000 });
157
157
  const _trimmed = stdout.trim();