@jshookmcp/jshook 0.2.7 → 0.2.9

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 (157) hide show
  1. package/README.md +36 -5
  2. package/README.zh.md +36 -5
  3. package/dist/{AntiCheatDetector-S8VRj-dD.mjs → AntiCheatDetector-BNk-EoBt.mjs} +3 -3
  4. package/dist/{CodeInjector-4Z3ngPoX.mjs → CodeInjector-Cq8q01kp.mjs} +5 -5
  5. package/dist/ConsoleMonitor-CPVQW1Y-.mjs +2201 -0
  6. package/dist/{DarwinAPI-B8hg_yhz.mjs → DarwinAPI-BNPxu0RH.mjs} +1 -1
  7. package/dist/DetailedDataManager-BQQcxh64.mjs +217 -0
  8. package/dist/EventBus-DgPmwpeu.mjs +141 -0
  9. package/dist/EvidenceGraphBridge-SFesNera.mjs +153 -0
  10. package/dist/{ExtensionManager-CZ6IveoV.mjs → ExtensionManager-CWYgw0YW.mjs} +13 -6
  11. package/dist/{FingerprintManager-BVxFJL2-.mjs → FingerprintManager-gzWtkKuf.mjs} +1 -1
  12. package/dist/{HardwareBreakpoint-DK1yjWkV.mjs → HardwareBreakpoint-B9gZCdFP.mjs} +3 -3
  13. package/dist/{HeapAnalyzer-CEbo10xU.mjs → HeapAnalyzer-BLDH0dCv.mjs} +4 -4
  14. package/dist/HookGeneratorBuilders.core.generators.storage-CtcdK78Q.mjs +639 -0
  15. package/dist/InstrumentationSession-CvPC7Jwy.mjs +244 -0
  16. package/dist/{MemoryController-DdtnBdD4.mjs → MemoryController-CbVdCIJF.mjs} +3 -3
  17. package/dist/{MemoryScanSession-RMixN3bX.mjs → MemoryScanSession-BsDZbLYm.mjs} +81 -78
  18. package/dist/{MemoryScanner-QjK4ld0B.mjs → MemoryScanner-Bcpml6II.mjs} +44 -18
  19. package/dist/{NativeMemoryManager.impl-CB6gJ0NM.mjs → NativeMemoryManager.impl-dZtA1ZGn.mjs} +14 -53
  20. package/dist/{NativeMemoryManager.utils-BML4q1ry.mjs → NativeMemoryManager.utils-B-FjA2mJ.mjs} +1 -1
  21. package/dist/{PEAnalyzer-CK0xe0Fs.mjs → PEAnalyzer-D1lzJ_VG.mjs} +2 -2
  22. package/dist/PageController-Bqm2kZ_X.mjs +417 -0
  23. package/dist/{PointerChainEngine-Cd73qu5b.mjs → PointerChainEngine-BOhyVsjx.mjs} +4 -4
  24. package/dist/PrerequisiteError-Dl33Svkz.mjs +20 -0
  25. package/dist/ResponseBuilder-D3iFYx2N.mjs +143 -0
  26. package/dist/ReverseEvidenceGraph-Dlsk94LC.mjs +269 -0
  27. package/dist/ScriptManager-aHHq0X7U.mjs +3000 -0
  28. package/dist/{Speedhack-CeF0XmEz.mjs → Speedhack-CqdIFlQl.mjs} +2 -2
  29. package/dist/{StructureAnalyzer-D4GkMduU.mjs → StructureAnalyzer-DhFaPvRO.mjs} +3 -3
  30. package/dist/ToolCatalog-C0JGZoOm.mjs +582 -0
  31. package/dist/ToolError-jh9whhMd.mjs +15 -0
  32. package/dist/ToolProbe-oC7aPrkv.mjs +45 -0
  33. package/dist/ToolRegistry-BjaF4oNz.mjs +131 -0
  34. package/dist/ToolRouter.policy-BWV67ZK-.mjs +304 -0
  35. package/dist/TraceRecorder-DgxyVbdQ.mjs +519 -0
  36. package/dist/{Win32API-Bc0QnQsN.mjs → Win32API-CePkipZY.mjs} +1 -1
  37. package/dist/{Win32Debug-DUHt9XUn.mjs → Win32Debug-BvKs-gxc.mjs} +2 -2
  38. package/dist/WorkflowEngine-CuvkZtWu.mjs +598 -0
  39. package/dist/analysis-CL9uACt9.mjs +463 -0
  40. package/dist/antidebug-CqDTB_uk.mjs +1081 -0
  41. package/dist/artifactRetention-CFEprwPw.mjs +591 -0
  42. package/dist/artifacts-Bk2-_uPq.mjs +59 -0
  43. package/dist/betterSqlite3-0pqusHHH.mjs +74 -0
  44. package/dist/binary-instrument-CXfpx6fT.mjs +979 -0
  45. package/dist/bind-helpers-xFfRF-qm.mjs +22 -0
  46. package/dist/boringssl-inspector-BH2D3VKc.mjs +180 -0
  47. package/dist/browser-BpOr5PEx.mjs +4082 -0
  48. package/dist/concurrency-Bt0yv1kJ.mjs +41 -0
  49. package/dist/{constants-CCvsN80K.mjs → constants-B0OANIBL.mjs} +88 -46
  50. package/dist/coordination-qUbyF8KU.mjs +259 -0
  51. package/dist/debugger-gnKxRSN0.mjs +1271 -0
  52. package/dist/definitions-6M-eejaT.mjs +53 -0
  53. package/dist/definitions-B18eyf0B.mjs +18 -0
  54. package/dist/definitions-B3QdlrHv.mjs +34 -0
  55. package/dist/definitions-B4rAvHNZ.mjs +63 -0
  56. package/dist/definitions-BB_4jnmy.mjs +37 -0
  57. package/dist/definitions-BMfYXoNC.mjs +43 -0
  58. package/dist/definitions-Beid2EB3.mjs +27 -0
  59. package/dist/definitions-C1UvM5Iy.mjs +126 -0
  60. package/dist/definitions-CXEI7QC72.mjs +216 -0
  61. package/dist/definitions-C_4r7Fo-2.mjs +14 -0
  62. package/dist/definitions-CkFDALoa.mjs +26 -0
  63. package/dist/definitions-Cke7zEb8.mjs +94 -0
  64. package/dist/definitions-ClJLzsJQ.mjs +25 -0
  65. package/dist/definitions-Cq-zroAU.mjs +28 -0
  66. package/dist/definitions-Cy3Sl6gV.mjs +34 -0
  67. package/dist/definitions-D3VsGcvz.mjs +47 -0
  68. package/dist/definitions-DVGfrn7y.mjs +96 -0
  69. package/dist/definitions-LKpC3-nL.mjs +9 -0
  70. package/dist/definitions-bAhHQJq9.mjs +359 -0
  71. package/dist/encoding-Bvz5jLRv.mjs +1065 -0
  72. package/dist/evidence-graph-bridge-C_fv9PuC.mjs +135 -0
  73. package/dist/{factory-CibqTNC8.mjs → factory-DxlGh9Xf.mjs} +37 -52
  74. package/dist/graphql-DYWzJ29s.mjs +1026 -0
  75. package/dist/handlers-9sAbfIg-.mjs +2552 -0
  76. package/dist/handlers-Bl8zkwz1.mjs +2716 -0
  77. package/dist/handlers-C67ktuRN.mjs +710 -0
  78. package/dist/handlers-C87g8oCe.mjs +276 -0
  79. package/dist/handlers-CTsDAO6p.mjs +681 -0
  80. package/dist/handlers-Cgyg6c0U.mjs +645 -0
  81. package/dist/handlers-D6j6yka7.mjs +2124 -0
  82. package/dist/handlers-DdFzXLvF.mjs +446 -0
  83. package/dist/handlers-DeLOCd5m.mjs +799 -0
  84. package/dist/handlers-DlCJN4Td.mjs +757 -0
  85. package/dist/handlers-DxGIq15_2.mjs +917 -0
  86. package/dist/handlers-U6L4xhuF.mjs +585 -0
  87. package/dist/handlers-tB9Mp9ZK.mjs +84 -0
  88. package/dist/handlers-tiy7EIBp.mjs +572 -0
  89. package/dist/handlers.impl-DS0d9fUw.mjs +761 -0
  90. package/dist/hooks-CzCWByww.mjs +898 -0
  91. package/dist/index.mjs +384 -155
  92. package/dist/{logger-BmWzC2lM.mjs → logger-Dh_xb7_2.mjs} +14 -6
  93. package/dist/maintenance-P7ePRXQC.mjs +830 -0
  94. package/dist/manifest-2ToTpjv8.mjs +106 -0
  95. package/dist/manifest-3g71z6Bg.mjs +79 -0
  96. package/dist/manifest-82baTv4U.mjs +45 -0
  97. package/dist/manifest-B3QVVeBS.mjs +82 -0
  98. package/dist/manifest-BB2J8IMJ.mjs +149 -0
  99. package/dist/manifest-BKbgbSiY.mjs +60 -0
  100. package/dist/manifest-Bcf-TJzH.mjs +848 -0
  101. package/dist/manifest-BmtZzQiQ2.mjs +45 -0
  102. package/dist/manifest-Bnd7kqEY.mjs +55 -0
  103. package/dist/manifest-BqQX6OQC2.mjs +65 -0
  104. package/dist/manifest-BqrQ4Tpj.mjs +81 -0
  105. package/dist/manifest-Br4RPFt5.mjs +370 -0
  106. package/dist/manifest-C5qDjysN.mjs +107 -0
  107. package/dist/manifest-C9RT5nk32.mjs +34 -0
  108. package/dist/manifest-CAhOuvSl.mjs +204 -0
  109. package/dist/manifest-CBYWCUBJ.mjs +51 -0
  110. package/dist/manifest-CFADCRa1.mjs +37 -0
  111. package/dist/manifest-CQVhavRF.mjs +114 -0
  112. package/dist/manifest-CT7zZBV1.mjs +48 -0
  113. package/dist/manifest-CV12bcrF.mjs +121 -0
  114. package/dist/manifest-CXsRWjjI.mjs +224 -0
  115. package/dist/manifest-CZLUCfG02.mjs +95 -0
  116. package/dist/manifest-D6phHKFd.mjs +131 -0
  117. package/dist/manifest-DCyjf4n2.mjs +294 -0
  118. package/dist/manifest-DHsnKgP6.mjs +60 -0
  119. package/dist/manifest-Df_dliIe.mjs +55 -0
  120. package/dist/manifest-Dh8WBmEW.mjs +129 -0
  121. package/dist/manifest-DhKRAT8_.mjs +92 -0
  122. package/dist/manifest-DlpTj4ic2.mjs +193 -0
  123. package/dist/manifest-DrbmZcFl2.mjs +253 -0
  124. package/dist/manifest-DuwHjUa5.mjs +70 -0
  125. package/dist/manifest-DzwvxPJX.mjs +38 -0
  126. package/dist/manifest-NXctwWQq.mjs +68 -0
  127. package/dist/manifest-Sc_0JQ13.mjs +418 -0
  128. package/dist/manifest-gZ4s_UtG.mjs +96 -0
  129. package/dist/manifest-qSleDqdO.mjs +1023 -0
  130. package/dist/modules-C184v-S9.mjs +11365 -0
  131. package/dist/mojo-ipc-B_H61Afw.mjs +525 -0
  132. package/dist/network-671Cw6hV.mjs +3346 -0
  133. package/dist/{artifacts-BbdOMET5.mjs → outputPaths-B1uGmrWZ.mjs} +219 -212
  134. package/dist/parse-args-BlRjqlkL.mjs +39 -0
  135. package/dist/platform-WmNn8Sxb.mjs +2070 -0
  136. package/dist/process-QcbIy5Zq.mjs +1401 -0
  137. package/dist/proxy-DqNs0bAd.mjs +170 -0
  138. package/dist/registry-D-6e18lB.mjs +34 -0
  139. package/dist/response-BQVP-xUn.mjs +28 -0
  140. package/dist/server/plugin-api.mjs +2 -2
  141. package/dist/shared-state-board-DV-dpHFJ.mjs +586 -0
  142. package/dist/sourcemap-Dq8ez8vS.mjs +650 -0
  143. package/dist/ssrf-policy-ZaUfvhq7.mjs +166 -0
  144. package/dist/streaming-BUQ0VJsg.mjs +725 -0
  145. package/dist/tool-builder-DCbIC5Eo.mjs +186 -0
  146. package/dist/transform-CiYJfNX0.mjs +1007 -0
  147. package/dist/types-Bx92KJfT.mjs +4 -0
  148. package/dist/wasm-DQTnHDs4.mjs +531 -0
  149. package/dist/workflow-f3xJOcjx.mjs +725 -0
  150. package/package.json +48 -78
  151. package/dist/ExtensionManager-DqUSOamB.mjs +0 -2
  152. package/dist/ToolCatalog-CnwmMIw3.mjs +0 -61483
  153. package/dist/{CacheAdapters-CzFNpD9a.mjs → CacheAdapters-CDe5WPSV.mjs} +0 -0
  154. package/dist/{StealthVerifier-BzBCFiwx.mjs → StealthVerifier-Bo4T3bz8.mjs} +0 -0
  155. package/dist/{VersionDetector-CNXcvD46.mjs → VersionDetector-CwVLVdDM.mjs} +0 -0
  156. package/dist/{formatAddress-ChCSIRWT.mjs → formatAddress-DVkj9kpI.mjs} +0 -0
  157. package/dist/{types-BBjOqye-.mjs → types-CPhOReNX.mjs} +1 -1
@@ -0,0 +1,757 @@
1
+ import { n as asJsonResponse } from "./response-BQVP-xUn.mjs";
2
+ import { a as argString, t as argBool } from "./parse-args-BlRjqlkL.mjs";
3
+ //#region src/server/domains/cross-domain/handlers/skia-correlator.ts
4
+ function normalizeSkiaToken(value) {
5
+ return value.toLowerCase().replace(/[^a-z0-9]/g, "");
6
+ }
7
+ function computeTokenSimilarity(a, b) {
8
+ const na = normalizeSkiaToken(a);
9
+ const nb = normalizeSkiaToken(b);
10
+ if (na === nb && na.length > 0) return 1;
11
+ if (na.length === 0 || nb.length === 0) return 0;
12
+ if (na.includes(nb) || nb.includes(na)) return .8;
13
+ return 0;
14
+ }
15
+ function findBestJSMatch(label, jsObjects) {
16
+ let bestScore = 0;
17
+ let bestMatch;
18
+ for (const obj of jsObjects) {
19
+ const nameScore = computeTokenSimilarity(label, obj.name);
20
+ if (nameScore > bestScore) {
21
+ bestScore = nameScore;
22
+ bestMatch = {
23
+ objectId: obj.objectId,
24
+ name: obj.name,
25
+ score: nameScore
26
+ };
27
+ }
28
+ for (const prop of obj.stringProps) {
29
+ const propScore = computeTokenSimilarity(label, prop);
30
+ if (propScore > bestScore) {
31
+ bestScore = propScore;
32
+ bestMatch = {
33
+ objectId: obj.objectId,
34
+ name: obj.name,
35
+ score: propScore
36
+ };
37
+ }
38
+ }
39
+ }
40
+ if (bestMatch && bestScore >= .5) return bestMatch;
41
+ }
42
+ function correlateSkiaToJS(bridge, input) {
43
+ const graphNodeIds = [];
44
+ const correlations = [];
45
+ const unmatchedSkiaNodes = [];
46
+ const matchedIds = /* @__PURE__ */ new Set();
47
+ const allSkiaItems = [];
48
+ for (const layer of input.sceneTree.layers) allSkiaItems.push({
49
+ id: layer.id,
50
+ label: layer.label,
51
+ heapObjectId: layer.heapObjectId
52
+ });
53
+ for (const cmd of input.sceneTree.drawCommands) allSkiaItems.push({
54
+ id: cmd.id,
55
+ label: cmd.label
56
+ });
57
+ const totalSkiaNodes = allSkiaItems.length;
58
+ for (const item of allSkiaItems) {
59
+ const canvasNode = bridge.addCanvasNode({
60
+ nodeId: item.id,
61
+ label: item.label
62
+ });
63
+ graphNodeIds.push(canvasNode.id);
64
+ if (item.heapObjectId) {
65
+ const jsObj = input.jsObjects.find((o) => o.objectId === item.heapObjectId);
66
+ if (jsObj) {
67
+ const heapNode = bridge.addV8Object({
68
+ address: item.heapObjectId,
69
+ name: jsObj.name
70
+ });
71
+ graphNodeIds.push(heapNode.id);
72
+ bridge.getGraph().addEdge(heapNode.id, canvasNode.id, "canvas-rendered-by", {
73
+ domain: "cross-domain",
74
+ matchScore: 1
75
+ });
76
+ correlations.push({
77
+ skiaNodeId: item.id,
78
+ matchedObjectId: jsObj.objectId,
79
+ matchedObjectName: jsObj.name,
80
+ matchScore: 1
81
+ });
82
+ matchedIds.add(item.id);
83
+ continue;
84
+ }
85
+ }
86
+ const match = findBestJSMatch(item.label, input.jsObjects);
87
+ if (match) {
88
+ const heapNode = bridge.addV8Object({
89
+ address: match.objectId,
90
+ name: match.name
91
+ });
92
+ graphNodeIds.push(heapNode.id);
93
+ bridge.getGraph().addEdge(heapNode.id, canvasNode.id, "canvas-rendered-by", {
94
+ domain: "cross-domain",
95
+ matchScore: match.score
96
+ });
97
+ correlations.push({
98
+ skiaNodeId: item.id,
99
+ matchedObjectId: match.objectId,
100
+ matchedObjectName: match.name,
101
+ matchScore: match.score
102
+ });
103
+ matchedIds.add(item.id);
104
+ } else unmatchedSkiaNodes.push(item.id);
105
+ }
106
+ return {
107
+ skiaNodes: totalSkiaNodes,
108
+ correlations,
109
+ unmatchedSkiaNodes,
110
+ confidence: totalSkiaNodes === 0 ? 0 : correlations.length / totalSkiaNodes,
111
+ graphNodeIds
112
+ };
113
+ }
114
+ //#endregion
115
+ //#region src/server/domains/cross-domain/handlers/mojo-cdp-correlator.ts
116
+ /** Mapping of Mojo interface patterns to CDP event patterns. */
117
+ const INTERFACE_TO_CDP_PATTERNS = [
118
+ {
119
+ mojoPattern: /URLLoader/i,
120
+ cdpPattern: /Network\./i
121
+ },
122
+ {
123
+ mojoPattern: /WebSocket/i,
124
+ cdpPattern: /Network\.webSocket/i
125
+ },
126
+ {
127
+ mojoPattern: /Fetch/i,
128
+ cdpPattern: /Fetch\./i
129
+ }
130
+ ];
131
+ const TIMESTAMP_PROXIMITY_MS = 50;
132
+ function correlateMojoToCDP(bridge, mojoMessages, cdpEvents, networkRequests) {
133
+ const graphNodeIds = [];
134
+ const matchedPairs = [];
135
+ const matchedMojoIds = /* @__PURE__ */ new Set();
136
+ if (mojoMessages.length === 0) return {
137
+ mojoMessages: 0,
138
+ matchedPairs: [],
139
+ unmatchedMojo: [],
140
+ confidence: 0,
141
+ graphNodeIds: []
142
+ };
143
+ const mojoNodeMap = /* @__PURE__ */ new Map();
144
+ for (const msg of mojoMessages) {
145
+ const node = bridge.addMojoMessage({
146
+ interface: msg.interface,
147
+ method: msg.method,
148
+ timestamp: msg.timestamp
149
+ });
150
+ mojoNodeMap.set(msg.messageId, node.id);
151
+ graphNodeIds.push(node.id);
152
+ }
153
+ for (const msg of mojoMessages) {
154
+ if (matchedMojoIds.has(msg.messageId)) continue;
155
+ for (const pattern of INTERFACE_TO_CDP_PATTERNS) {
156
+ if (!pattern.mojoPattern.test(msg.interface)) continue;
157
+ const matchingCdp = cdpEvents.find((evt) => pattern.cdpPattern.test(evt.eventType) && !matchedMojoIds.has(msg.messageId));
158
+ if (matchingCdp) {
159
+ matchedPairs.push({
160
+ mojoMessageId: msg.messageId,
161
+ matchType: "interface",
162
+ cdpEventType: matchingCdp.eventType
163
+ });
164
+ matchedMojoIds.add(msg.messageId);
165
+ break;
166
+ }
167
+ }
168
+ }
169
+ for (const msg of mojoMessages) {
170
+ if (matchedMojoIds.has(msg.messageId)) continue;
171
+ if (/URLLoader/i.test(msg.interface)) {
172
+ const matchingReq = networkRequests.find((req) => Math.abs(req.timestamp - msg.timestamp) <= TIMESTAMP_PROXIMITY_MS);
173
+ if (matchingReq) {
174
+ matchedPairs.push({
175
+ mojoMessageId: msg.messageId,
176
+ matchType: "urlloader",
177
+ networkRequestId: matchingReq.requestId,
178
+ timestampDelta: Math.abs(matchingReq.timestamp - msg.timestamp)
179
+ });
180
+ matchedMojoIds.add(msg.messageId);
181
+ }
182
+ }
183
+ }
184
+ for (const msg of mojoMessages) {
185
+ if (matchedMojoIds.has(msg.messageId)) continue;
186
+ let closestDelta = Infinity;
187
+ let closestCdp;
188
+ for (const evt of cdpEvents) {
189
+ const delta = Math.abs(evt.timestamp - msg.timestamp);
190
+ if (delta <= TIMESTAMP_PROXIMITY_MS && delta < closestDelta) {
191
+ closestDelta = delta;
192
+ closestCdp = evt;
193
+ }
194
+ }
195
+ if (closestCdp) {
196
+ matchedPairs.push({
197
+ mojoMessageId: msg.messageId,
198
+ matchType: "timestamp",
199
+ cdpEventType: closestCdp.eventType,
200
+ timestampDelta: closestDelta
201
+ });
202
+ matchedMojoIds.add(msg.messageId);
203
+ }
204
+ }
205
+ const unmatchedMojo = mojoMessages.filter((msg) => !matchedMojoIds.has(msg.messageId)).map((msg) => msg.messageId);
206
+ const confidence = mojoMessages.length === 0 ? 0 : matchedMojoIds.size / mojoMessages.length;
207
+ return {
208
+ mojoMessages: mojoMessages.length,
209
+ matchedPairs,
210
+ unmatchedMojo,
211
+ confidence,
212
+ graphNodeIds
213
+ };
214
+ }
215
+ //#endregion
216
+ //#region src/server/domains/cross-domain/handlers/syscall-js-correlator.ts
217
+ /**
218
+ * Patterns mapping syscall names to JS API patterns for confidence scoring.
219
+ * If the JS function name matches a pattern associated with a syscall, confidence is higher.
220
+ */
221
+ const SYSCALL_JS_PATTERNS = {
222
+ NtReadFile: /read|fs[_.]read/i,
223
+ NtWriteFile: /write|fs[_.]write/i,
224
+ NtOpenFile: /open|fs[_.]open/i,
225
+ NtCreateFile: /create|fs[_.]create/i,
226
+ NtClose: /close|fs[_.]close/i,
227
+ NtDeviceIoControlFile: /ioctl|device/i,
228
+ NtQueryInformationFile: /stat|info|query/i,
229
+ NtSetInformationFile: /set|chmod|chown/i
230
+ };
231
+ function scoreConfidence(syscallName, functionName) {
232
+ const pattern = SYSCALL_JS_PATTERNS[syscallName];
233
+ if (pattern && pattern.test(functionName)) return "high";
234
+ if (/file|fs|read|write|open|close/i.test(functionName)) return "medium";
235
+ return "low";
236
+ }
237
+ function correlateSyscallToJS(bridge, syscallEvents, jsStacks) {
238
+ const graphNodeIds = [];
239
+ const correlations = [];
240
+ const unmatchedSyscalls = [];
241
+ if (syscallEvents.length === 0) return {
242
+ syscalls: 0,
243
+ correlations: [],
244
+ unmatchedSyscalls: [],
245
+ correlationConfidence: 0,
246
+ graphNodeIds: []
247
+ };
248
+ for (const event of syscallEvents) {
249
+ const syscallNode = bridge.addSyscallEvent({
250
+ pid: event.pid,
251
+ tid: event.tid,
252
+ syscallName: event.syscallName,
253
+ timestamp: event.timestamp
254
+ });
255
+ graphNodeIds.push(syscallNode.id);
256
+ const matchingStack = jsStacks.find((stack) => stack.threadId === event.tid && stack.timestamp === event.timestamp);
257
+ if (matchingStack && matchingStack.frames.length > 0) {
258
+ const topFrame = matchingStack.frames[0];
259
+ if (topFrame) {
260
+ const functionName = topFrame.functionName;
261
+ const confidence = scoreConfidence(event.syscallName, functionName);
262
+ const funcNode = bridge.addNode("function", functionName, {
263
+ domain: "v8-inspector",
264
+ functionName,
265
+ threadId: event.tid
266
+ });
267
+ graphNodeIds.push(funcNode.id);
268
+ bridge.getGraph().addEdge(funcNode.id, syscallNode.id, "syscall-emitted-by", {
269
+ domain: "cross-domain",
270
+ confidence
271
+ });
272
+ correlations.push({
273
+ syscallName: event.syscallName,
274
+ topJsFunction: functionName,
275
+ threadId: event.tid,
276
+ timestamp: event.timestamp,
277
+ confidence
278
+ });
279
+ } else unmatchedSyscalls.push({
280
+ syscallName: event.syscallName,
281
+ tid: event.tid
282
+ });
283
+ } else unmatchedSyscalls.push({
284
+ syscallName: event.syscallName,
285
+ tid: event.tid
286
+ });
287
+ }
288
+ const correlationConfidence = syscallEvents.length === 0 ? 0 : correlations.length / syscallEvents.length;
289
+ return {
290
+ syscalls: syscallEvents.length,
291
+ correlations,
292
+ unmatchedSyscalls,
293
+ correlationConfidence,
294
+ graphNodeIds
295
+ };
296
+ }
297
+ //#endregion
298
+ //#region src/server/domains/cross-domain/handlers/binary-to-js-pipeline.ts
299
+ /** Patterns that identify functions callable from JS or exported for JS use. */
300
+ const JS_CALLABLE_PATTERNS = [
301
+ /^native_/i,
302
+ /^JS_/i,
303
+ /^Java_/i
304
+ ];
305
+ function isJSCallable(func) {
306
+ if (func.calledFrom && func.calledFrom.length > 0) return true;
307
+ return JS_CALLABLE_PATTERNS.some((pattern) => pattern.test(func.name));
308
+ }
309
+ function generateFridaHookCode(functions, moduleName) {
310
+ const lines = [];
311
+ lines.push("// Binary-to-JS Hook Script");
312
+ lines.push(`// Module: ${moduleName}`);
313
+ lines.push(`// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}`);
314
+ lines.push("");
315
+ for (const func of functions) {
316
+ const resolvedModule = func.moduleName || moduleName;
317
+ if (func.address) {
318
+ lines.push(`// Hook: ${func.name} at ${func.address} in ${resolvedModule}`);
319
+ lines.push(`Interceptor.attach(Module.findBaseAddress('${resolvedModule}').add(${func.address}), {`);
320
+ } else {
321
+ lines.push(`// Hook: ${func.name} in ${resolvedModule}`);
322
+ lines.push(`Interceptor.attach(Module.findExportByName('${resolvedModule}', '${func.name}'), {`);
323
+ }
324
+ lines.push(` onEnter(args) {`);
325
+ lines.push(` console.log('[${func.name}] called with args:', args[0], args[1]);`);
326
+ lines.push(` },`);
327
+ lines.push(` onLeave(retval) {`);
328
+ lines.push(` console.log('[${func.name}] returned:', retval);`);
329
+ lines.push(` }`);
330
+ lines.push(`});`);
331
+ lines.push("");
332
+ }
333
+ lines.push(`console.log('Binary-to-JS hook script loaded for ${moduleName}');`);
334
+ return lines.join("\n");
335
+ }
336
+ function buildBinaryToJSPipeline(bridge, ghidraOutput, forcedFunctions) {
337
+ const evidenceGraphLinks = [];
338
+ const injectedFunctions = [];
339
+ let selectedFunctions;
340
+ if (forcedFunctions && forcedFunctions.length > 0) {
341
+ const forcedSet = new Set(forcedFunctions);
342
+ selectedFunctions = ghidraOutput.functions.filter((f) => forcedSet.has(f.name));
343
+ } else selectedFunctions = ghidraOutput.functions.filter(isJSCallable);
344
+ const generatedHookScript = generateFridaHookCode(selectedFunctions, ghidraOutput.moduleName);
345
+ for (const func of selectedFunctions) {
346
+ const symbolNode = bridge.addBinarySymbol({
347
+ moduleName: func.moduleName || ghidraOutput.moduleName,
348
+ symbolName: func.name,
349
+ address: func.address ?? "0x0"
350
+ });
351
+ const hookNode = bridge.addNode("breakpoint-hook", `frida:${func.name}`, {
352
+ domain: "binary-instrument",
353
+ hookType: "frida-interceptor",
354
+ functionName: func.name,
355
+ moduleName: func.moduleName || ghidraOutput.moduleName
356
+ });
357
+ bridge.getGraph().addEdge(symbolNode.id, hookNode.id, "binary-exports", {
358
+ domain: "cross-domain",
359
+ relation: "binary-to-frida-hook"
360
+ });
361
+ evidenceGraphLinks.push({
362
+ binarySymbolNodeId: symbolNode.id,
363
+ hookScriptNodeId: hookNode.id,
364
+ functionName: func.name
365
+ });
366
+ injectedFunctions.push(func.name);
367
+ }
368
+ return {
369
+ hookCount: selectedFunctions.length,
370
+ generatedHookScript,
371
+ injectedFunctions,
372
+ evidenceGraphLinks
373
+ };
374
+ }
375
+ //#endregion
376
+ //#region src/server/domains/cross-domain/workflows/missions.ts
377
+ const WORKFLOWS = {
378
+ WORKFLOW_REVERSE_OBFUSCATED: {
379
+ id: "reverse-obfuscated-api",
380
+ displayName: "Reverse Obfuscated API",
381
+ steps: [
382
+ {
383
+ tool: "deobfuscate",
384
+ args: { targetUrl: "${input.targetUrl}" }
385
+ },
386
+ {
387
+ tool: "js_heap_search",
388
+ args: { query: "${previous.cryptoKeys}" }
389
+ },
390
+ {
391
+ tool: "network_enable",
392
+ args: {}
393
+ },
394
+ {
395
+ tool: "tls_cert_pin_bypass",
396
+ args: { target: "${input.target}" }
397
+ },
398
+ {
399
+ tool: "console_inject_fetch_interceptor",
400
+ args: { urls: ["${input.apiEndpoint}"] }
401
+ }
402
+ ]
403
+ },
404
+ WORKFLOW_GAME_CANVAS_SKIA: {
405
+ id: "game-canvas-skia-v8",
406
+ displayName: "Game Canvas + SKIA + V8 Analysis",
407
+ steps: [
408
+ {
409
+ tool: "canvas_engine_fingerprint",
410
+ args: { canvasId: "${input.canvasId}" }
411
+ },
412
+ {
413
+ tool: "canvas_scene_dump",
414
+ args: { canvasId: "${input.canvasId}" }
415
+ },
416
+ {
417
+ tool: "skia_correlate_objects",
418
+ args: { skiaNodeIds: "${previous.nodeIds}" }
419
+ },
420
+ {
421
+ tool: "performance_take_heap_snapshot",
422
+ args: {}
423
+ },
424
+ {
425
+ tool: "js_heap_search",
426
+ args: { query: "${input.searchTerm}" }
427
+ }
428
+ ]
429
+ },
430
+ WORKFLOW_BINARY_NATIVE_HOOK: {
431
+ id: "binary-native-hook",
432
+ displayName: "Binary Analysis + Native Hook",
433
+ steps: [
434
+ {
435
+ tool: "ghidra_analyze",
436
+ args: { binaryPath: "${input.binaryPath}" }
437
+ },
438
+ {
439
+ tool: "generate_hooks",
440
+ args: { symbols: "${previous.exportedSymbols}" }
441
+ },
442
+ {
443
+ tool: "frida_attach",
444
+ args: { target: "${input.target}" }
445
+ },
446
+ {
447
+ tool: "frida_run_script",
448
+ args: { script: "${previous.hookScript}" }
449
+ }
450
+ ]
451
+ }
452
+ };
453
+ //#endregion
454
+ //#region src/server/domains/cross-domain/handlers.impl.ts
455
+ function isRecord(value) {
456
+ return value !== null && typeof value === "object";
457
+ }
458
+ function extractSkiaSceneTree(value) {
459
+ if (!isRecord(value)) return {
460
+ layers: [],
461
+ drawCommands: []
462
+ };
463
+ return {
464
+ layers: Array.isArray(value["layers"]) ? value["layers"] : [],
465
+ drawCommands: Array.isArray(value["drawCommands"]) ? value["drawCommands"] : []
466
+ };
467
+ }
468
+ function extractJSObjectArray(value) {
469
+ if (!Array.isArray(value)) return [];
470
+ return value.filter(isRecord).map((item) => ({
471
+ objectId: typeof item["objectId"] === "string" ? item["objectId"] : "",
472
+ className: typeof item["className"] === "string" ? item["className"] : "",
473
+ name: typeof item["name"] === "string" ? item["name"] : "",
474
+ stringProps: Array.isArray(item["stringProps"]) ? item["stringProps"].filter((s) => typeof s === "string") : [],
475
+ numericProps: isRecord(item["numericProps"]) ? Object.fromEntries(Object.entries(item["numericProps"]).filter((entry) => typeof entry[1] === "number")) : {},
476
+ colorProps: Array.isArray(item["colorProps"]) ? item["colorProps"].filter((s) => typeof s === "string") : [],
477
+ urlProps: Array.isArray(item["urlProps"]) ? item["urlProps"].filter((s) => typeof s === "string") : []
478
+ }));
479
+ }
480
+ function extractMojoMessages(value) {
481
+ if (!Array.isArray(value)) return [];
482
+ return value.filter(isRecord).map((item) => ({
483
+ interface: typeof item["interface"] === "string" ? item["interface"] : "",
484
+ method: typeof item["method"] === "string" ? item["method"] : "",
485
+ timestamp: typeof item["timestamp"] === "number" ? item["timestamp"] : 0,
486
+ messageId: typeof item["messageId"] === "string" ? item["messageId"] : ""
487
+ }));
488
+ }
489
+ function extractCDPEvents(value) {
490
+ if (!Array.isArray(value)) return [];
491
+ return value.filter(isRecord).map((item) => ({
492
+ eventType: typeof item["eventType"] === "string" ? item["eventType"] : "",
493
+ timestamp: typeof item["timestamp"] === "number" ? item["timestamp"] : 0,
494
+ url: typeof item["url"] === "string" ? item["url"] : void 0
495
+ }));
496
+ }
497
+ function extractNetworkRequests(value) {
498
+ if (!Array.isArray(value)) return [];
499
+ return value.filter(isRecord).map((item) => ({
500
+ requestId: typeof item["requestId"] === "string" ? item["requestId"] : "",
501
+ url: typeof item["url"] === "string" ? item["url"] : "",
502
+ timestamp: typeof item["timestamp"] === "number" ? item["timestamp"] : 0
503
+ }));
504
+ }
505
+ function extractSyscallEvents(value) {
506
+ if (!Array.isArray(value)) return [];
507
+ return value.filter(isRecord).map((item) => ({
508
+ pid: typeof item["pid"] === "number" ? item["pid"] : 0,
509
+ tid: typeof item["tid"] === "number" ? item["tid"] : 0,
510
+ syscallName: typeof item["syscallName"] === "string" ? item["syscallName"] : "",
511
+ timestamp: typeof item["timestamp"] === "number" ? item["timestamp"] : 0
512
+ }));
513
+ }
514
+ function extractJSStacks(value) {
515
+ if (!Array.isArray(value)) return [];
516
+ return value.filter(isRecord).map((item) => {
517
+ const frames = Array.isArray(item["frames"]) ? item["frames"].filter(isRecord).map((f) => ({ functionName: typeof f["functionName"] === "string" ? f["functionName"] : "" })) : [];
518
+ return {
519
+ threadId: typeof item["threadId"] === "number" ? item["threadId"] : 0,
520
+ timestamp: typeof item["timestamp"] === "number" ? item["timestamp"] : 0,
521
+ frames
522
+ };
523
+ });
524
+ }
525
+ function extractGhidraOutput(value) {
526
+ if (!isRecord(value)) return null;
527
+ const moduleName = typeof value["moduleName"] === "string" ? value["moduleName"] : "";
528
+ if (!moduleName) return null;
529
+ return {
530
+ functions: (Array.isArray(value["functions"]) ? value["functions"] : []).filter(isRecord).map((item) => ({
531
+ name: typeof item["name"] === "string" ? item["name"] : "",
532
+ moduleName: typeof item["moduleName"] === "string" ? item["moduleName"] : "",
533
+ address: typeof item["address"] === "string" ? item["address"] : void 0,
534
+ calledFrom: Array.isArray(item["calledFrom"]) ? item["calledFrom"].filter((c) => typeof c === "string") : void 0
535
+ })),
536
+ moduleName
537
+ };
538
+ }
539
+ const V5_DOMAIN_NAMES = [
540
+ "analysis",
541
+ "browser",
542
+ "network",
543
+ "canvas",
544
+ "skia-capture",
545
+ "v8-inspector",
546
+ "mojo-ipc",
547
+ "syscall-hook",
548
+ "binary-instrument",
549
+ "boringssl-inspector",
550
+ "evidence"
551
+ ];
552
+ var CrossDomainWorkflowClassifier = class {
553
+ constructor(ctx, evidenceBridgeReady) {
554
+ this.ctx = ctx;
555
+ this.evidenceBridgeReady = evidenceBridgeReady;
556
+ }
557
+ getCapabilities() {
558
+ const availableDomains = this.getAvailableDomains();
559
+ const missingDomains = V5_DOMAIN_NAMES.filter((d) => !availableDomains.includes(d));
560
+ const workflows = Object.entries(WORKFLOWS).map(([workflowKey, workflow]) => {
561
+ const evaluation = this.evaluateWorkflow(workflow);
562
+ return {
563
+ workflowKey,
564
+ id: workflow.id,
565
+ displayName: workflow.displayName,
566
+ stepCount: workflow.steps.length,
567
+ ...evaluation
568
+ };
569
+ });
570
+ return {
571
+ availableDomains,
572
+ missingDomains,
573
+ supportedDomains: [...V5_DOMAIN_NAMES],
574
+ workflows
575
+ };
576
+ }
577
+ suggestWorkflow(goal, preferAvailableOnly) {
578
+ const normalizedGoal = goal.toLowerCase();
579
+ const scored = Object.entries(WORKFLOWS).map(([workflowKey, workflow]) => {
580
+ return {
581
+ workflowKey,
582
+ workflow,
583
+ keywordScore: this.scoreWorkflowGoal(normalizedGoal, workflowKey, workflow),
584
+ evaluation: this.evaluateWorkflow(workflow)
585
+ };
586
+ });
587
+ const candidates = preferAvailableOnly ? scored.filter((item) => item.evaluation.missingDomains.length === 0) : scored;
588
+ const rankedPool = candidates.length > 0 ? candidates : scored;
589
+ rankedPool.sort((a, b) => {
590
+ if (b.keywordScore !== a.keywordScore) return b.keywordScore - a.keywordScore;
591
+ return b.evaluation.coverage - a.evaluation.coverage;
592
+ });
593
+ const selected = rankedPool[0];
594
+ if (!selected) throw new Error("No workflow definitions are available for cross-domain suggestion");
595
+ const reason = this.describeWorkflowReason(normalizedGoal, selected.evaluation);
596
+ return {
597
+ workflowKey: selected.workflowKey,
598
+ id: selected.workflow.id,
599
+ displayName: selected.workflow.displayName,
600
+ reason,
601
+ ...selected.evaluation
602
+ };
603
+ }
604
+ getHealth() {
605
+ const availableDomains = this.getAvailableDomains();
606
+ return {
607
+ evidenceBridgeReady: this.evidenceBridgeReady,
608
+ orchestratorReady: true,
609
+ availableDomains,
610
+ missingDomains: V5_DOMAIN_NAMES.filter((d) => !availableDomains.includes(d))
611
+ };
612
+ }
613
+ getAvailableDomains() {
614
+ const currentEnabledDomains = this.ctx.enabledDomains.size > 0 ? this.ctx.enabledDomains : this.ctx.resolveEnabledDomains(this.ctx.selectedTools);
615
+ const available = [];
616
+ for (const d of V5_DOMAIN_NAMES) if (currentEnabledDomains.has(d)) available.push(d);
617
+ return available;
618
+ }
619
+ evaluateWorkflow(workflow) {
620
+ const requiredSet = /* @__PURE__ */ new Set();
621
+ for (const step of workflow.steps) for (const d of this.inferDomainsForTool(step.tool)) requiredSet.add(d);
622
+ const requiredDomains = [...requiredSet];
623
+ const available = this.getAvailableDomains().filter((d) => requiredSet.has(d));
624
+ return {
625
+ requiredDomains,
626
+ availableDomains: available,
627
+ missingDomains: requiredDomains.filter((d) => !available.includes(d)),
628
+ coverage: requiredDomains.length === 0 ? 1 : available.length / requiredDomains.length
629
+ };
630
+ }
631
+ inferDomainsForTool(toolName) {
632
+ if (toolName.startsWith("deobfuscate") || toolName.startsWith("advanced_deobfuscate")) return ["analysis"];
633
+ if (toolName.startsWith("js_heap") || toolName.startsWith("performance_take_heap_snapshot")) return ["v8-inspector"];
634
+ if (toolName.startsWith("network_")) return ["network"];
635
+ if (toolName.startsWith("console_")) return ["browser"];
636
+ if (toolName.startsWith("tls_") || toolName.startsWith("net_raw_")) return ["boringssl-inspector"];
637
+ if (toolName.startsWith("canvas_")) return ["canvas"];
638
+ if (toolName.startsWith("skia_")) return ["skia-capture"];
639
+ if (toolName.startsWith("v8_")) return ["v8-inspector"];
640
+ if (toolName.startsWith("mojo_")) return ["mojo-ipc"];
641
+ if (toolName.startsWith("syscall_")) return ["syscall-hook"];
642
+ if (toolName.startsWith("adb_")) return ["adb-bridge"];
643
+ if (toolName.startsWith("ghidra_") || toolName.startsWith("frida_") || toolName.startsWith("generate_hooks") || toolName.startsWith("unidbg_") || toolName.startsWith("export_hook_script")) return ["binary-instrument"];
644
+ if (toolName.startsWith("extension_") || toolName.startsWith("webhook_")) return ["extension-registry"];
645
+ if (toolName.startsWith("cross_domain_")) return ["cross-domain"];
646
+ if (toolName.startsWith("evidence_")) return ["evidence"];
647
+ if (toolName.startsWith("boringssl_")) return ["boringssl-inspector"];
648
+ return [];
649
+ }
650
+ scoreWorkflowGoal(normalizedGoal, workflowKey, workflow) {
651
+ let score = 0;
652
+ if (workflowKey === "WORKFLOW_REVERSE_OBFUSCATED") {
653
+ if (normalizedGoal.includes("obfus") || normalizedGoal.includes("api")) score += 3;
654
+ if (normalizedGoal.includes("tls") || normalizedGoal.includes("pin")) score += 2;
655
+ }
656
+ if (workflowKey === "WORKFLOW_GAME_CANVAS_SKIA") {
657
+ if (normalizedGoal.includes("canvas") || normalizedGoal.includes("game")) score += 3;
658
+ if (normalizedGoal.includes("skia") || normalizedGoal.includes("scene")) score += 2;
659
+ }
660
+ if (workflowKey === "WORKFLOW_BINARY_NATIVE_HOOK") {
661
+ if (normalizedGoal.includes("binary") || normalizedGoal.includes("native")) score += 3;
662
+ if (normalizedGoal.includes("hook") || normalizedGoal.includes("frida")) score += 2;
663
+ }
664
+ if (score === 0 && workflow.displayName.toLowerCase().includes(normalizedGoal)) score += 1;
665
+ return score;
666
+ }
667
+ describeWorkflowReason(normalizedGoal, evaluation) {
668
+ if (evaluation.missingDomains.length === 0) return `Matched goal "${normalizedGoal}" and all required domains are enabled.`;
669
+ return `Matched goal "${normalizedGoal}" with ${Math.round(evaluation.coverage * 100)}% domain coverage. Missing: ${evaluation.missingDomains.join(", ")}.`;
670
+ }
671
+ };
672
+ var CrossDomainHandlers = class {
673
+ constructor(evidenceBridge, workflowClassifier) {
674
+ this.evidenceBridge = evidenceBridge;
675
+ this.workflowClassifier = workflowClassifier;
676
+ }
677
+ async handleCapabilities(_args) {
678
+ const capabilities = {
679
+ evidenceGraphAvailable: true,
680
+ workflowClassifierAvailable: this.workflowClassifier !== void 0
681
+ };
682
+ if (this.workflowClassifier) return asJsonResponse({
683
+ capabilities,
684
+ ...this.workflowClassifier.getCapabilities()
685
+ });
686
+ return asJsonResponse({ capabilities });
687
+ }
688
+ async handleSuggestWorkflow(args) {
689
+ const query = argString(args, "query", "") || argString(args, "goal", "");
690
+ const preferAvailableOnly = argBool(args, "preferAvailableOnly", true);
691
+ if (this.workflowClassifier && query) return asJsonResponse(this.workflowClassifier.suggestWorkflow(query, preferAvailableOnly));
692
+ return asJsonResponse({ message: "Cross-domain workflow suggestion requires a classifier and query." });
693
+ }
694
+ async handleHealth() {
695
+ const stats = this.evidenceBridge.getStats();
696
+ if (this.workflowClassifier) return asJsonResponse({
697
+ ...this.workflowClassifier.getHealth(),
698
+ evidenceGraph: stats
699
+ });
700
+ return asJsonResponse({
701
+ evidenceBridgeReady: true,
702
+ orchestratorReady: false,
703
+ evidenceGraph: stats
704
+ });
705
+ }
706
+ async handleCorrelateAll(args) {
707
+ const errors = [];
708
+ const results = {};
709
+ try {
710
+ const sceneTree = extractSkiaSceneTree(args["sceneTree"]);
711
+ const jsObjects = extractJSObjectArray(args["jsObjects"]);
712
+ results["skia"] = correlateSkiaToJS(this.evidenceBridge, {
713
+ sceneTree,
714
+ jsObjects
715
+ });
716
+ } catch (e) {
717
+ errors.push(`SKIA-03: ${e instanceof Error ? e.message : String(e)}`);
718
+ }
719
+ try {
720
+ const mojoMessages = extractMojoMessages(args["mojoMessages"]);
721
+ const cdpEvents = extractCDPEvents(args["cdpEvents"]);
722
+ const networkRequests = extractNetworkRequests(args["networkRequests"]);
723
+ results["mojo"] = correlateMojoToCDP(this.evidenceBridge, mojoMessages, cdpEvents, networkRequests);
724
+ } catch (e) {
725
+ errors.push(`MOJO-03: ${e instanceof Error ? e.message : String(e)}`);
726
+ }
727
+ try {
728
+ const syscallEvents = extractSyscallEvents(args["syscallEvents"]);
729
+ const jsStacks = extractJSStacks(args["jsStacks"]);
730
+ results["syscall"] = correlateSyscallToJS(this.evidenceBridge, syscallEvents, jsStacks);
731
+ } catch (e) {
732
+ errors.push(`SYSCALL-02: ${e instanceof Error ? e.message : String(e)}`);
733
+ }
734
+ try {
735
+ const ghidraOutput = extractGhidraOutput(args["ghidraOutput"]);
736
+ if (ghidraOutput) results["binary"] = buildBinaryToJSPipeline(this.evidenceBridge, ghidraOutput);
737
+ } catch (e) {
738
+ errors.push(`BIN-04: ${e instanceof Error ? e.message : String(e)}`);
739
+ }
740
+ const snapshot = this.evidenceBridge.exportGraph();
741
+ return asJsonResponse({
742
+ correlationResults: {
743
+ ...results,
744
+ errors
745
+ },
746
+ evidenceGraph: snapshot
747
+ });
748
+ }
749
+ async handleEvidenceExport() {
750
+ return asJsonResponse(this.evidenceBridge.exportGraph());
751
+ }
752
+ async handleEvidenceStats() {
753
+ return asJsonResponse(this.evidenceBridge.getStats());
754
+ }
755
+ };
756
+ //#endregion
757
+ export { CrossDomainHandlers, CrossDomainWorkflowClassifier };