@jshookmcp/jshook 0.2.8 → 0.3.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.
Files changed (162) hide show
  1. package/README.md +36 -5
  2. package/README.zh.md +36 -5
  3. package/dist/{AntiCheatDetector-S8VRj-dD.mjs → AntiCheatDetector-CqGDXmfc.mjs} +160 -54
  4. package/dist/{CodeInjector-4Z3ngPoX.mjs → CodeInjector-BdjRfNx7.mjs} +5 -5
  5. package/dist/ConsoleMonitor-DykL3IAw.mjs +2269 -0
  6. package/dist/{DarwinAPI-B8hg_yhz.mjs → DarwinAPI-ETyy0xyo.mjs} +1 -1
  7. package/dist/DetailedDataManager-HT49OrvF.mjs +217 -0
  8. package/dist/EventBus-DFKvADm3.mjs +141 -0
  9. package/dist/EvidenceGraphBridge-318Oi0Lf.mjs +153 -0
  10. package/dist/{ExtensionManager-D5-bO9D8.mjs → ExtensionManager-BDMsY2Dz.mjs} +27 -13
  11. package/dist/{FingerprintManager-BVxFJL2-.mjs → FingerprintManager-BN4UQWnX.mjs} +1 -1
  12. package/dist/{HardwareBreakpoint-DK1yjWkV.mjs → HardwareBreakpoint-Cc2AFq1Y.mjs} +3 -3
  13. package/dist/{HeapAnalyzer-CEbo10xU.mjs → HeapAnalyzer-DruMgsgj.mjs} +21 -21
  14. package/dist/HookGeneratorBuilders.core.generators.storage-CTbB4Lcx.mjs +566 -0
  15. package/dist/InstrumentationSession-DLH0vd-z.mjs +244 -0
  16. package/dist/{MemoryController-DdtnBdD4.mjs → MemoryController-CMtviNW_.mjs} +3 -3
  17. package/dist/{MemoryScanSession-RMixN3bX.mjs → MemoryScanSession-ITgb_NMi.mjs} +81 -78
  18. package/dist/{MemoryScanner-QjK4ld0B.mjs → MemoryScanner-CiL7Z3ey.mjs} +50 -21
  19. package/dist/{NativeMemoryManager.impl-CB6gJ0NM.mjs → NativeMemoryManager.impl-D9Lkovvn.mjs} +20 -56
  20. package/dist/{NativeMemoryManager.utils-BML4q1ry.mjs → NativeMemoryManager.utils-BBlAixF5.mjs} +1 -1
  21. package/dist/{PEAnalyzer-CK0xe0Fs.mjs → PEAnalyzer-DMQ44gen.mjs} +16 -16
  22. package/dist/PageController-BPJNqqBN.mjs +431 -0
  23. package/dist/{PointerChainEngine-Cd73qu5b.mjs → PointerChainEngine-K7wN8Z-w.mjs} +10 -7
  24. package/dist/PrerequisiteError-TuyZIs6n.mjs +20 -0
  25. package/dist/ProcessRegistry-zGg12QbE.mjs +74 -0
  26. package/dist/ResponseBuilder-CJXWmWNw.mjs +143 -0
  27. package/dist/ReverseEvidenceGraph-C02-gXOh.mjs +269 -0
  28. package/dist/ScriptManager-ZuWD-0Jg.mjs +3003 -0
  29. package/dist/{Speedhack-CeF0XmEz.mjs → Speedhack-D-z0umeT.mjs} +2 -2
  30. package/dist/{StructureAnalyzer-D4GkMduU.mjs → StructureAnalyzer-Cav5AVSL.mjs} +9 -6
  31. package/dist/ToolCatalog-5OJdMiF0.mjs +582 -0
  32. package/dist/ToolError-jh9whhMd.mjs +15 -0
  33. package/dist/ToolProbe-DbCFGyrg.mjs +45 -0
  34. package/dist/ToolRegistry-B9krbTtI.mjs +180 -0
  35. package/dist/ToolRouter.policy-BGDAGyeH.mjs +344 -0
  36. package/dist/TraceRecorder-B41Z5XBj.mjs +1286 -0
  37. package/dist/{Win32API-Bc0QnQsN.mjs → Win32API-C2kjj0ze.mjs} +19 -13
  38. package/dist/{Win32Debug-DUHt9XUn.mjs → Win32Debug-CKrGOTpo.mjs} +3 -3
  39. package/dist/WorkflowEngine-DJ6M4opp.mjs +569 -0
  40. package/dist/analysis-BHeJW2Nb.mjs +1234 -0
  41. package/dist/antidebug-BRKeyt27.mjs +1081 -0
  42. package/dist/artifactRetention-CPXkUJXp.mjs +598 -0
  43. package/dist/artifacts-DkfosXH3.mjs +59 -0
  44. package/dist/authorization-schema-DRqyJMSk.mjs +31 -0
  45. package/dist/betterSqlite3-DLSBZodi.mjs +74 -0
  46. package/dist/binary-instrument--V3MAhJ4.mjs +971 -0
  47. package/dist/bind-helpers-ClV34xdn.mjs +42 -0
  48. package/dist/boringssl-inspector-Bo_LOLaS.mjs +180 -0
  49. package/dist/browser-Dx3_S2cG.mjs +4369 -0
  50. package/dist/capabilities-CcHlvWgK.mjs +33 -0
  51. package/dist/concurrency-Drev_Vz9.mjs +41 -0
  52. package/dist/{constants-CCvsN80K.mjs → constants-CDZLOoVv.mjs} +105 -48
  53. package/dist/coordination-DgItD9DL.mjs +259 -0
  54. package/dist/debugger-RS3RSAqs.mjs +1288 -0
  55. package/dist/definitions-BEoYofW5.mjs +47 -0
  56. package/dist/definitions-BRaefg3u.mjs +365 -0
  57. package/dist/definitions-BbkvZkiv.mjs +96 -0
  58. package/dist/definitions-BtWSHJ3o.mjs +17 -0
  59. package/dist/definitions-C1gCHO0i.mjs +43 -0
  60. package/dist/definitions-CDOg_b-l.mjs +138 -0
  61. package/dist/definitions-CVPD9hzZ.mjs +54 -0
  62. package/dist/definitions-Cea8Lgl7.mjs +94 -0
  63. package/dist/definitions-DAgIyjxM.mjs +10 -0
  64. package/dist/definitions-DJA27nsL.mjs +66 -0
  65. package/dist/definitions-DKPFU3LW.mjs +25 -0
  66. package/dist/definitions-DPRpZQ96.mjs +47 -0
  67. package/dist/definitions-DUE5gmdn.mjs +18 -0
  68. package/dist/definitions-DYVjOtxa.mjs +26 -0
  69. package/dist/definitions-DcYLVLCo.mjs +37 -0
  70. package/dist/definitions-Pp5LI2H4.mjs +27 -0
  71. package/dist/definitions-j9KdHVNR.mjs +14 -0
  72. package/dist/definitions-uzkjBwa7.mjs +258 -0
  73. package/dist/definitions-va-AnLuQ.mjs +28 -0
  74. package/dist/encoding-DJeqHmpd.mjs +1079 -0
  75. package/dist/evidence-graph-bridge-DcYizFk2.mjs +136 -0
  76. package/dist/{factory-CibqTNC8.mjs → factory-C90tBff6.mjs} +41 -56
  77. package/dist/flat-target-session-Dgax2Cy3.mjs +29 -0
  78. package/dist/graphql-CoHrhweh.mjs +1197 -0
  79. package/dist/handlers-4jmR0nMs.mjs +898 -0
  80. package/dist/handlers-BAHPxcch.mjs +789 -0
  81. package/dist/handlers-BOs9b907.mjs +2600 -0
  82. package/dist/handlers-BWXEy6ef.mjs +917 -0
  83. package/dist/handlers-Bndn6QvE.mjs +111 -0
  84. package/dist/handlers-BqC4bD4s.mjs +681 -0
  85. package/dist/handlers-BtYq60bM2.mjs +276 -0
  86. package/dist/handlers-BzgcB4iv.mjs +799 -0
  87. package/dist/handlers-CRyRWj2b.mjs +859 -0
  88. package/dist/handlers-CVv2H1uq.mjs +592 -0
  89. package/dist/handlers-Dl5a7JS4.mjs +572 -0
  90. package/dist/handlers-Dx2d7jt7.mjs +2537 -0
  91. package/dist/handlers-Dz9PYsCa.mjs +2805 -0
  92. package/dist/handlers-HujRKC3b.mjs +661 -0
  93. package/dist/handlers.impl-XWXkQfyi.mjs +807 -0
  94. package/dist/hooks-B1B8NRHL.mjs +898 -0
  95. package/dist/index.mjs +491 -259
  96. package/dist/{logger-BmWzC2lM.mjs → logger-Dh_xb7_2.mjs} +14 -6
  97. package/dist/maintenance-PRMkLVRW.mjs +835 -0
  98. package/dist/manifest-67Bok-Si.mjs +58 -0
  99. package/dist/manifest-6lNTMZAB2.mjs +87 -0
  100. package/dist/manifest-B2duEHiH.mjs +90 -0
  101. package/dist/manifest-B6EY9Vm8.mjs +57 -0
  102. package/dist/manifest-B6nKSbyY.mjs +95 -0
  103. package/dist/manifest-BL8AQNPF.mjs +106 -0
  104. package/dist/manifest-BSZvJJmV.mjs +47 -0
  105. package/dist/manifest-BU7qzUyX.mjs +418 -0
  106. package/dist/manifest-Bl62e8WK.mjs +49 -0
  107. package/dist/manifest-Bo5cXjdt.mjs +82 -0
  108. package/dist/manifest-BpS4gtUK.mjs +1347 -0
  109. package/dist/manifest-Bv65_e2W.mjs +101 -0
  110. package/dist/manifest-BytNIF4Z.mjs +117 -0
  111. package/dist/manifest-C-xtsjS3.mjs +81 -0
  112. package/dist/manifest-CDYl7OhA.mjs +66 -0
  113. package/dist/manifest-CRZ3xmkD.mjs +61 -0
  114. package/dist/manifest-CoW6u4Tp.mjs +132 -0
  115. package/dist/manifest-Cq5zN_8A.mjs +50 -0
  116. package/dist/manifest-D7YZM_2e.mjs +194 -0
  117. package/dist/manifest-DE_VrAeQ.mjs +314 -0
  118. package/dist/manifest-DGsXSCpT.mjs +39 -0
  119. package/dist/manifest-DJ2vfEuW.mjs +156 -0
  120. package/dist/manifest-DPXDYhEu.mjs +80 -0
  121. package/dist/manifest-Dd4fQb0a.mjs +322 -0
  122. package/dist/manifest-Deq6opGg.mjs +223 -0
  123. package/dist/manifest-DfJTafJK.mjs +37 -0
  124. package/dist/manifest-DgOdgN_j.mjs +50 -0
  125. package/dist/manifest-DlbMW4v4.mjs +47 -0
  126. package/dist/manifest-DmVfbH0w.mjs +374 -0
  127. package/dist/manifest-Dog6Ddjr.mjs +109 -0
  128. package/dist/manifest-DvgU5FWb.mjs +58 -0
  129. package/dist/manifest-HsfDBs7j.mjs +50 -0
  130. package/dist/manifest-I8oQHvCG.mjs +186 -0
  131. package/dist/manifest-NvH_a-av.mjs +786 -0
  132. package/dist/manifest-cEJU1v0Z.mjs +129 -0
  133. package/dist/manifest-wOl5XLB12.mjs +112 -0
  134. package/dist/modules-tZozf0LQ.mjs +10635 -0
  135. package/dist/mojo-ipc-DXNEXEqb.mjs +640 -0
  136. package/dist/network-CPVvwvFg.mjs +3852 -0
  137. package/dist/{artifacts-BbdOMET5.mjs → outputPaths-um7lCRY3.mjs} +219 -216
  138. package/dist/parse-args-B4cY5Vx5.mjs +39 -0
  139. package/dist/platform-CYeFoTWp.mjs +2161 -0
  140. package/dist/process-BTbgcVc6.mjs +1306 -0
  141. package/dist/proxy-r8YN6nP1.mjs +192 -0
  142. package/dist/registry-Bl8ZQW61.mjs +34 -0
  143. package/dist/response-CWhh2aLo.mjs +34 -0
  144. package/dist/server/plugin-api.mjs +2 -2
  145. package/dist/shared-state-board-BoZnSoj-.mjs +586 -0
  146. package/dist/sourcemap-BIDHUVXy.mjs +934 -0
  147. package/dist/ssrf-policy-Dsqd-DTX.mjs +166 -0
  148. package/dist/streaming-Dal6utPp.mjs +725 -0
  149. package/dist/tool-builder-BHJp32mV.mjs +186 -0
  150. package/dist/transform-DRVgGG90.mjs +1011 -0
  151. package/dist/types-Bx92KJfT.mjs +4 -0
  152. package/dist/wasm-BYx5UOeG.mjs +1044 -0
  153. package/dist/webcrack-Be0_FccV.mjs +747 -0
  154. package/dist/workflow-BpuKEtvn.mjs +725 -0
  155. package/package.json +82 -49
  156. package/dist/ExtensionManager-CPTJhHFg.mjs +0 -2
  157. package/dist/ToolCatalog-Bq4V2sbJ.mjs +0 -67201
  158. package/dist/{CacheAdapters-CzFNpD9a.mjs → CacheAdapters-jJFy20G-.mjs} +0 -0
  159. package/dist/{StealthVerifier-BzBCFiwx.mjs → StealthVerifier-BWmPgQsv.mjs} +0 -0
  160. package/dist/{VersionDetector-CNXcvD46.mjs → VersionDetector-K3V4vGsw.mjs} +0 -0
  161. package/dist/{formatAddress-ChCSIRWT.mjs → formatAddress-nnMvEohD.mjs} +0 -0
  162. package/dist/{types-BBjOqye-.mjs → types-DDBWs9UP.mjs} +1 -1
@@ -0,0 +1,1081 @@
1
+ import { o as argStringArray, r as argNumber, t as argBool } from "./parse-args-B4cY5Vx5.mjs";
2
+ import { o as evaluateOnNewDocumentWithTimeout, s as evaluateWithTimeout } from "./PageController-BPJNqqBN.mjs";
3
+ import "./definitions-DUE5gmdn.mjs";
4
+ //#region src/server/domains/antidebug/scripts.data.bypass-core.ts
5
+ const ANTI_DEBUG_BYPASS_CORE_SCRIPTS = {
6
+ bypassDebuggerStatement: `(function () {
7
+ var globalObj = typeof window !== 'undefined' ? window : globalThis;
8
+ var installFlag = '__ANTI_DEBUGGER_STATEMENT_INSTALLED__';
9
+ if (Object.prototype.hasOwnProperty.call(globalObj, installFlag)) {
10
+ return;
11
+ }
12
+
13
+ try {
14
+ Object.defineProperty(globalObj, installFlag, {
15
+ value: true,
16
+ enumerable: false,
17
+ configurable: false,
18
+ writable: false
19
+ });
20
+ } catch (_) {
21
+ globalObj[installFlag] = true;
22
+ }
23
+
24
+ var mode = __ANTI_DEBUG_MODE__;
25
+ var NativeFunction = Function;
26
+
27
+ function sanitizeSource(source) {
28
+ if (typeof source !== 'string') {
29
+ return source;
30
+ }
31
+ if (!/\\bdebugger\\b/.test(source)) {
32
+ return source;
33
+ }
34
+ if (mode === 'remove') {
35
+ return source.replace(/\\bdebugger\\b\\s*;?/g, '');
36
+ }
37
+ return source.replace(/\\bdebugger\\b\\s*;?/g, 'void 0;');
38
+ }
39
+
40
+ var PatchedFunction = new Proxy(NativeFunction, {
41
+ apply: function (target, thisArg, argArray) {
42
+ if (Array.isArray(argArray) && argArray.length > 0) {
43
+ var nextArgs = argArray.slice();
44
+ var lastIndex = nextArgs.length - 1;
45
+ nextArgs[lastIndex] = sanitizeSource(nextArgs[lastIndex]);
46
+ return Reflect.apply(target, thisArg, nextArgs);
47
+ }
48
+ return Reflect.apply(target, thisArg, argArray);
49
+ },
50
+ construct: function (target, argArray, newTarget) {
51
+ if (Array.isArray(argArray) && argArray.length > 0) {
52
+ var nextArgs = argArray.slice();
53
+ var lastIndex = nextArgs.length - 1;
54
+ nextArgs[lastIndex] = sanitizeSource(nextArgs[lastIndex]);
55
+ return Reflect.construct(target, nextArgs, newTarget);
56
+ }
57
+ return Reflect.construct(target, argArray, newTarget);
58
+ }
59
+ });
60
+
61
+ try {
62
+ Object.defineProperty(PatchedFunction, 'toString', {
63
+ value: function () {
64
+ return 'function Function() { [native code] }';
65
+ },
66
+ enumerable: false,
67
+ configurable: false,
68
+ writable: false
69
+ });
70
+ } catch (_) {}
71
+
72
+ try {
73
+ Object.defineProperty(Function.prototype, 'constructor', {
74
+ value: PatchedFunction,
75
+ enumerable: false,
76
+ configurable: false,
77
+ writable: false
78
+ });
79
+ } catch (_) {}
80
+
81
+ function patchScriptElement(scriptEl) {
82
+ if (!scriptEl || scriptEl.tagName !== 'SCRIPT') {
83
+ return;
84
+ }
85
+
86
+ if (scriptEl.src) {
87
+ return;
88
+ }
89
+
90
+ var code = scriptEl.textContent || '';
91
+ if (!/\\bdebugger\\b/.test(code)) {
92
+ return;
93
+ }
94
+
95
+ if (mode === 'remove') {
96
+ try {
97
+ scriptEl.remove();
98
+ } catch (_) {}
99
+ return;
100
+ }
101
+
102
+ try {
103
+ scriptEl.textContent = sanitizeSource(code);
104
+ } catch (_) {}
105
+ }
106
+
107
+ function visitNode(node) {
108
+ if (!node || node.nodeType !== 1) {
109
+ return;
110
+ }
111
+
112
+ var element = node;
113
+ if (element.tagName === 'SCRIPT') {
114
+ patchScriptElement(element);
115
+ }
116
+
117
+ if (typeof element.querySelectorAll === 'function') {
118
+ var nestedScripts = element.querySelectorAll('script');
119
+ for (var i = 0; i < nestedScripts.length; i += 1) {
120
+ patchScriptElement(nestedScripts[i]);
121
+ }
122
+ }
123
+ }
124
+
125
+ var observer = new MutationObserver(function (mutations) {
126
+ for (var i = 0; i < mutations.length; i += 1) {
127
+ var mutation = mutations[i];
128
+ if (!mutation.addedNodes) {
129
+ continue;
130
+ }
131
+ for (var j = 0; j < mutation.addedNodes.length; j += 1) {
132
+ visitNode(mutation.addedNodes[j]);
133
+ }
134
+ }
135
+ });
136
+
137
+ function startObserving() {
138
+ try {
139
+ if (document.documentElement) {
140
+ observer.observe(document.documentElement, {
141
+ childList: true,
142
+ subtree: true
143
+ });
144
+ }
145
+ } catch (_) {}
146
+ }
147
+
148
+ if (document.documentElement) {
149
+ startObserving();
150
+ } else {
151
+ document.addEventListener('DOMContentLoaded', startObserving, { once: true });
152
+ }
153
+
154
+ var existingScripts = document.querySelectorAll('script');
155
+ for (var i = 0; i < existingScripts.length; i += 1) {
156
+ patchScriptElement(existingScripts[i]);
157
+ }
158
+ })();`,
159
+ bypassTiming: `(function () {
160
+ var globalObj = typeof window !== 'undefined' ? window : globalThis;
161
+ var installFlag = '__ANTI_DEBUG_TIMING_INSTALLED__';
162
+ if (Object.prototype.hasOwnProperty.call(globalObj, installFlag)) {
163
+ return;
164
+ }
165
+
166
+ try {
167
+ Object.defineProperty(globalObj, installFlag, {
168
+ value: true,
169
+ enumerable: false,
170
+ configurable: false,
171
+ writable: false
172
+ });
173
+ } catch (_) {
174
+ globalObj[installFlag] = true;
175
+ }
176
+
177
+ var maxDrift = __ANTI_DEBUG_MAX_DRIFT__;
178
+ if (typeof maxDrift !== 'number' || !isFinite(maxDrift) || maxDrift < 0) {
179
+ maxDrift = 50;
180
+ }
181
+
182
+ var perfNow = typeof performance !== 'undefined' && performance && typeof performance.now === 'function'
183
+ ? performance.now.bind(performance)
184
+ : function () { return Date.now(); };
185
+
186
+ var dateNow = Date.now.bind(Date);
187
+
188
+ var lastPerfReal = perfNow();
189
+ var logicalPerf = lastPerfReal;
190
+
191
+ var lastDateReal = dateNow();
192
+ var logicalDate = lastDateReal;
193
+
194
+ function stepLogicalTime(currentReal, lastRealRef, logicalRef) {
195
+ var delta = currentReal - lastRealRef.value;
196
+ if (!isFinite(delta) || delta < 0) {
197
+ delta = 0;
198
+ }
199
+ if (delta > maxDrift) {
200
+ delta = maxDrift;
201
+ }
202
+ logicalRef.value += delta;
203
+ lastRealRef.value = currentReal;
204
+ return logicalRef.value;
205
+ }
206
+
207
+ var perfLastRef = { value: lastPerfReal };
208
+ var perfLogicalRef = { value: logicalPerf };
209
+ var dateLastRef = { value: lastDateReal };
210
+ var dateLogicalRef = { value: logicalDate };
211
+
212
+ var wrappedPerformanceNow = function () {
213
+ return stepLogicalTime(perfNow(), perfLastRef, perfLogicalRef);
214
+ };
215
+
216
+ var wrappedDateNow = function () {
217
+ return Math.floor(stepLogicalTime(dateNow(), dateLastRef, dateLogicalRef));
218
+ };
219
+
220
+ try {
221
+ Object.defineProperty(performance, 'now', {
222
+ value: wrappedPerformanceNow,
223
+ enumerable: false,
224
+ configurable: false,
225
+ writable: false
226
+ });
227
+ } catch (_) {
228
+ try {
229
+ performance.now = wrappedPerformanceNow;
230
+ } catch (_) {}
231
+ }
232
+
233
+ try {
234
+ Object.defineProperty(Date, 'now', {
235
+ value: wrappedDateNow,
236
+ enumerable: false,
237
+ configurable: false,
238
+ writable: false
239
+ });
240
+ } catch (_) {
241
+ try {
242
+ Date.now = wrappedDateNow;
243
+ } catch (_) {}
244
+ }
245
+
246
+ var labels = Object.create(null);
247
+ var nativeConsoleLog = typeof console !== 'undefined' && console && typeof console.log === 'function'
248
+ ? console.log.bind(console)
249
+ : function () {};
250
+
251
+ var wrappedTime = function (label) {
252
+ var key = String(label == null ? 'default' : label);
253
+ labels[key] = wrappedPerformanceNow();
254
+ };
255
+
256
+ var wrappedTimeEnd = function (label) {
257
+ var key = String(label == null ? 'default' : label);
258
+ var nowValue = wrappedPerformanceNow();
259
+ var startValue = labels[key];
260
+ if (typeof startValue !== 'number') {
261
+ nativeConsoleLog(key + ': 0.000ms');
262
+ return 0;
263
+ }
264
+ var duration = Math.max(0, nowValue - startValue);
265
+ delete labels[key];
266
+ nativeConsoleLog(key + ': ' + duration.toFixed(3) + 'ms');
267
+ return duration;
268
+ };
269
+
270
+ try {
271
+ Object.defineProperty(console, 'time', {
272
+ value: wrappedTime,
273
+ enumerable: false,
274
+ configurable: false,
275
+ writable: false
276
+ });
277
+ } catch (_) {
278
+ try {
279
+ console.time = wrappedTime;
280
+ } catch (_) {}
281
+ }
282
+
283
+ try {
284
+ Object.defineProperty(console, 'timeEnd', {
285
+ value: wrappedTimeEnd,
286
+ enumerable: false,
287
+ configurable: false,
288
+ writable: false
289
+ });
290
+ } catch (_) {
291
+ try {
292
+ console.timeEnd = wrappedTimeEnd;
293
+ } catch (_) {}
294
+ }
295
+ })();`,
296
+ bypassStackTrace: `(function () {
297
+ var globalObj = typeof window !== 'undefined' ? window : globalThis;
298
+ var installFlag = '__ANTI_DEBUG_STACK_TRACE_INSTALLED__';
299
+ if (Object.prototype.hasOwnProperty.call(globalObj, installFlag)) {
300
+ return;
301
+ }
302
+
303
+ try {
304
+ Object.defineProperty(globalObj, installFlag, {
305
+ value: true,
306
+ enumerable: false,
307
+ configurable: false,
308
+ writable: false
309
+ });
310
+ } catch (_) {
311
+ globalObj[installFlag] = true;
312
+ }
313
+
314
+ var configuredPatterns = __ANTI_DEBUG_FILTER_PATTERNS__;
315
+ if (!Array.isArray(configuredPatterns)) {
316
+ configuredPatterns = ['puppeteer', 'devtools', '__puppeteer', 'cdp'];
317
+ }
318
+
319
+ var normalizedPatterns = configuredPatterns
320
+ .map(function (item) {
321
+ return String(item).toLowerCase().trim();
322
+ })
323
+ .filter(function (item) {
324
+ return item.length > 0;
325
+ });
326
+
327
+ function sanitizeStack(stackText) {
328
+ if (typeof stackText !== 'string' || stackText.length === 0) {
329
+ return stackText;
330
+ }
331
+
332
+ var lines = stackText.split('\\n');
333
+ var filtered = [];
334
+ for (var i = 0; i < lines.length; i += 1) {
335
+ var line = lines[i];
336
+ var lowerLine = line.toLowerCase();
337
+ var blocked = false;
338
+ for (var j = 0; j < normalizedPatterns.length; j += 1) {
339
+ if (lowerLine.indexOf(normalizedPatterns[j]) !== -1) {
340
+ blocked = true;
341
+ break;
342
+ }
343
+ }
344
+ if (!blocked) {
345
+ filtered.push(line);
346
+ }
347
+ }
348
+
349
+ return filtered.join('\\n');
350
+ }
351
+
352
+ var sourceMapKey = '__ANTI_NATIVE_SOURCE_MAP__';
353
+ var toStringFlag = '__ANTI_TOSTRING_PATCHED__';
354
+ var nativeSourceMap = globalObj[sourceMapKey];
355
+
356
+ if (!(nativeSourceMap instanceof WeakMap)) {
357
+ nativeSourceMap = new WeakMap();
358
+ try {
359
+ Object.defineProperty(globalObj, sourceMapKey, {
360
+ value: nativeSourceMap,
361
+ enumerable: false,
362
+ configurable: false,
363
+ writable: false
364
+ });
365
+ } catch (_) {
366
+ globalObj[sourceMapKey] = nativeSourceMap;
367
+ }
368
+ }
369
+
370
+ if (!globalObj[toStringFlag]) {
371
+ var nativeToString = Function.prototype.toString;
372
+ var patchedToString = function () {
373
+ if (nativeSourceMap && nativeSourceMap.has(this)) {
374
+ return nativeSourceMap.get(this);
375
+ }
376
+ return nativeToString.call(this);
377
+ };
378
+
379
+ try {
380
+ Object.defineProperty(Function.prototype, 'toString', {
381
+ value: patchedToString,
382
+ enumerable: false,
383
+ configurable: false,
384
+ writable: false
385
+ });
386
+ Object.defineProperty(globalObj, toStringFlag, {
387
+ value: true,
388
+ enumerable: false,
389
+ configurable: false,
390
+ writable: false
391
+ });
392
+ } catch (_) {
393
+ globalObj[toStringFlag] = true;
394
+ }
395
+ }
396
+
397
+ function markAsNative(fn, name) {
398
+ if (!(nativeSourceMap instanceof WeakMap) || typeof fn !== 'function') {
399
+ return;
400
+ }
401
+ var fnName = String(name || fn.name || 'anonymous').replace(/[^a-zA-Z0-9_$]/g, '');
402
+ nativeSourceMap.set(fn, 'function ' + fnName + '() { [native code] }');
403
+ }
404
+
405
+ function sanitizeError(error) {
406
+ if (!error || typeof error !== 'object') {
407
+ return error;
408
+ }
409
+
410
+ try {
411
+ if (typeof error.stack === 'string') {
412
+ Object.defineProperty(error, 'stack', {
413
+ value: sanitizeStack(error.stack),
414
+ enumerable: false,
415
+ configurable: true,
416
+ writable: true
417
+ });
418
+ }
419
+ } catch (_) {}
420
+
421
+ return error;
422
+ }
423
+
424
+ var NativeError = Error;
425
+ var PatchedError = function () {
426
+ var args = Array.prototype.slice.call(arguments);
427
+ var err = Reflect.construct(NativeError, args, PatchedError);
428
+ return sanitizeError(err);
429
+ };
430
+
431
+ PatchedError.prototype = NativeError.prototype;
432
+ try {
433
+ Object.setPrototypeOf(PatchedError, NativeError);
434
+ } catch (_) {}
435
+
436
+ if (typeof NativeError.captureStackTrace === 'function') {
437
+ var nativeCapture = NativeError.captureStackTrace.bind(NativeError);
438
+ var patchedCapture = function (target, constructorOpt) {
439
+ nativeCapture(target, constructorOpt);
440
+ sanitizeError(target);
441
+ };
442
+
443
+ try {
444
+ Object.defineProperty(PatchedError, 'captureStackTrace', {
445
+ value: patchedCapture,
446
+ enumerable: false,
447
+ configurable: false,
448
+ writable: false
449
+ });
450
+ markAsNative(patchedCapture, 'captureStackTrace');
451
+ } catch (_) {}
452
+ }
453
+
454
+ var stackDescriptor = Object.getOwnPropertyDescriptor(NativeError.prototype, 'stack');
455
+ if (stackDescriptor && typeof stackDescriptor.get === 'function') {
456
+ var nativeStackGetter = stackDescriptor.get;
457
+ var nativeStackSetter = stackDescriptor.set;
458
+
459
+ try {
460
+ Object.defineProperty(NativeError.prototype, 'stack', {
461
+ get: function () {
462
+ return sanitizeStack(nativeStackGetter.call(this));
463
+ },
464
+ set: function (value) {
465
+ if (typeof nativeStackSetter === 'function') {
466
+ nativeStackSetter.call(this, value);
467
+ return;
468
+ }
469
+ Object.defineProperty(this, 'stack', {
470
+ value: value,
471
+ enumerable: false,
472
+ configurable: true,
473
+ writable: true
474
+ });
475
+ },
476
+ enumerable: false,
477
+ configurable: stackDescriptor.configurable === true
478
+ });
479
+ } catch (_) {}
480
+ }
481
+
482
+ markAsNative(PatchedError, 'Error');
483
+
484
+ try {
485
+ Object.defineProperty(globalObj, 'Error', {
486
+ value: PatchedError,
487
+ enumerable: false,
488
+ configurable: false,
489
+ writable: false
490
+ });
491
+ } catch (_) {
492
+ try {
493
+ globalObj.Error = PatchedError;
494
+ } catch (_) {}
495
+ }
496
+ })();`
497
+ };
498
+ //#endregion
499
+ //#region src/server/domains/antidebug/scripts.data.bypass-console.ts
500
+ const ANTI_DEBUG_BYPASS_CONSOLE_SCRIPT = { bypassConsoleDetect: `(function () {
501
+ var globalObj = typeof window !== 'undefined' ? window : globalThis;
502
+ var installFlag = '__ANTI_DEBUG_CONSOLE_INSTALLED__';
503
+ if (Object.prototype.hasOwnProperty.call(globalObj, installFlag)) {
504
+ return;
505
+ }
506
+
507
+ try {
508
+ Object.defineProperty(globalObj, installFlag, {
509
+ value: true,
510
+ enumerable: false,
511
+ configurable: false,
512
+ writable: false
513
+ });
514
+ } catch (_) {
515
+ globalObj[installFlag] = true;
516
+ }
517
+
518
+ var sourceMapKey = '__ANTI_NATIVE_SOURCE_MAP__';
519
+ var toStringFlag = '__ANTI_TOSTRING_PATCHED__';
520
+ var nativeSourceMap = globalObj[sourceMapKey];
521
+
522
+ if (!(nativeSourceMap instanceof WeakMap)) {
523
+ nativeSourceMap = new WeakMap();
524
+ try {
525
+ Object.defineProperty(globalObj, sourceMapKey, {
526
+ value: nativeSourceMap,
527
+ enumerable: false,
528
+ configurable: false,
529
+ writable: false
530
+ });
531
+ } catch (_) {
532
+ globalObj[sourceMapKey] = nativeSourceMap;
533
+ }
534
+ }
535
+
536
+ if (!globalObj[toStringFlag]) {
537
+ var nativeToString = Function.prototype.toString;
538
+ var patchedToString = function () {
539
+ if (nativeSourceMap && nativeSourceMap.has(this)) {
540
+ return nativeSourceMap.get(this);
541
+ }
542
+ return nativeToString.call(this);
543
+ };
544
+
545
+ try {
546
+ Object.defineProperty(Function.prototype, 'toString', {
547
+ value: patchedToString,
548
+ enumerable: false,
549
+ configurable: false,
550
+ writable: false
551
+ });
552
+ Object.defineProperty(globalObj, toStringFlag, {
553
+ value: true,
554
+ enumerable: false,
555
+ configurable: false,
556
+ writable: false
557
+ });
558
+ } catch (_) {
559
+ globalObj[toStringFlag] = true;
560
+ }
561
+ }
562
+
563
+ function markAsNative(fn, name) {
564
+ if (!(nativeSourceMap instanceof WeakMap) || typeof fn !== 'function') {
565
+ return;
566
+ }
567
+ var fnName = String(name || fn.name || 'anonymous').replace(/[^a-zA-Z0-9_$]/g, '');
568
+ nativeSourceMap.set(fn, 'function ' + fnName + '() { [native code] }');
569
+ }
570
+
571
+ function sanitizeArg(value, depth, seen) {
572
+ if (depth > 3) {
573
+ return '[MaxDepth]';
574
+ }
575
+
576
+ var valueType = typeof value;
577
+ if (value == null || valueType === 'string' || valueType === 'number' || valueType === 'boolean' || valueType === 'bigint') {
578
+ return value;
579
+ }
580
+
581
+ if (valueType === 'symbol') {
582
+ return value.toString();
583
+ }
584
+
585
+ if (valueType === 'function') {
586
+ return '[Function ' + (value.name || 'anonymous') + ']';
587
+ }
588
+
589
+ if (valueType !== 'object') {
590
+ return String(value);
591
+ }
592
+
593
+ if (!(seen instanceof WeakSet)) {
594
+ seen = new WeakSet();
595
+ }
596
+
597
+ if (seen.has(value)) {
598
+ return '[Circular]';
599
+ }
600
+ seen.add(value);
601
+
602
+ if (Array.isArray(value)) {
603
+ var outArray = [];
604
+ for (var i = 0; i < value.length; i += 1) {
605
+ outArray.push(sanitizeArg(value[i], depth + 1, seen));
606
+ }
607
+ return outArray;
608
+ }
609
+
610
+ var outObject = {};
611
+ var descriptors = {};
612
+ try {
613
+ descriptors = Object.getOwnPropertyDescriptors(value);
614
+ } catch (_) {
615
+ return '[Uninspectable Object]';
616
+ }
617
+
618
+ var keys = Object.keys(descriptors);
619
+ for (var j = 0; j < keys.length; j += 1) {
620
+ var key = keys[j];
621
+ var descriptor = descriptors[key];
622
+ if (!descriptor) {
623
+ continue;
624
+ }
625
+
626
+ if (typeof descriptor.get === 'function' && !Object.prototype.hasOwnProperty.call(descriptor, 'value')) {
627
+ outObject[key] = '[Getter]';
628
+ continue;
629
+ }
630
+
631
+ if (Object.prototype.hasOwnProperty.call(descriptor, 'value')) {
632
+ outObject[key] = sanitizeArg(descriptor.value, depth + 1, seen);
633
+ }
634
+ }
635
+
636
+ return outObject;
637
+ }
638
+
639
+ function wrapConsoleMethod(methodName, nativeMethod) {
640
+ var wrapped = function () {
641
+ if (methodName === 'clear') {
642
+ return undefined;
643
+ }
644
+
645
+ var rawArgs = Array.prototype.slice.call(arguments);
646
+ var safeArgs = [];
647
+ for (var i = 0; i < rawArgs.length; i += 1) {
648
+ safeArgs.push(sanitizeArg(rawArgs[i], 0, new WeakSet()));
649
+ }
650
+
651
+ try {
652
+ nativeMethod.apply(console, safeArgs);
653
+ } catch (_) {}
654
+
655
+ return undefined;
656
+ };
657
+
658
+ markAsNative(wrapped, methodName);
659
+ return wrapped;
660
+ }
661
+
662
+ var methods = ['log', 'debug', 'info', 'warn', 'error', 'table', 'dir', 'trace', 'clear'];
663
+ for (var idx = 0; idx < methods.length; idx += 1) {
664
+ var methodName = methods[idx];
665
+ var nativeMethod = console && console[methodName];
666
+ if (typeof nativeMethod !== 'function') {
667
+ continue;
668
+ }
669
+
670
+ var wrappedMethod = wrapConsoleMethod(methodName, nativeMethod);
671
+
672
+ try {
673
+ Object.defineProperty(console, methodName, {
674
+ value: wrappedMethod,
675
+ enumerable: false,
676
+ configurable: false,
677
+ writable: false
678
+ });
679
+ } catch (_) {
680
+ try {
681
+ console[methodName] = wrappedMethod;
682
+ } catch (_) {}
683
+ }
684
+ }
685
+ })();` };
686
+ //#endregion
687
+ //#region src/server/domains/antidebug/scripts.data.detect.ts
688
+ const ANTI_DEBUG_DETECT_SCRIPTS = { detectProtections: `(async function () {
689
+ function pushUnique(list, value) {
690
+ if (list.indexOf(value) === -1) {
691
+ list.push(value);
692
+ }
693
+ }
694
+
695
+ var findings = [];
696
+ var recommendations = [];
697
+
698
+ function addFinding(type, severity, evidence, strategy) {
699
+ findings.push({
700
+ type: type,
701
+ severity: severity,
702
+ evidence: evidence,
703
+ recommendedBypass: strategy
704
+ });
705
+ pushUnique(recommendations, strategy);
706
+ }
707
+
708
+ var inlineScripts = [];
709
+ try {
710
+ var scriptNodes = document.querySelectorAll('script');
711
+ for (var i = 0; i < scriptNodes.length; i += 1) {
712
+ var node = scriptNodes[i];
713
+ if (!node.src && typeof node.textContent === 'string' && node.textContent.trim().length > 0) {
714
+ inlineScripts.push(node.textContent.slice(0, 200000));
715
+ }
716
+ }
717
+ } catch (_) {}
718
+
719
+ var externalScripts = [];
720
+ try {
721
+ var externalCount = 0;
722
+ var allScriptNodes = document.querySelectorAll('script[src]');
723
+ for (var j = 0; j < allScriptNodes.length; j += 1) {
724
+ if (externalCount >= 8) {
725
+ break;
726
+ }
727
+
728
+ var scriptSrc = allScriptNodes[j].src;
729
+ if (!scriptSrc) {
730
+ continue;
731
+ }
732
+
733
+ try {
734
+ var absoluteUrl = new URL(scriptSrc, location.href);
735
+ if (absoluteUrl.origin !== location.origin) {
736
+ continue;
737
+ }
738
+
739
+ var response = await fetch(absoluteUrl.href, { credentials: 'same-origin' });
740
+ if (!response.ok) {
741
+ continue;
742
+ }
743
+
744
+ var text = await response.text();
745
+ externalScripts.push(text.slice(0, 200000));
746
+ externalCount += 1;
747
+ } catch (_) {}
748
+ }
749
+ } catch (_) {}
750
+
751
+ var sourceBlob = (inlineScripts.join('\\n') + '\\n' + externalScripts.join('\\n')).toLowerCase();
752
+
753
+ var debuggerTimerPattern = /(setinterval|settimeout)[\\s\\S]{0,180}debugger|debugger\\s*;/i;
754
+ if (debuggerTimerPattern.test(sourceBlob)) {
755
+ addFinding(
756
+ 'debugger_statement',
757
+ 'high',
758
+ 'Found debugger statements or timer-driven debugger triggers in script sources.',
759
+ 'antidebug_bypass_debugger_statement'
760
+ );
761
+ }
762
+
763
+ var timingPattern = /(performance\\.now\\s*\\(|date\\.now\\s*\\()[\\s\\S]{0,120}(>|>=|<|<=|===|!==)[\\s\\S]{0,60}(50|100|200|500|1000)/i;
764
+ if (timingPattern.test(sourceBlob)) {
765
+ addFinding(
766
+ 'timing_check',
767
+ 'high',
768
+ 'Found timing delta logic around performance.now()/Date.now().',
769
+ 'antidebug_bypass_timing'
770
+ );
771
+ }
772
+
773
+ var stackPattern = /(new\\s+error\\s*\\(|error\\s*\\(|\\.stack\\b|preparestacktrace)/i;
774
+ if (stackPattern.test(sourceBlob)) {
775
+ addFinding(
776
+ 'stack_trace_check',
777
+ 'medium',
778
+ 'Found Error.stack or stack trace analysis patterns.',
779
+ 'antidebug_bypass_stack_trace'
780
+ );
781
+ }
782
+
783
+ var consolePattern = /(console\\.(log|clear|table|debug|dir|trace)\\s*\\(|console\\s*=|Object\\.defineProperty\\s*\\(\\s*console)/i;
784
+ if (consolePattern.test(sourceBlob)) {
785
+ addFinding(
786
+ 'console_detect',
787
+ 'medium',
788
+ 'Found console instrumentation or console-based detection patterns.',
789
+ 'antidebug_bypass_console_detect'
790
+ );
791
+ }
792
+
793
+ var devtoolsSizePattern = /(outerheight\\s*-\\s*innerheight|outerwidth\\s*-\\s*innerwidth|innerheight\\s*<\\s*outerheight|innerwidth\\s*<\\s*outerwidth)/i;
794
+ if (devtoolsSizePattern.test(sourceBlob)) {
795
+ addFinding(
796
+ 'devtools_window_check',
797
+ 'low',
798
+ 'Found outer/inner window dimension comparison likely used for devtools panel detection.',
799
+ 'antidebug_bypass_all'
800
+ );
801
+ }
802
+
803
+ var overwrittenConsoleMethods = [];
804
+ var nativeCodePattern = /\\{\\s*\\[native code\\]\\s*\\}/i;
805
+ var runtimeMethods = ['log', 'debug', 'info', 'warn', 'error', 'table', 'clear'];
806
+ for (var k = 0; k < runtimeMethods.length; k += 1) {
807
+ var methodName = runtimeMethods[k];
808
+ try {
809
+ var candidate = console[methodName];
810
+ if (typeof candidate !== 'function') {
811
+ overwrittenConsoleMethods.push(methodName + ':non-function');
812
+ continue;
813
+ }
814
+
815
+ var fnSource = Function.prototype.toString.call(candidate);
816
+ if (!nativeCodePattern.test(fnSource)) {
817
+ overwrittenConsoleMethods.push(methodName);
818
+ }
819
+ } catch (_) {}
820
+ }
821
+
822
+ if (overwrittenConsoleMethods.length > 0) {
823
+ addFinding(
824
+ 'console_runtime_overwrite',
825
+ 'medium',
826
+ 'Runtime console methods appear wrapped/overwritten: ' + overwrittenConsoleMethods.join(', '),
827
+ 'antidebug_bypass_console_detect'
828
+ );
829
+ }
830
+
831
+ return {
832
+ success: true,
833
+ detected: findings.length > 0,
834
+ count: findings.length,
835
+ protections: findings,
836
+ recommendations: recommendations,
837
+ evidence: {
838
+ scannedInlineScripts: inlineScripts.length,
839
+ scannedExternalScripts: externalScripts.length,
840
+ sourceBytesApprox: sourceBlob.length
841
+ }
842
+ };
843
+ })();` };
844
+ //#endregion
845
+ //#region src/server/domains/antidebug/scripts.data.ts
846
+ const ANTI_DEBUG_SCRIPTS = {
847
+ ...ANTI_DEBUG_BYPASS_CORE_SCRIPTS,
848
+ ...ANTI_DEBUG_BYPASS_CONSOLE_SCRIPT,
849
+ ...ANTI_DEBUG_DETECT_SCRIPTS
850
+ };
851
+ //#endregion
852
+ //#region src/server/domains/antidebug/handlers.ts
853
+ var AntiDebugToolHandlers = class AntiDebugToolHandlers {
854
+ static DEFAULT_DEBUGGER_MODE = "remove";
855
+ static DEFAULT_MAX_DRIFT = 50;
856
+ static DEFAULT_STACK_FILTER_PATTERNS = [
857
+ "puppeteer",
858
+ "devtools",
859
+ "__puppeteer",
860
+ "CDP"
861
+ ];
862
+ constructor(collector) {
863
+ this.collector = collector;
864
+ }
865
+ toTextResponse(payload) {
866
+ return { content: [{
867
+ type: "text",
868
+ text: JSON.stringify(payload, null, 2)
869
+ }] };
870
+ }
871
+ parseDebuggerMode(value) {
872
+ if (value === "remove" || value === "noop") return value;
873
+ if (typeof value === "string") {
874
+ const normalized = value.trim().toLowerCase();
875
+ if (normalized === "remove" || normalized === "noop") return normalized;
876
+ }
877
+ return AntiDebugToolHandlers.DEFAULT_DEBUGGER_MODE;
878
+ }
879
+ mergeStackFilterPatterns(extraPatterns) {
880
+ const merged = [...AntiDebugToolHandlers.DEFAULT_STACK_FILTER_PATTERNS, ...extraPatterns].map((item) => item.trim());
881
+ return Array.from(new Set(merged.filter((item) => item.length > 0)));
882
+ }
883
+ buildScript(template, replacements) {
884
+ let output = template;
885
+ for (const [token, value] of Object.entries(replacements)) output = output.split(token).join(value);
886
+ return output;
887
+ }
888
+ buildDebuggerBypassScript(mode) {
889
+ return this.buildScript(ANTI_DEBUG_SCRIPTS.bypassDebuggerStatement, { __ANTI_DEBUG_MODE__: JSON.stringify(mode) });
890
+ }
891
+ buildTimingBypassScript(maxDrift) {
892
+ return this.buildScript(ANTI_DEBUG_SCRIPTS.bypassTiming, { __ANTI_DEBUG_MAX_DRIFT__: String(maxDrift) });
893
+ }
894
+ buildStackTraceBypassScript(filterPatterns) {
895
+ return this.buildScript(ANTI_DEBUG_SCRIPTS.bypassStackTrace, { __ANTI_DEBUG_FILTER_PATTERNS__: JSON.stringify(filterPatterns) });
896
+ }
897
+ async injectScripts(page, scripts, persistent) {
898
+ if (persistent) for (const script of scripts) await evaluateOnNewDocumentWithTimeout(page, script);
899
+ for (const script of scripts) await evaluateWithTimeout(page, script);
900
+ }
901
+ async getPage() {
902
+ return this.collector.getActivePage();
903
+ }
904
+ async handleAntiDebugBypassAll(args) {
905
+ try {
906
+ const persistent = argBool(args, "persistent", true);
907
+ const page = await this.getPage();
908
+ const scripts = [
909
+ this.buildDebuggerBypassScript(AntiDebugToolHandlers.DEFAULT_DEBUGGER_MODE),
910
+ this.buildTimingBypassScript(AntiDebugToolHandlers.DEFAULT_MAX_DRIFT),
911
+ this.buildStackTraceBypassScript(this.mergeStackFilterPatterns([])),
912
+ ANTI_DEBUG_SCRIPTS.bypassConsoleDetect
913
+ ];
914
+ await this.injectScripts(page, scripts, persistent);
915
+ return this.toTextResponse({
916
+ success: true,
917
+ tool: "antidebug_bypass_all",
918
+ persistent,
919
+ injectedCount: scripts.length,
920
+ injected: [
921
+ "bypassDebuggerStatement",
922
+ "bypassTiming",
923
+ "bypassStackTrace",
924
+ "bypassConsoleDetect"
925
+ ]
926
+ });
927
+ } catch (error) {
928
+ return this.toTextResponse({
929
+ success: false,
930
+ tool: "antidebug_bypass_all",
931
+ error: error instanceof Error ? error.message : String(error)
932
+ });
933
+ }
934
+ }
935
+ async handleAntiDebugBypassDebuggerStatement(args) {
936
+ try {
937
+ const mode = this.parseDebuggerMode(args.mode);
938
+ const page = await this.getPage();
939
+ const script = this.buildDebuggerBypassScript(mode);
940
+ await this.injectScripts(page, [script], true);
941
+ return this.toTextResponse({
942
+ success: true,
943
+ tool: "antidebug_bypass_debugger_statement",
944
+ mode,
945
+ persistent: true
946
+ });
947
+ } catch (error) {
948
+ return this.toTextResponse({
949
+ success: false,
950
+ tool: "antidebug_bypass_debugger_statement",
951
+ error: error instanceof Error ? error.message : String(error)
952
+ });
953
+ }
954
+ }
955
+ async handleAntiDebugBypassTiming(args) {
956
+ try {
957
+ const maxDrift = argNumber(args, "maxDrift", AntiDebugToolHandlers.DEFAULT_MAX_DRIFT) ?? AntiDebugToolHandlers.DEFAULT_MAX_DRIFT;
958
+ const page = await this.getPage();
959
+ const script = this.buildTimingBypassScript(maxDrift);
960
+ await this.injectScripts(page, [script], true);
961
+ return this.toTextResponse({
962
+ success: true,
963
+ tool: "antidebug_bypass_timing",
964
+ maxDrift,
965
+ persistent: true
966
+ });
967
+ } catch (error) {
968
+ return this.toTextResponse({
969
+ success: false,
970
+ tool: "antidebug_bypass_timing",
971
+ error: error instanceof Error ? error.message : String(error)
972
+ });
973
+ }
974
+ }
975
+ async handleAntiDebugBypassStackTrace(args) {
976
+ try {
977
+ const userPatterns = argStringArray(args, "filterPatterns");
978
+ const mergedPatterns = this.mergeStackFilterPatterns(userPatterns);
979
+ const page = await this.getPage();
980
+ const script = this.buildStackTraceBypassScript(mergedPatterns);
981
+ await this.injectScripts(page, [script], true);
982
+ return this.toTextResponse({
983
+ success: true,
984
+ tool: "antidebug_bypass_stack_trace",
985
+ filterPatterns: mergedPatterns,
986
+ persistent: true
987
+ });
988
+ } catch (error) {
989
+ return this.toTextResponse({
990
+ success: false,
991
+ tool: "antidebug_bypass_stack_trace",
992
+ error: error instanceof Error ? error.message : String(error)
993
+ });
994
+ }
995
+ }
996
+ async handleAntiDebugBypassConsoleDetect(_args) {
997
+ try {
998
+ const page = await this.getPage();
999
+ await this.injectScripts(page, [ANTI_DEBUG_SCRIPTS.bypassConsoleDetect], true);
1000
+ return this.toTextResponse({
1001
+ success: true,
1002
+ tool: "antidebug_bypass_console_detect",
1003
+ persistent: true
1004
+ });
1005
+ } catch (error) {
1006
+ return this.toTextResponse({
1007
+ success: false,
1008
+ tool: "antidebug_bypass_console_detect",
1009
+ error: error instanceof Error ? error.message : String(error)
1010
+ });
1011
+ }
1012
+ }
1013
+ async handleAntiDebugDetectProtections(_args) {
1014
+ try {
1015
+ const result = await evaluateWithTimeout(await this.getPage(), ANTI_DEBUG_SCRIPTS.detectProtections);
1016
+ return this.toTextResponse({
1017
+ success: result?.success ?? true,
1018
+ tool: "antidebug_detect_protections",
1019
+ detected: result?.detected ?? false,
1020
+ count: result?.count ?? 0,
1021
+ protections: result?.protections ?? [],
1022
+ recommendations: result?.recommendations ?? [],
1023
+ evidence: result?.evidence ?? {}
1024
+ });
1025
+ } catch (error) {
1026
+ return this.toTextResponse({
1027
+ success: false,
1028
+ tool: "antidebug_detect_protections",
1029
+ error: error instanceof Error ? error.message : String(error)
1030
+ });
1031
+ }
1032
+ }
1033
+ async handleAntidebugBypass(args) {
1034
+ const rawTypes = args["types"];
1035
+ const typesArr = Array.isArray(rawTypes) ? rawTypes : ["all"];
1036
+ const types = typesArr.length === 0 ? ["all"] : typesArr;
1037
+ if (types.includes("all")) return this.handleAntiDebugBypassAll(args);
1038
+ const persistent = argBool(args, "persistent", true);
1039
+ const mode = this.parseDebuggerMode(args["mode"]);
1040
+ const maxDrift = argNumber(args, "maxDrift", AntiDebugToolHandlers.DEFAULT_MAX_DRIFT) ?? AntiDebugToolHandlers.DEFAULT_MAX_DRIFT;
1041
+ const userPatterns = argStringArray(args, "filterPatterns");
1042
+ const applied = [];
1043
+ try {
1044
+ const page = await this.getPage();
1045
+ if (types.includes("debugger_statement")) {
1046
+ const script = this.buildDebuggerBypassScript(mode);
1047
+ await this.injectScripts(page, [script], persistent);
1048
+ applied.push("debugger_statement");
1049
+ }
1050
+ if (types.includes("timing")) {
1051
+ const script = this.buildTimingBypassScript(maxDrift);
1052
+ await this.injectScripts(page, [script], persistent);
1053
+ applied.push("timing");
1054
+ }
1055
+ if (types.includes("stack_trace")) {
1056
+ const mergedPatterns = this.mergeStackFilterPatterns(userPatterns);
1057
+ const script = this.buildStackTraceBypassScript(mergedPatterns);
1058
+ await this.injectScripts(page, [script], persistent);
1059
+ applied.push("stack_trace");
1060
+ }
1061
+ if (types.includes("console_detect")) {
1062
+ await this.injectScripts(page, [ANTI_DEBUG_SCRIPTS.bypassConsoleDetect], persistent);
1063
+ applied.push("console_detect");
1064
+ }
1065
+ return this.toTextResponse({
1066
+ success: true,
1067
+ tool: "antidebug_bypass",
1068
+ applied,
1069
+ persistent
1070
+ });
1071
+ } catch (error) {
1072
+ return this.toTextResponse({
1073
+ success: false,
1074
+ tool: "antidebug_bypass",
1075
+ error: error instanceof Error ? error.message : String(error)
1076
+ });
1077
+ }
1078
+ }
1079
+ };
1080
+ //#endregion
1081
+ export { AntiDebugToolHandlers };