@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.
- package/README.md +36 -5
- package/README.zh.md +36 -5
- package/dist/{AntiCheatDetector-S8VRj-dD.mjs → AntiCheatDetector-CqGDXmfc.mjs} +160 -54
- package/dist/{CodeInjector-4Z3ngPoX.mjs → CodeInjector-BdjRfNx7.mjs} +5 -5
- package/dist/ConsoleMonitor-DykL3IAw.mjs +2269 -0
- package/dist/{DarwinAPI-B8hg_yhz.mjs → DarwinAPI-ETyy0xyo.mjs} +1 -1
- package/dist/DetailedDataManager-HT49OrvF.mjs +217 -0
- package/dist/EventBus-DFKvADm3.mjs +141 -0
- package/dist/EvidenceGraphBridge-318Oi0Lf.mjs +153 -0
- package/dist/{ExtensionManager-D5-bO9D8.mjs → ExtensionManager-BDMsY2Dz.mjs} +27 -13
- package/dist/{FingerprintManager-BVxFJL2-.mjs → FingerprintManager-BN4UQWnX.mjs} +1 -1
- package/dist/{HardwareBreakpoint-DK1yjWkV.mjs → HardwareBreakpoint-Cc2AFq1Y.mjs} +3 -3
- package/dist/{HeapAnalyzer-CEbo10xU.mjs → HeapAnalyzer-DruMgsgj.mjs} +21 -21
- package/dist/HookGeneratorBuilders.core.generators.storage-CTbB4Lcx.mjs +566 -0
- package/dist/InstrumentationSession-DLH0vd-z.mjs +244 -0
- package/dist/{MemoryController-DdtnBdD4.mjs → MemoryController-CMtviNW_.mjs} +3 -3
- package/dist/{MemoryScanSession-RMixN3bX.mjs → MemoryScanSession-ITgb_NMi.mjs} +81 -78
- package/dist/{MemoryScanner-QjK4ld0B.mjs → MemoryScanner-CiL7Z3ey.mjs} +50 -21
- package/dist/{NativeMemoryManager.impl-CB6gJ0NM.mjs → NativeMemoryManager.impl-D9Lkovvn.mjs} +20 -56
- package/dist/{NativeMemoryManager.utils-BML4q1ry.mjs → NativeMemoryManager.utils-BBlAixF5.mjs} +1 -1
- package/dist/{PEAnalyzer-CK0xe0Fs.mjs → PEAnalyzer-DMQ44gen.mjs} +16 -16
- package/dist/PageController-BPJNqqBN.mjs +431 -0
- package/dist/{PointerChainEngine-Cd73qu5b.mjs → PointerChainEngine-K7wN8Z-w.mjs} +10 -7
- package/dist/PrerequisiteError-TuyZIs6n.mjs +20 -0
- package/dist/ProcessRegistry-zGg12QbE.mjs +74 -0
- package/dist/ResponseBuilder-CJXWmWNw.mjs +143 -0
- package/dist/ReverseEvidenceGraph-C02-gXOh.mjs +269 -0
- package/dist/ScriptManager-ZuWD-0Jg.mjs +3003 -0
- package/dist/{Speedhack-CeF0XmEz.mjs → Speedhack-D-z0umeT.mjs} +2 -2
- package/dist/{StructureAnalyzer-D4GkMduU.mjs → StructureAnalyzer-Cav5AVSL.mjs} +9 -6
- package/dist/ToolCatalog-5OJdMiF0.mjs +582 -0
- package/dist/ToolError-jh9whhMd.mjs +15 -0
- package/dist/ToolProbe-DbCFGyrg.mjs +45 -0
- package/dist/ToolRegistry-B9krbTtI.mjs +180 -0
- package/dist/ToolRouter.policy-BGDAGyeH.mjs +344 -0
- package/dist/TraceRecorder-B41Z5XBj.mjs +1286 -0
- package/dist/{Win32API-Bc0QnQsN.mjs → Win32API-C2kjj0ze.mjs} +19 -13
- package/dist/{Win32Debug-DUHt9XUn.mjs → Win32Debug-CKrGOTpo.mjs} +3 -3
- package/dist/WorkflowEngine-DJ6M4opp.mjs +569 -0
- package/dist/analysis-BHeJW2Nb.mjs +1234 -0
- package/dist/antidebug-BRKeyt27.mjs +1081 -0
- package/dist/artifactRetention-CPXkUJXp.mjs +598 -0
- package/dist/artifacts-DkfosXH3.mjs +59 -0
- package/dist/authorization-schema-DRqyJMSk.mjs +31 -0
- package/dist/betterSqlite3-DLSBZodi.mjs +74 -0
- package/dist/binary-instrument--V3MAhJ4.mjs +971 -0
- package/dist/bind-helpers-ClV34xdn.mjs +42 -0
- package/dist/boringssl-inspector-Bo_LOLaS.mjs +180 -0
- package/dist/browser-Dx3_S2cG.mjs +4369 -0
- package/dist/capabilities-CcHlvWgK.mjs +33 -0
- package/dist/concurrency-Drev_Vz9.mjs +41 -0
- package/dist/{constants-CCvsN80K.mjs → constants-CDZLOoVv.mjs} +105 -48
- package/dist/coordination-DgItD9DL.mjs +259 -0
- package/dist/debugger-RS3RSAqs.mjs +1288 -0
- package/dist/definitions-BEoYofW5.mjs +47 -0
- package/dist/definitions-BRaefg3u.mjs +365 -0
- package/dist/definitions-BbkvZkiv.mjs +96 -0
- package/dist/definitions-BtWSHJ3o.mjs +17 -0
- package/dist/definitions-C1gCHO0i.mjs +43 -0
- package/dist/definitions-CDOg_b-l.mjs +138 -0
- package/dist/definitions-CVPD9hzZ.mjs +54 -0
- package/dist/definitions-Cea8Lgl7.mjs +94 -0
- package/dist/definitions-DAgIyjxM.mjs +10 -0
- package/dist/definitions-DJA27nsL.mjs +66 -0
- package/dist/definitions-DKPFU3LW.mjs +25 -0
- package/dist/definitions-DPRpZQ96.mjs +47 -0
- package/dist/definitions-DUE5gmdn.mjs +18 -0
- package/dist/definitions-DYVjOtxa.mjs +26 -0
- package/dist/definitions-DcYLVLCo.mjs +37 -0
- package/dist/definitions-Pp5LI2H4.mjs +27 -0
- package/dist/definitions-j9KdHVNR.mjs +14 -0
- package/dist/definitions-uzkjBwa7.mjs +258 -0
- package/dist/definitions-va-AnLuQ.mjs +28 -0
- package/dist/encoding-DJeqHmpd.mjs +1079 -0
- package/dist/evidence-graph-bridge-DcYizFk2.mjs +136 -0
- package/dist/{factory-CibqTNC8.mjs → factory-C90tBff6.mjs} +41 -56
- package/dist/flat-target-session-Dgax2Cy3.mjs +29 -0
- package/dist/graphql-CoHrhweh.mjs +1197 -0
- package/dist/handlers-4jmR0nMs.mjs +898 -0
- package/dist/handlers-BAHPxcch.mjs +789 -0
- package/dist/handlers-BOs9b907.mjs +2600 -0
- package/dist/handlers-BWXEy6ef.mjs +917 -0
- package/dist/handlers-Bndn6QvE.mjs +111 -0
- package/dist/handlers-BqC4bD4s.mjs +681 -0
- package/dist/handlers-BtYq60bM2.mjs +276 -0
- package/dist/handlers-BzgcB4iv.mjs +799 -0
- package/dist/handlers-CRyRWj2b.mjs +859 -0
- package/dist/handlers-CVv2H1uq.mjs +592 -0
- package/dist/handlers-Dl5a7JS4.mjs +572 -0
- package/dist/handlers-Dx2d7jt7.mjs +2537 -0
- package/dist/handlers-Dz9PYsCa.mjs +2805 -0
- package/dist/handlers-HujRKC3b.mjs +661 -0
- package/dist/handlers.impl-XWXkQfyi.mjs +807 -0
- package/dist/hooks-B1B8NRHL.mjs +898 -0
- package/dist/index.mjs +491 -259
- package/dist/{logger-BmWzC2lM.mjs → logger-Dh_xb7_2.mjs} +14 -6
- package/dist/maintenance-PRMkLVRW.mjs +835 -0
- package/dist/manifest-67Bok-Si.mjs +58 -0
- package/dist/manifest-6lNTMZAB2.mjs +87 -0
- package/dist/manifest-B2duEHiH.mjs +90 -0
- package/dist/manifest-B6EY9Vm8.mjs +57 -0
- package/dist/manifest-B6nKSbyY.mjs +95 -0
- package/dist/manifest-BL8AQNPF.mjs +106 -0
- package/dist/manifest-BSZvJJmV.mjs +47 -0
- package/dist/manifest-BU7qzUyX.mjs +418 -0
- package/dist/manifest-Bl62e8WK.mjs +49 -0
- package/dist/manifest-Bo5cXjdt.mjs +82 -0
- package/dist/manifest-BpS4gtUK.mjs +1347 -0
- package/dist/manifest-Bv65_e2W.mjs +101 -0
- package/dist/manifest-BytNIF4Z.mjs +117 -0
- package/dist/manifest-C-xtsjS3.mjs +81 -0
- package/dist/manifest-CDYl7OhA.mjs +66 -0
- package/dist/manifest-CRZ3xmkD.mjs +61 -0
- package/dist/manifest-CoW6u4Tp.mjs +132 -0
- package/dist/manifest-Cq5zN_8A.mjs +50 -0
- package/dist/manifest-D7YZM_2e.mjs +194 -0
- package/dist/manifest-DE_VrAeQ.mjs +314 -0
- package/dist/manifest-DGsXSCpT.mjs +39 -0
- package/dist/manifest-DJ2vfEuW.mjs +156 -0
- package/dist/manifest-DPXDYhEu.mjs +80 -0
- package/dist/manifest-Dd4fQb0a.mjs +322 -0
- package/dist/manifest-Deq6opGg.mjs +223 -0
- package/dist/manifest-DfJTafJK.mjs +37 -0
- package/dist/manifest-DgOdgN_j.mjs +50 -0
- package/dist/manifest-DlbMW4v4.mjs +47 -0
- package/dist/manifest-DmVfbH0w.mjs +374 -0
- package/dist/manifest-Dog6Ddjr.mjs +109 -0
- package/dist/manifest-DvgU5FWb.mjs +58 -0
- package/dist/manifest-HsfDBs7j.mjs +50 -0
- package/dist/manifest-I8oQHvCG.mjs +186 -0
- package/dist/manifest-NvH_a-av.mjs +786 -0
- package/dist/manifest-cEJU1v0Z.mjs +129 -0
- package/dist/manifest-wOl5XLB12.mjs +112 -0
- package/dist/modules-tZozf0LQ.mjs +10635 -0
- package/dist/mojo-ipc-DXNEXEqb.mjs +640 -0
- package/dist/network-CPVvwvFg.mjs +3852 -0
- package/dist/{artifacts-BbdOMET5.mjs → outputPaths-um7lCRY3.mjs} +219 -216
- package/dist/parse-args-B4cY5Vx5.mjs +39 -0
- package/dist/platform-CYeFoTWp.mjs +2161 -0
- package/dist/process-BTbgcVc6.mjs +1306 -0
- package/dist/proxy-r8YN6nP1.mjs +192 -0
- package/dist/registry-Bl8ZQW61.mjs +34 -0
- package/dist/response-CWhh2aLo.mjs +34 -0
- package/dist/server/plugin-api.mjs +2 -2
- package/dist/shared-state-board-BoZnSoj-.mjs +586 -0
- package/dist/sourcemap-BIDHUVXy.mjs +934 -0
- package/dist/ssrf-policy-Dsqd-DTX.mjs +166 -0
- package/dist/streaming-Dal6utPp.mjs +725 -0
- package/dist/tool-builder-BHJp32mV.mjs +186 -0
- package/dist/transform-DRVgGG90.mjs +1011 -0
- package/dist/types-Bx92KJfT.mjs +4 -0
- package/dist/wasm-BYx5UOeG.mjs +1044 -0
- package/dist/webcrack-Be0_FccV.mjs +747 -0
- package/dist/workflow-BpuKEtvn.mjs +725 -0
- package/package.json +82 -49
- package/dist/ExtensionManager-CPTJhHFg.mjs +0 -2
- package/dist/ToolCatalog-Bq4V2sbJ.mjs +0 -67201
- package/dist/{CacheAdapters-CzFNpD9a.mjs → CacheAdapters-jJFy20G-.mjs} +0 -0
- package/dist/{StealthVerifier-BzBCFiwx.mjs → StealthVerifier-BWmPgQsv.mjs} +0 -0
- package/dist/{VersionDetector-CNXcvD46.mjs → VersionDetector-K3V4vGsw.mjs} +0 -0
- package/dist/{formatAddress-ChCSIRWT.mjs → formatAddress-nnMvEohD.mjs} +0 -0
- package/dist/{types-BBjOqye-.mjs → types-DDBWs9UP.mjs} +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
//#region src/server/domains/cross-domain/handlers/evidence-graph-bridge.impl.ts
|
|
2
|
+
var CrossDomainEvidenceBridge = class {
|
|
3
|
+
graph;
|
|
4
|
+
constructor(graph) {
|
|
5
|
+
this.graph = graph;
|
|
6
|
+
}
|
|
7
|
+
getGraph() {
|
|
8
|
+
return this.graph;
|
|
9
|
+
}
|
|
10
|
+
addNode(type, label, metadata) {
|
|
11
|
+
return this.graph.addNode(type, label, metadata);
|
|
12
|
+
}
|
|
13
|
+
addV8Object(input, scriptNodeId) {
|
|
14
|
+
const node = this.graph.addNode("v8-heap-object", input.name, {
|
|
15
|
+
domain: "v8-inspector",
|
|
16
|
+
address: input.address,
|
|
17
|
+
name: input.name
|
|
18
|
+
});
|
|
19
|
+
if (scriptNodeId) this.graph.addEdge(scriptNodeId, node.id, "heap-allocates", {
|
|
20
|
+
domain: "cross-domain",
|
|
21
|
+
relation: "script-allocates-heap-object"
|
|
22
|
+
});
|
|
23
|
+
return node;
|
|
24
|
+
}
|
|
25
|
+
addNetworkRequest(input, initiatorHeapNodeId) {
|
|
26
|
+
const label = input.method ? `${input.method} ${input.url}` : input.url;
|
|
27
|
+
const node = this.graph.addNode("network-request", label, {
|
|
28
|
+
domain: "network",
|
|
29
|
+
requestId: input.requestId,
|
|
30
|
+
url: input.url,
|
|
31
|
+
method: input.method ?? "GET"
|
|
32
|
+
});
|
|
33
|
+
let initiatorNode;
|
|
34
|
+
if (initiatorHeapNodeId) {
|
|
35
|
+
initiatorNode = this.graph.getNode(initiatorHeapNodeId);
|
|
36
|
+
this.graph.addEdge(initiatorHeapNodeId, node.id, "network-initiated-by", {
|
|
37
|
+
domain: "cross-domain",
|
|
38
|
+
relation: "heap-initiates-network"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
node,
|
|
43
|
+
initiatorNode
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
addCanvasNode(input, creatorHeapNodeId) {
|
|
47
|
+
const node = this.graph.addNode("canvas-scene-node", input.label, {
|
|
48
|
+
domain: "canvas",
|
|
49
|
+
nodeId: input.nodeId,
|
|
50
|
+
label: input.label
|
|
51
|
+
});
|
|
52
|
+
if (creatorHeapNodeId) this.graph.addEdge(creatorHeapNodeId, node.id, "canvas-rendered-by", {
|
|
53
|
+
domain: "cross-domain",
|
|
54
|
+
relation: "heap-creates-canvas-node"
|
|
55
|
+
});
|
|
56
|
+
return node;
|
|
57
|
+
}
|
|
58
|
+
addSyscallEvent(input, jsFunctionNodeId) {
|
|
59
|
+
const node = this.graph.addNode("syscall-event", input.syscallName, {
|
|
60
|
+
domain: "syscall-hook",
|
|
61
|
+
pid: input.pid,
|
|
62
|
+
tid: input.tid,
|
|
63
|
+
syscallName: input.syscallName,
|
|
64
|
+
timestamp: input.timestamp
|
|
65
|
+
});
|
|
66
|
+
if (jsFunctionNodeId) this.graph.addEdge(jsFunctionNodeId, node.id, "syscall-emitted-by", {
|
|
67
|
+
domain: "cross-domain",
|
|
68
|
+
relation: "js-triggers-syscall"
|
|
69
|
+
});
|
|
70
|
+
return node;
|
|
71
|
+
}
|
|
72
|
+
addMojoMessage(input, cdpEventNodeId) {
|
|
73
|
+
const node = this.graph.addNode("mojo-message", `${input.interface}:${input.method}`, {
|
|
74
|
+
domain: "mojo-ipc",
|
|
75
|
+
interface: input.interface,
|
|
76
|
+
method: input.method,
|
|
77
|
+
timestamp: input.timestamp
|
|
78
|
+
});
|
|
79
|
+
if (cdpEventNodeId) this.graph.addEdge(cdpEventNodeId, node.id, "mojo-routed-to", {
|
|
80
|
+
domain: "cross-domain",
|
|
81
|
+
relation: "cdp-routes-to-mojo"
|
|
82
|
+
});
|
|
83
|
+
return node;
|
|
84
|
+
}
|
|
85
|
+
addBinarySymbol(input, jsFunctionNodeId) {
|
|
86
|
+
const node = this.graph.addNode("binary-symbol", input.symbolName, {
|
|
87
|
+
domain: "binary-instrument",
|
|
88
|
+
moduleName: input.moduleName,
|
|
89
|
+
symbolName: input.symbolName,
|
|
90
|
+
address: input.address
|
|
91
|
+
});
|
|
92
|
+
if (jsFunctionNodeId) this.graph.addEdge(jsFunctionNodeId, node.id, "binary-exports", {
|
|
93
|
+
domain: "cross-domain",
|
|
94
|
+
relation: "js-references-native-symbol"
|
|
95
|
+
});
|
|
96
|
+
return node;
|
|
97
|
+
}
|
|
98
|
+
queryByHeapAddress(addr) {
|
|
99
|
+
const snapshot = this.graph.exportJson();
|
|
100
|
+
const matchingIds = [];
|
|
101
|
+
for (const node of snapshot.nodes) {
|
|
102
|
+
const address = node.metadata["address"];
|
|
103
|
+
if (typeof address === "string" && address.includes(addr)) matchingIds.push(node.id);
|
|
104
|
+
}
|
|
105
|
+
return this.collectConnectedNodes(matchingIds);
|
|
106
|
+
}
|
|
107
|
+
queryByNetworkUrl(url) {
|
|
108
|
+
return this.graph.queryByUrl(url);
|
|
109
|
+
}
|
|
110
|
+
exportGraph() {
|
|
111
|
+
return this.graph.exportJson();
|
|
112
|
+
}
|
|
113
|
+
getStats() {
|
|
114
|
+
const snapshot = this.graph.exportJson();
|
|
115
|
+
const nodesByType = {};
|
|
116
|
+
for (const node of snapshot.nodes) {
|
|
117
|
+
const currentCount = nodesByType[node.type] ?? 0;
|
|
118
|
+
nodesByType[node.type] = currentCount + 1;
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
nodeCount: snapshot.nodes.length,
|
|
122
|
+
edgeCount: snapshot.edges.length,
|
|
123
|
+
nodesByType
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
collectConnectedNodes(nodeIds) {
|
|
127
|
+
const collected = /* @__PURE__ */ new Map();
|
|
128
|
+
for (const nodeId of nodeIds) {
|
|
129
|
+
for (const node of this.graph.getEvidenceChain(nodeId, "forward")) collected.set(node.id, node);
|
|
130
|
+
for (const node of this.graph.getEvidenceChain(nodeId, "backward")) collected.set(node.id, node);
|
|
131
|
+
}
|
|
132
|
+
return [...collected.values()];
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
//#endregion
|
|
136
|
+
export { CrossDomainEvidenceBridge };
|
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
|
|
2
|
-
import { _ as WriteProcessMemory, b as openProcessForMemory, d as ReadProcessMemory, f as VirtualAllocEx, h as VirtualQueryEx, i as GetModuleBaseName, l as MEM, m as VirtualProtectEx, n as EnumProcessModules, p as VirtualFreeEx, s as GetModuleInformation, t as CloseHandle, u as PAGE, v as isKoffiAvailable, y as isWindows } from "./Win32API-
|
|
3
|
-
import { _ as machVmReadOverwrite, a as VM_PROT, b as taskForPid, c as dyldImageCount, d as kernReturnName, f as machPortDeallocate, g as machVmProtect, h as machVmDeallocate, i as VM_FLAGS, l as isDarwin, m as machVmAllocate, n as KERN, o as dyldGetImageHeader, p as machTaskSelf, r as SM, s as dyldGetImageName, u as isKoffiAvailableOnDarwin, v as machVmRegion, y as machVmWrite } from "./DarwinAPI-
|
|
2
|
+
import { _ as WriteProcessMemory, b as openProcessForMemory, d as ReadProcessMemory, f as VirtualAllocEx, h as VirtualQueryEx, i as GetModuleBaseName, l as MEM, m as VirtualProtectEx, n as EnumProcessModules, p as VirtualFreeEx, s as GetModuleInformation, t as CloseHandle, u as PAGE, v as isKoffiAvailable, y as isWindows } from "./Win32API-C2kjj0ze.mjs";
|
|
3
|
+
import { _ as machVmReadOverwrite, a as VM_PROT, b as taskForPid, c as dyldImageCount, d as kernReturnName, f as machPortDeallocate, g as machVmProtect, h as machVmDeallocate, i as VM_FLAGS, l as isDarwin, m as machVmAllocate, n as KERN, o as dyldGetImageHeader, p as machTaskSelf, r as SM, s as dyldGetImageName, u as isKoffiAvailableOnDarwin, v as machVmRegion, y as machVmWrite } from "./DarwinAPI-ETyy0xyo.mjs";
|
|
4
4
|
import fs from "node:fs";
|
|
5
|
-
//#region src/native/platform/types.ts
|
|
6
|
-
/** Memory protection flags (platform-independent) */
|
|
7
|
-
let MemoryProtection = /* @__PURE__ */ function(MemoryProtection) {
|
|
8
|
-
MemoryProtection[MemoryProtection["NoAccess"] = 0] = "NoAccess";
|
|
9
|
-
MemoryProtection[MemoryProtection["Read"] = 1] = "Read";
|
|
10
|
-
MemoryProtection[MemoryProtection["Write"] = 2] = "Write";
|
|
11
|
-
MemoryProtection[MemoryProtection["Execute"] = 4] = "Execute";
|
|
12
|
-
MemoryProtection[MemoryProtection["ReadWrite"] = 3] = "ReadWrite";
|
|
13
|
-
MemoryProtection[MemoryProtection["ReadExecute"] = 5] = "ReadExecute";
|
|
14
|
-
MemoryProtection[MemoryProtection["ReadWriteExecute"] = 7] = "ReadWriteExecute";
|
|
15
|
-
MemoryProtection[MemoryProtection["Guard"] = 8] = "Guard";
|
|
16
|
-
MemoryProtection[MemoryProtection["WriteCopy"] = 16] = "WriteCopy";
|
|
17
|
-
return MemoryProtection;
|
|
18
|
-
}({});
|
|
19
|
-
//#endregion
|
|
20
5
|
//#region src/native/platform/win32/Win32MemoryProvider.ts
|
|
21
6
|
const handleMap$1 = /* @__PURE__ */ new WeakMap();
|
|
22
7
|
function getWin32Handle(handle) {
|
|
@@ -25,28 +10,28 @@ function getWin32Handle(handle) {
|
|
|
25
10
|
return h;
|
|
26
11
|
}
|
|
27
12
|
function win32ProtToMemoryProtection(prot) {
|
|
28
|
-
let flags =
|
|
29
|
-
if (prot & PAGE.READONLY) flags |=
|
|
30
|
-
if (prot & PAGE.READWRITE) flags |=
|
|
31
|
-
if (prot & PAGE.WRITECOPY) flags |=
|
|
32
|
-
if (prot & PAGE.EXECUTE) flags |=
|
|
33
|
-
if (prot & PAGE.EXECUTE_READ) flags |=
|
|
34
|
-
if (prot & PAGE.EXECUTE_READWRITE) flags |=
|
|
35
|
-
if (prot & PAGE.EXECUTE_WRITECOPY) flags |=
|
|
36
|
-
if (prot & PAGE.GUARD) flags |=
|
|
13
|
+
let flags = 0;
|
|
14
|
+
if (prot & PAGE.READONLY) flags |= 1;
|
|
15
|
+
if (prot & PAGE.READWRITE) flags |= 3;
|
|
16
|
+
if (prot & PAGE.WRITECOPY) flags |= 17;
|
|
17
|
+
if (prot & PAGE.EXECUTE) flags |= 4;
|
|
18
|
+
if (prot & PAGE.EXECUTE_READ) flags |= 5;
|
|
19
|
+
if (prot & PAGE.EXECUTE_READWRITE) flags |= 7;
|
|
20
|
+
if (prot & PAGE.EXECUTE_WRITECOPY) flags |= 21;
|
|
21
|
+
if (prot & PAGE.GUARD) flags |= 8;
|
|
37
22
|
return flags;
|
|
38
23
|
}
|
|
39
24
|
function memoryProtectionToWin32Prot(prot) {
|
|
40
|
-
const hasRead = (prot &
|
|
41
|
-
const hasWrite = (prot &
|
|
42
|
-
const hasExec = (prot &
|
|
25
|
+
const hasRead = (prot & 1) !== 0;
|
|
26
|
+
const hasWrite = (prot & 2) !== 0;
|
|
27
|
+
const hasExec = (prot & 4) !== 0;
|
|
43
28
|
let page = PAGE.NOACCESS;
|
|
44
29
|
if (hasRead && hasWrite && hasExec) page = PAGE.EXECUTE_READWRITE;
|
|
45
30
|
else if (hasRead && hasExec) page = PAGE.EXECUTE_READ;
|
|
46
31
|
else if (hasRead && hasWrite) page = PAGE.READWRITE;
|
|
47
32
|
else if (hasExec) page = PAGE.EXECUTE;
|
|
48
33
|
else if (hasRead) page = PAGE.READONLY;
|
|
49
|
-
if ((prot &
|
|
34
|
+
if ((prot & 8) !== 0) page |= PAGE.GUARD;
|
|
50
35
|
return page;
|
|
51
36
|
}
|
|
52
37
|
function win32StateToState(state) {
|
|
@@ -110,9 +95,9 @@ var Win32MemoryProvider = class {
|
|
|
110
95
|
protection,
|
|
111
96
|
state: win32StateToState(info.State),
|
|
112
97
|
type: win32TypeToType(info.Type),
|
|
113
|
-
isReadable: (protection &
|
|
114
|
-
isWritable: (protection &
|
|
115
|
-
isExecutable: (protection &
|
|
98
|
+
isReadable: (protection & 1) !== 0,
|
|
99
|
+
isWritable: (protection & 2) !== 0,
|
|
100
|
+
isExecutable: (protection & 4) !== 0
|
|
116
101
|
};
|
|
117
102
|
}
|
|
118
103
|
changeProtection(handle, address, size, newProtection) {
|
|
@@ -161,10 +146,10 @@ function getDarwinHandle(handle) {
|
|
|
161
146
|
* Map Mach VM_PROT_* flags → platform-agnostic MemoryProtection
|
|
162
147
|
*/
|
|
163
148
|
function machProtToMemoryProtection(prot) {
|
|
164
|
-
let flags =
|
|
165
|
-
if (prot & VM_PROT.READ) flags |=
|
|
166
|
-
if (prot & VM_PROT.WRITE) flags |=
|
|
167
|
-
if (prot & VM_PROT.EXECUTE) flags |=
|
|
149
|
+
let flags = 0;
|
|
150
|
+
if (prot & VM_PROT.READ) flags |= 1;
|
|
151
|
+
if (prot & VM_PROT.WRITE) flags |= 2;
|
|
152
|
+
if (prot & VM_PROT.EXECUTE) flags |= 4;
|
|
168
153
|
return flags;
|
|
169
154
|
}
|
|
170
155
|
/**
|
|
@@ -172,9 +157,9 @@ function machProtToMemoryProtection(prot) {
|
|
|
172
157
|
*/
|
|
173
158
|
function memoryProtectionToMachProt(prot) {
|
|
174
159
|
let machProt = VM_PROT.NONE;
|
|
175
|
-
if (prot &
|
|
176
|
-
if (prot &
|
|
177
|
-
if (prot &
|
|
160
|
+
if (prot & 1) machProt |= VM_PROT.READ;
|
|
161
|
+
if (prot & 2) machProt |= VM_PROT.WRITE;
|
|
162
|
+
if (prot & 4) machProt |= VM_PROT.EXECUTE;
|
|
178
163
|
return machProt;
|
|
179
164
|
}
|
|
180
165
|
/**
|
|
@@ -264,16 +249,16 @@ var DarwinMemoryProvider = class {
|
|
|
264
249
|
protection,
|
|
265
250
|
state: "committed",
|
|
266
251
|
type: darwinShareModeToType(info.behavior),
|
|
267
|
-
isReadable: (protection &
|
|
268
|
-
isWritable: (protection &
|
|
269
|
-
isExecutable: (protection &
|
|
252
|
+
isReadable: (protection & 1) !== 0,
|
|
253
|
+
isWritable: (protection & 2) !== 0,
|
|
254
|
+
isExecutable: (protection & 4) !== 0
|
|
270
255
|
};
|
|
271
256
|
}
|
|
272
257
|
changeProtection(handle, address, size, newProtection) {
|
|
273
258
|
const h = getDarwinHandle(handle);
|
|
274
259
|
const machProt = memoryProtectionToMachProt(newProtection);
|
|
275
260
|
const { kr: queryKr, info } = machVmRegion(h.task, address);
|
|
276
|
-
const oldProtection = queryKr === KERN.SUCCESS ? machProtToMemoryProtection(info.protection) :
|
|
261
|
+
const oldProtection = queryKr === KERN.SUCCESS ? machProtToMemoryProtection(info.protection) : 0;
|
|
277
262
|
if ((machProt & VM_PROT.WRITE) !== 0 && (machProt & VM_PROT.EXECUTE) !== 0) {
|
|
278
263
|
const maxKr = machVmProtect(h.task, address, BigInt(size), true, VM_PROT.ALL);
|
|
279
264
|
if (maxKr !== KERN.SUCCESS) throw new Error(`mach_vm_protect (set_maximum) failed at 0x${address.toString(16)}: ${kernReturnName(maxKr)} (${maxKr})`);
|
|
@@ -302,13 +287,13 @@ var DarwinMemoryProvider = class {
|
|
|
302
287
|
}
|
|
303
288
|
enumerateModules(handle) {
|
|
304
289
|
const h = getDarwinHandle(handle);
|
|
305
|
-
if (handle.pid === process.pid) return this.
|
|
306
|
-
return this.
|
|
290
|
+
if (handle.pid === process.pid) return this.enumerateModulesSelf();
|
|
291
|
+
return this.enumerateModulesRemote(h.task);
|
|
307
292
|
}
|
|
308
293
|
/**
|
|
309
294
|
* Enumerate modules for the current process using dyld APIs (fast path).
|
|
310
295
|
*/
|
|
311
|
-
|
|
296
|
+
enumerateModulesSelf() {
|
|
312
297
|
const count = dyldImageCount();
|
|
313
298
|
const modules = [];
|
|
314
299
|
for (let i = 0; i < count; i++) {
|
|
@@ -330,7 +315,7 @@ var DarwinMemoryProvider = class {
|
|
|
330
315
|
* This reads the target process's dyld info structures from memory.
|
|
331
316
|
* Falls back to an empty list if the info struct cannot be located.
|
|
332
317
|
*/
|
|
333
|
-
|
|
318
|
+
enumerateModulesRemote(task) {
|
|
334
319
|
const modules = [];
|
|
335
320
|
let address = 0n;
|
|
336
321
|
for (let i = 0; i < 1e4; i++) {
|
|
@@ -389,10 +374,10 @@ function isLinuxRuntime() {
|
|
|
389
374
|
return process.platform === "linux";
|
|
390
375
|
}
|
|
391
376
|
function toProtection(perms) {
|
|
392
|
-
let protection =
|
|
393
|
-
if (perms.includes("r")) protection |=
|
|
394
|
-
if (perms.includes("w")) protection |=
|
|
395
|
-
if (perms.includes("x")) protection |=
|
|
377
|
+
let protection = 0;
|
|
378
|
+
if (perms.includes("r")) protection |= 1;
|
|
379
|
+
if (perms.includes("w")) protection |= 2;
|
|
380
|
+
if (perms.includes("x")) protection |= 4;
|
|
396
381
|
return protection;
|
|
397
382
|
}
|
|
398
383
|
function toRegionInfo(region) {
|
|
@@ -403,9 +388,9 @@ function toRegionInfo(region) {
|
|
|
403
388
|
protection,
|
|
404
389
|
state: "committed",
|
|
405
390
|
type: region.path ? "mapped" : "private",
|
|
406
|
-
isReadable: (protection &
|
|
407
|
-
isWritable: (protection &
|
|
408
|
-
isExecutable: (protection &
|
|
391
|
+
isReadable: (protection & 1) !== 0,
|
|
392
|
+
isWritable: (protection & 2) !== 0,
|
|
393
|
+
isExecutable: (protection & 4) !== 0
|
|
409
394
|
};
|
|
410
395
|
}
|
|
411
396
|
function normalizePattern(pattern) {
|
|
@@ -587,4 +572,4 @@ function createPlatformProvider() {
|
|
|
587
572
|
return cachedProvider;
|
|
588
573
|
}
|
|
589
574
|
//#endregion
|
|
590
|
-
export {
|
|
575
|
+
export { parseProcMaps as i, factory_exports as n, formatLinuxProtection as r, createPlatformProvider as t };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/modules/browser/flat-target-session.ts
|
|
2
|
+
function readSessionId(response) {
|
|
3
|
+
if (typeof response !== "object" || response === null) return null;
|
|
4
|
+
const sessionId = response.sessionId;
|
|
5
|
+
return typeof sessionId === "string" && sessionId.length > 0 ? sessionId : null;
|
|
6
|
+
}
|
|
7
|
+
function readAttachedSessionId(session) {
|
|
8
|
+
const sessionId = session.id?.();
|
|
9
|
+
return typeof sessionId === "string" && sessionId.length > 0 ? sessionId : null;
|
|
10
|
+
}
|
|
11
|
+
async function attachToFlatTarget(parentSession, targetId) {
|
|
12
|
+
const sessionId = readSessionId(await parentSession.send("Target.attachToTarget", {
|
|
13
|
+
targetId,
|
|
14
|
+
flatten: true
|
|
15
|
+
}));
|
|
16
|
+
if (!sessionId) throw new Error(`Target.attachToTarget did not return sessionId for ${targetId}`);
|
|
17
|
+
const connection = parentSession.connection?.();
|
|
18
|
+
if (!connection || typeof connection.session !== "function") throw new Error(`CDP connection lookup unavailable for attached target ${targetId}`);
|
|
19
|
+
const attachedSession = connection.session(sessionId);
|
|
20
|
+
if (!attachedSession) throw new Error(`CDP attached target session ${sessionId} was not registered for ${targetId}`);
|
|
21
|
+
return attachedSession;
|
|
22
|
+
}
|
|
23
|
+
async function detachFromFlatTarget(parentSession, attachedSession) {
|
|
24
|
+
const sessionId = readAttachedSessionId(attachedSession);
|
|
25
|
+
if (!sessionId) throw new Error("CDP attached target session id unavailable for detach");
|
|
26
|
+
await parentSession.send("Target.detachFromTarget", { sessionId });
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { detachFromFlatTarget as n, attachToFlatTarget as t };
|