@jshookmcp/jshook 0.3.0 → 0.3.1
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 +25 -50
- package/README.zh.md +25 -48
- package/dist/AntiCheatDetector-CGVGNfy5.mjs +1 -0
- package/dist/CacheAdapters-CdAxBmVW.mjs +1 -0
- package/dist/CodeInjector-BlgyqTOk.mjs +1 -0
- package/dist/ConsoleMonitor-Dkqc0HNi.mjs +490 -0
- package/dist/DOMInspector-BYY_EJ0C.mjs +95 -0
- package/dist/DarwinAPI-DC4HGGLl.mjs +1 -0
- package/dist/DetailedDataManager-BniBJlVv.mjs +1 -0
- package/dist/EventBus-DgciURGg.mjs +1 -0
- package/dist/EvidenceGraphBridge-BIfgB7HP.mjs +1 -0
- package/dist/ExtensionManager-erMpqcLk.mjs +1 -0
- package/dist/FingerprintManager-N7BZqjxP.mjs +1 -0
- package/dist/HardwareBreakpoint-OcJqNFVc.mjs +1 -0
- package/dist/HeapAnalyzer-CqAxZzeS.mjs +1 -0
- package/dist/{HookGeneratorBuilders.core.generators.storage-CTbB4Lcx.mjs → HookGeneratorBuilders.core.generators.storage-Bf1fbrNK.mjs} +66 -101
- package/dist/InstrumentationSession-DxXs0sCp.mjs +1 -0
- package/dist/MCPServer.search.handlers.domain-DVbWL1bT.mjs +1 -0
- package/dist/MemoryController-BaqstM5w.mjs +2 -0
- package/dist/MemoryScanSession-CaxAjZJf.mjs +1 -0
- package/dist/MemoryScanner-BLYnMJy6.mjs +1 -0
- package/dist/NativeMemoryManager.impl-CI554XbY.mjs +1 -0
- package/dist/NativeMemoryManager.utils-DM4NC3FE.mjs +1 -0
- package/dist/PEAnalyzer-DJyaJTQJ.mjs +1 -0
- package/dist/PageController-D9jVkH0i.mjs +1 -0
- package/dist/PointerChainEngine-5nF9eNlu.mjs +1 -0
- package/dist/PrerequisiteError-Bl3dK8XA.mjs +1 -0
- package/dist/ProcessRegistry-Hf12LlR9.mjs +1 -0
- package/dist/ResponseBuilder-B2lu4KEl.mjs +1 -0
- package/dist/ReverseEvidenceGraph-B931HeoW.mjs +2 -0
- package/dist/ScriptManager-fgqiALgj.mjs +7 -0
- package/dist/Speedhack-l6s8L2Qw.mjs +1 -0
- package/dist/StealthVerifier-Dhbj4B4P.mjs +1 -0
- package/dist/StructureAnalyzer-A-WamfYE.mjs +2 -0
- package/dist/ToolCatalog-D_IKl1Hu.mjs +1 -0
- package/dist/ToolError-DWU_z7gp.mjs +1 -0
- package/dist/ToolProbe-xsfALmN3.mjs +1 -0
- package/dist/ToolRegistry-B0Zs-phN.mjs +1 -0
- package/dist/ToolRouter.policy-CFHoN_Lw.mjs +4 -0
- package/dist/TraceRecorder-Dd8jLXpi.mjs +272 -0
- package/dist/VersionDetector-DMoUWyNm.mjs +9 -0
- package/dist/Win32API-Bhi5xFBe.mjs +1 -0
- package/dist/Win32Debug-CQteFL4F.mjs +1 -0
- package/dist/WorkflowEngine-CxEp2WXH.mjs +1 -0
- package/dist/analysis-BuR-NgX8.mjs +5 -0
- package/dist/{antidebug-BRKeyt27.mjs → antidebug-BOTZH6-0.mjs} +8 -259
- package/dist/artifactRetention-NBdncOEW.mjs +1 -0
- package/dist/artifacts-B5xQuEa_.mjs +1 -0
- package/dist/authorization-schema-B40obG1A.mjs +1 -0
- package/dist/betterSqlite3-CGaxz4AX.mjs +1 -0
- package/dist/binary-instrument-Cf9qqLlM.mjs +7 -0
- package/dist/bind-helpers-BlAOQrFQ.mjs +1 -0
- package/dist/boringssl-inspector-BST5vtKx.mjs +2 -0
- package/dist/browser-C4Le3xqA.mjs +11 -0
- package/dist/capabilities-DbYCv-HF.mjs +1 -0
- package/dist/chunk-C_pMuVsO.mjs +1 -0
- package/dist/collector-CKO8RPK8.mjs +1 -0
- package/dist/concurrency-CcK46d0h.mjs +1 -0
- package/dist/constants-Cp6hBrrx.mjs +1 -0
- package/dist/coordination-BbijHEHH.mjs +1 -0
- package/dist/debugger-CRJq_krh.mjs +1 -0
- package/dist/definitions-BGobEDQa.mjs +1 -0
- package/dist/definitions-BGwNSkVm.mjs +1 -0
- package/dist/definitions-BbxOUiP-.mjs +1 -0
- package/dist/definitions-CCP9gphV.mjs +1 -0
- package/dist/definitions-CIO9O-Sw.mjs +1 -0
- package/dist/definitions-CYFbewnd.mjs +1 -0
- package/dist/definitions-CdWEuIkI.mjs +1 -0
- package/dist/definitions-CoQFbggH.mjs +1 -0
- package/dist/definitions-CuJRsJ6N.mjs +1 -0
- package/dist/definitions-DI9YXsJk.mjs +1 -0
- package/dist/definitions-DJklW2sS.mjs +1 -0
- package/dist/definitions-DZ8uKusP.mjs +1 -0
- package/dist/definitions-Dds_zrWx.mjs +1 -0
- package/dist/definitions-Dgrg7f3D.mjs +1 -0
- package/dist/definitions-DtE0XLrT.mjs +1 -0
- package/dist/definitions-LaYTuwQd.mjs +26 -0
- package/dist/definitions-NoVp_9Pm.mjs +1 -0
- package/dist/definitions-OvGsfxdt.mjs +1 -0
- package/dist/definitions-jXPaVy4P.mjs +1 -0
- package/dist/encoding-DGcr6Aj_.mjs +2 -0
- package/dist/ensure-browser-core-Buls24LQ.mjs +1 -0
- package/dist/evidence-graph-bridge-B0yhGPcs.mjs +1 -0
- package/dist/factory-Cx_1LorX.mjs +1 -0
- package/dist/flat-target-session-CO5g78k3.mjs +1 -0
- package/dist/formatAddress-C7j2fDlM.mjs +1 -0
- package/dist/graphql-HLf3MS8H.mjs +62 -0
- package/dist/handlers-BLMa4X7l.mjs +54 -0
- package/dist/handlers-BP12ZsWc.mjs +4 -0
- package/dist/handlers-BZoPla6E.mjs +1 -0
- package/dist/handlers-BggKiVx9.mjs +2 -0
- package/dist/handlers-D3iev8g1.mjs +1 -0
- package/dist/handlers-D49r1-1P.mjs +1 -0
- package/dist/handlers-DCE45Ww8.mjs +2 -0
- package/dist/handlers-DW5AbYs5.mjs +5 -0
- package/dist/handlers-De5u62Ga2.mjs +1 -0
- package/dist/handlers-DmQzIc44.mjs +31 -0
- package/dist/handlers-DnJRGp7t.mjs +302 -0
- package/dist/handlers-Dv_runVv.mjs +2 -0
- package/dist/handlers-S9Ws0IGy.mjs +2 -0
- package/dist/{handlers-Dz9PYsCa.mjs → handlers-pVNpaw4A.mjs} +118 -904
- package/dist/handlers.impl-CD2_kOcC.mjs +1 -0
- package/dist/hooks-DDKppogd.mjs +600 -0
- package/dist/index.mjs +12 -5235
- package/dist/logger-sBC6IdRT.mjs +1 -0
- package/dist/maintenance-CutEO84j.mjs +1 -0
- package/dist/manifest-BFGxlDRh.mjs +123 -0
- package/dist/manifest-BPuE6oH2.mjs +1 -0
- package/dist/manifest-BXry5N09.mjs +1 -0
- package/dist/manifest-BeP_zJGb2.mjs +1 -0
- package/dist/manifest-C0g67k6U.mjs +1 -0
- package/dist/manifest-C1nZkTkO.mjs +1 -0
- package/dist/manifest-C7qV1z7F.mjs +1 -0
- package/dist/manifest-CDeUZGUZ.mjs +1 -0
- package/dist/manifest-CDiCtaQT.mjs +1 -0
- package/dist/manifest-CFn0359q2.mjs +1 -0
- package/dist/manifest-CGq4NpqH2.mjs +1 -0
- package/dist/manifest-CJMGt7Qy.mjs +1 -0
- package/dist/manifest-CRIJq4Hs.mjs +1 -0
- package/dist/manifest-C_hEIjSx.mjs +1 -0
- package/dist/manifest-CeQmtQOY.mjs +1 -0
- package/dist/manifest-Cq0j7GZt.mjs +1 -0
- package/dist/manifest-CtPmHAdn.mjs +1 -0
- package/dist/manifest-Cx2IVMUY.mjs +1 -0
- package/dist/manifest-D16xPXro.mjs +1 -0
- package/dist/manifest-D44TaRJU.mjs +1 -0
- package/dist/manifest-D610kxZr.mjs +2 -0
- package/dist/manifest-DC-SMF6b.mjs +1 -0
- package/dist/manifest-DD3rtxvV.mjs +1 -0
- package/dist/manifest-DKUorv5M.mjs +1 -0
- package/dist/manifest-DMJlcsTR.mjs +1 -0
- package/dist/manifest-DWUUWBz0.mjs +1 -0
- package/dist/manifest-De-6Wf2R.mjs +1 -0
- package/dist/manifest-Dgh0uDW-.mjs +1 -0
- package/dist/manifest-Dm0o3i2U.mjs +1 -0
- package/dist/manifest-DsVh7Y4U.mjs +1 -0
- package/dist/manifest-DtEFSRaq.mjs +1 -0
- package/dist/manifest-H-EpAyZQ.mjs +1 -0
- package/dist/manifest-ais9Afrw.mjs +1 -0
- package/dist/manifest-tmb54wmA.mjs +1 -0
- package/dist/manifest-yu2xiQqe.mjs +1 -0
- package/dist/manifest-zrbrpKCC.mjs +1 -0
- package/dist/matchesWildcardPattern-BGqLSmEs.mjs +1 -0
- package/dist/modules-p-PUNv9r.mjs +332 -0
- package/dist/mojo-ipc-VGlv3Qyp.mjs +9 -0
- package/dist/network-BjZ1Y-GB.mjs +7 -0
- package/dist/outputPaths-BonGThuc.mjs +2 -0
- package/dist/parse-args-Cuk7-xUt.mjs +1 -0
- package/dist/platform-C446Lf97.mjs +93 -0
- package/dist/playwright-cdp-fallback-BwVR-_T3.mjs +1 -0
- package/dist/process-C9f2A5zk.mjs +962 -0
- package/dist/proxy-CvRepxgV.mjs +1 -0
- package/dist/registry-DUHIPE-v.mjs +1 -0
- package/dist/response-C7rKQst4.mjs +1 -0
- package/dist/search-defaults-D2bY-rzH.mjs +1 -0
- package/dist/server/plugin-api.mjs +1 -293
- package/dist/shared-state-board-Cyg-xh_k.mjs +1 -0
- package/dist/sourcemap-D6Q1UuAp.mjs +1 -0
- package/dist/ssrf-policy-T96MR3r6.mjs +1 -0
- package/dist/streaming-CTX58tbb.mjs +1 -0
- package/dist/tool-builder-CI9914Tf.mjs +1 -0
- package/dist/transform-Cv9P2vVD.mjs +103 -0
- package/dist/types-CuyefmGT.mjs +1 -0
- package/dist/types-DtThH00r.mjs +1 -0
- package/dist/wasm-DaJa8J0V.mjs +174 -0
- package/dist/webcrack-CsLLJIs9.mjs +46 -0
- package/dist/workflow-CYIXtrWD.mjs +101 -0
- package/package.json +50 -78
- package/dist/AntiCheatDetector-CqGDXmfc.mjs +0 -350
- package/dist/CacheAdapters-jJFy20G-.mjs +0 -80
- package/dist/CodeInjector-BdjRfNx7.mjs +0 -150
- package/dist/ConsoleMonitor-DykL3IAw.mjs +0 -2269
- package/dist/DarwinAPI-ETyy0xyo.mjs +0 -363
- package/dist/DetailedDataManager-HT49OrvF.mjs +0 -217
- package/dist/EventBus-DFKvADm3.mjs +0 -141
- package/dist/EvidenceGraphBridge-318Oi0Lf.mjs +0 -153
- package/dist/ExtensionManager-BDMsY2Dz.mjs +0 -721
- package/dist/FingerprintManager-BN4UQWnX.mjs +0 -96
- package/dist/HardwareBreakpoint-Cc2AFq1Y.mjs +0 -239
- package/dist/HeapAnalyzer-DruMgsgj.mjs +0 -284
- package/dist/InstrumentationSession-DLH0vd-z.mjs +0 -244
- package/dist/MemoryController-CMtviNW_.mjs +0 -167
- package/dist/MemoryScanSession-ITgb_NMi.mjs +0 -278
- package/dist/MemoryScanner-CiL7Z3ey.mjs +0 -428
- package/dist/NativeMemoryManager.impl-D9Lkovvn.mjs +0 -485
- package/dist/NativeMemoryManager.utils-BBlAixF5.mjs +0 -165
- package/dist/PEAnalyzer-DMQ44gen.mjs +0 -385
- package/dist/PageController-BPJNqqBN.mjs +0 -431
- package/dist/PointerChainEngine-K7wN8Z-w.mjs +0 -325
- package/dist/PrerequisiteError-TuyZIs6n.mjs +0 -20
- package/dist/ProcessRegistry-zGg12QbE.mjs +0 -74
- package/dist/ResponseBuilder-CJXWmWNw.mjs +0 -143
- package/dist/ReverseEvidenceGraph-C02-gXOh.mjs +0 -269
- package/dist/ScriptManager-ZuWD-0Jg.mjs +0 -3003
- package/dist/Speedhack-D-z0umeT.mjs +0 -156
- package/dist/StealthVerifier-BWmPgQsv.mjs +0 -135
- package/dist/StructureAnalyzer-Cav5AVSL.mjs +0 -429
- package/dist/ToolCatalog-5OJdMiF0.mjs +0 -582
- package/dist/ToolError-jh9whhMd.mjs +0 -15
- package/dist/ToolProbe-DbCFGyrg.mjs +0 -45
- package/dist/ToolRegistry-B9krbTtI.mjs +0 -180
- package/dist/ToolRouter.policy-BGDAGyeH.mjs +0 -344
- package/dist/TraceRecorder-B41Z5XBj.mjs +0 -1286
- package/dist/VersionDetector-K3V4vGsw.mjs +0 -104
- package/dist/Win32API-C2kjj0ze.mjs +0 -346
- package/dist/Win32Debug-CKrGOTpo.mjs +0 -274
- package/dist/WorkflowEngine-DJ6M4opp.mjs +0 -569
- package/dist/analysis-BHeJW2Nb.mjs +0 -1234
- package/dist/artifactRetention-CPXkUJXp.mjs +0 -598
- package/dist/artifacts-DkfosXH3.mjs +0 -59
- package/dist/authorization-schema-DRqyJMSk.mjs +0 -31
- package/dist/betterSqlite3-DLSBZodi.mjs +0 -74
- package/dist/binary-instrument--V3MAhJ4.mjs +0 -971
- package/dist/bind-helpers-ClV34xdn.mjs +0 -42
- package/dist/boringssl-inspector-Bo_LOLaS.mjs +0 -180
- package/dist/browser-Dx3_S2cG.mjs +0 -4369
- package/dist/capabilities-CcHlvWgK.mjs +0 -33
- package/dist/chunk-CjcI7cDX.mjs +0 -15
- package/dist/concurrency-Drev_Vz9.mjs +0 -41
- package/dist/constants-CDZLOoVv.mjs +0 -534
- package/dist/coordination-DgItD9DL.mjs +0 -259
- package/dist/debugger-RS3RSAqs.mjs +0 -1288
- package/dist/definitions-BEoYofW5.mjs +0 -47
- package/dist/definitions-BRaefg3u.mjs +0 -365
- package/dist/definitions-BbkvZkiv.mjs +0 -96
- package/dist/definitions-BtWSHJ3o.mjs +0 -17
- package/dist/definitions-C1gCHO0i.mjs +0 -43
- package/dist/definitions-CDOg_b-l.mjs +0 -138
- package/dist/definitions-CVPD9hzZ.mjs +0 -54
- package/dist/definitions-Cea8Lgl7.mjs +0 -94
- package/dist/definitions-DAgIyjxM.mjs +0 -10
- package/dist/definitions-DJA27nsL.mjs +0 -66
- package/dist/definitions-DKPFU3LW.mjs +0 -25
- package/dist/definitions-DPRpZQ96.mjs +0 -47
- package/dist/definitions-DUE5gmdn.mjs +0 -18
- package/dist/definitions-DYVjOtxa.mjs +0 -26
- package/dist/definitions-DcYLVLCo.mjs +0 -37
- package/dist/definitions-Pp5LI2H4.mjs +0 -27
- package/dist/definitions-j9KdHVNR.mjs +0 -14
- package/dist/definitions-uzkjBwa7.mjs +0 -258
- package/dist/definitions-va-AnLuQ.mjs +0 -28
- package/dist/encoding-DJeqHmpd.mjs +0 -1079
- package/dist/evidence-graph-bridge-DcYizFk2.mjs +0 -136
- package/dist/factory-C90tBff6.mjs +0 -575
- package/dist/flat-target-session-Dgax2Cy3.mjs +0 -29
- package/dist/formatAddress-nnMvEohD.mjs +0 -17
- package/dist/graphql-CoHrhweh.mjs +0 -1197
- package/dist/handlers-4jmR0nMs.mjs +0 -898
- package/dist/handlers-BAHPxcch.mjs +0 -789
- package/dist/handlers-BOs9b907.mjs +0 -2600
- package/dist/handlers-BWXEy6ef.mjs +0 -917
- package/dist/handlers-Bndn6QvE.mjs +0 -111
- package/dist/handlers-BqC4bD4s.mjs +0 -681
- package/dist/handlers-BtYq60bM2.mjs +0 -276
- package/dist/handlers-BzgcB4iv.mjs +0 -799
- package/dist/handlers-CRyRWj2b.mjs +0 -859
- package/dist/handlers-CVv2H1uq.mjs +0 -592
- package/dist/handlers-Dl5a7JS4.mjs +0 -572
- package/dist/handlers-Dx2d7jt7.mjs +0 -2537
- package/dist/handlers-HujRKC3b.mjs +0 -661
- package/dist/handlers.impl-XWXkQfyi.mjs +0 -807
- package/dist/hooks-B1B8NRHL.mjs +0 -898
- package/dist/logger-Dh_xb7_2.mjs +0 -93
- package/dist/maintenance-PRMkLVRW.mjs +0 -835
- package/dist/manifest-67Bok-Si.mjs +0 -58
- package/dist/manifest-6lNTMZAB2.mjs +0 -87
- package/dist/manifest-B2duEHiH.mjs +0 -90
- package/dist/manifest-B6EY9Vm8.mjs +0 -57
- package/dist/manifest-B6nKSbyY.mjs +0 -95
- package/dist/manifest-BL8AQNPF.mjs +0 -106
- package/dist/manifest-BSZvJJmV.mjs +0 -47
- package/dist/manifest-BU7qzUyX.mjs +0 -418
- package/dist/manifest-Bl62e8WK.mjs +0 -49
- package/dist/manifest-Bo5cXjdt.mjs +0 -82
- package/dist/manifest-BpS4gtUK.mjs +0 -1347
- package/dist/manifest-Bv65_e2W.mjs +0 -101
- package/dist/manifest-BytNIF4Z.mjs +0 -117
- package/dist/manifest-C-xtsjS3.mjs +0 -81
- package/dist/manifest-CDYl7OhA.mjs +0 -66
- package/dist/manifest-CRZ3xmkD.mjs +0 -61
- package/dist/manifest-CoW6u4Tp.mjs +0 -132
- package/dist/manifest-Cq5zN_8A.mjs +0 -50
- package/dist/manifest-D7YZM_2e.mjs +0 -194
- package/dist/manifest-DE_VrAeQ.mjs +0 -314
- package/dist/manifest-DGsXSCpT.mjs +0 -39
- package/dist/manifest-DJ2vfEuW.mjs +0 -156
- package/dist/manifest-DPXDYhEu.mjs +0 -80
- package/dist/manifest-Dd4fQb0a.mjs +0 -322
- package/dist/manifest-Deq6opGg.mjs +0 -223
- package/dist/manifest-DfJTafJK.mjs +0 -37
- package/dist/manifest-DgOdgN_j.mjs +0 -50
- package/dist/manifest-DlbMW4v4.mjs +0 -47
- package/dist/manifest-DmVfbH0w.mjs +0 -374
- package/dist/manifest-Dog6Ddjr.mjs +0 -109
- package/dist/manifest-DvgU5FWb.mjs +0 -58
- package/dist/manifest-HsfDBs7j.mjs +0 -50
- package/dist/manifest-I8oQHvCG.mjs +0 -186
- package/dist/manifest-NvH_a-av.mjs +0 -786
- package/dist/manifest-cEJU1v0Z.mjs +0 -129
- package/dist/manifest-wOl5XLB12.mjs +0 -112
- package/dist/modules-tZozf0LQ.mjs +0 -10635
- package/dist/mojo-ipc-DXNEXEqb.mjs +0 -640
- package/dist/network-CPVvwvFg.mjs +0 -3852
- package/dist/outputPaths-um7lCRY3.mjs +0 -1141
- package/dist/parse-args-B4cY5Vx5.mjs +0 -39
- package/dist/platform-CYeFoTWp.mjs +0 -2161
- package/dist/process-BTbgcVc6.mjs +0 -1306
- package/dist/proxy-r8YN6nP1.mjs +0 -192
- package/dist/registry-Bl8ZQW61.mjs +0 -34
- package/dist/response-CWhh2aLo.mjs +0 -34
- package/dist/shared-state-board-BoZnSoj-.mjs +0 -586
- package/dist/sourcemap-BIDHUVXy.mjs +0 -934
- package/dist/ssrf-policy-Dsqd-DTX.mjs +0 -166
- package/dist/streaming-Dal6utPp.mjs +0 -725
- package/dist/tool-builder-BHJp32mV.mjs +0 -186
- package/dist/transform-DRVgGG90.mjs +0 -1011
- package/dist/types-Bx92KJfT.mjs +0 -4
- package/dist/types-DDBWs9UP.mjs +0 -37
- package/dist/wasm-BYx5UOeG.mjs +0 -1044
- package/dist/webcrack-Be0_FccV.mjs +0 -747
- package/dist/workflow-BpuKEtvn.mjs +0 -725
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { n as __require } from "./chunk-CjcI7cDX.mjs";
|
|
2
|
-
import { t as logger } from "./logger-Dh_xb7_2.mjs";
|
|
3
|
-
//#region src/modules/stealth/FingerprintManager.ts
|
|
4
|
-
var FingerprintManager = class FingerprintManager {
|
|
5
|
-
static instance = null;
|
|
6
|
-
activeProfile = null;
|
|
7
|
-
available = null;
|
|
8
|
-
constructor() {}
|
|
9
|
-
static getInstance() {
|
|
10
|
-
if (!FingerprintManager.instance) FingerprintManager.instance = new FingerprintManager();
|
|
11
|
-
return FingerprintManager.instance;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Check if fingerprint-generator and fingerprint-injector packages are installed.
|
|
15
|
-
*/
|
|
16
|
-
isAvailable() {
|
|
17
|
-
if (this.available !== null) return this.available;
|
|
18
|
-
try {
|
|
19
|
-
__require.resolve("fingerprint-generator");
|
|
20
|
-
__require.resolve("fingerprint-injector");
|
|
21
|
-
this.available = true;
|
|
22
|
-
} catch {
|
|
23
|
-
this.available = false;
|
|
24
|
-
}
|
|
25
|
-
return this.available;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Generate a fingerprint profile using real-world datasets.
|
|
29
|
-
* Returns null if packages are not installed.
|
|
30
|
-
*/
|
|
31
|
-
async generateFingerprint(options) {
|
|
32
|
-
if (!this.isAvailable()) {
|
|
33
|
-
logger.warn("fingerprint-generator not installed. Run: pnpm add fingerprint-generator fingerprint-injector");
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
const { FingerprintGenerator } = await import("fingerprint-generator");
|
|
38
|
-
const generator = new FingerprintGenerator();
|
|
39
|
-
const fpOptions = {};
|
|
40
|
-
if (options?.os) fpOptions.operatingSystems = [{
|
|
41
|
-
windows: "windows",
|
|
42
|
-
macos: "macos",
|
|
43
|
-
linux: "linux"
|
|
44
|
-
}[options.os] ?? "windows"];
|
|
45
|
-
if (options?.browser) fpOptions.browsers = [options.browser];
|
|
46
|
-
if (options?.locale) fpOptions.locales = [options.locale];
|
|
47
|
-
if (options?.screen) fpOptions.screen = options.screen;
|
|
48
|
-
const result = generator.getFingerprint(fpOptions);
|
|
49
|
-
this.activeProfile = {
|
|
50
|
-
fingerprint: result.fingerprint,
|
|
51
|
-
headers: result.headers ?? {},
|
|
52
|
-
generatedAt: Date.now(),
|
|
53
|
-
os: options?.os ?? "windows",
|
|
54
|
-
browser: options?.browser ?? "chrome"
|
|
55
|
-
};
|
|
56
|
-
logger.info(`Fingerprint generated for ${this.activeProfile.os}/${this.activeProfile.browser}`);
|
|
57
|
-
return this.activeProfile;
|
|
58
|
-
} catch (err) {
|
|
59
|
-
logger.error("Failed to generate fingerprint:", err);
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Inject the given fingerprint profile into a page.
|
|
65
|
-
* Must be called BEFORE StealthScripts.injectAll().
|
|
66
|
-
*/
|
|
67
|
-
async injectFingerprint(page, profile) {
|
|
68
|
-
if (!this.isAvailable()) throw new Error("fingerprint-injector not installed");
|
|
69
|
-
try {
|
|
70
|
-
const { newInjectedPage } = await import("fingerprint-injector");
|
|
71
|
-
await newInjectedPage(page, { fingerprint: "fingerprint" in profile ? profile.fingerprint : profile });
|
|
72
|
-
logger.info("Fingerprint injected into page");
|
|
73
|
-
} catch (err) {
|
|
74
|
-
logger.error("Failed to inject fingerprint:", err);
|
|
75
|
-
throw err;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Get the currently cached fingerprint profile.
|
|
80
|
-
*/
|
|
81
|
-
getActiveProfile() {
|
|
82
|
-
return this.activeProfile;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Clear the cached fingerprint profile.
|
|
86
|
-
*/
|
|
87
|
-
clearProfile() {
|
|
88
|
-
this.activeProfile = null;
|
|
89
|
-
}
|
|
90
|
-
/** Reset singleton for testing purposes. */
|
|
91
|
-
static resetInstance() {
|
|
92
|
-
FingerprintManager.instance = null;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
//#endregion
|
|
96
|
-
export { FingerprintManager };
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { _ as BREAKPOINT_HIT_TIMEOUT_MS, v as BREAKPOINT_TRACE_MAX_HITS } from "./constants-CDZLOoVv.mjs";
|
|
2
|
-
import { t as CloseHandle } from "./Win32API-C2kjj0ze.mjs";
|
|
3
|
-
import { _ as openThreadForDebug, a as DebugActiveProcessStop, c as EnumerateProcessThreads, d as ResumeThread, f as SetThreadContext, g as encodeDR7, h as WaitForDebugEvent, i as DebugActiveProcess, n as ContinueDebugEvent, o as DebugSetProcessKillOnExit, p as SuspendThread, r as DBG, s as EXCEPTION_CODE, t as CONTEXT_FLAGS, u as GetThreadContext, v as parseContext, y as writeContext } from "./Win32Debug-CKrGOTpo.mjs";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
5
|
-
//#region src/native/HardwareBreakpoint.ts
|
|
6
|
-
/**
|
|
7
|
-
* Hardware Breakpoint Engine — x64 debug register management.
|
|
8
|
-
*
|
|
9
|
-
* Sets/clears hardware breakpoints using DR0–DR3, monitors for hits,
|
|
10
|
-
* and returns access context (instruction address, thread, register state).
|
|
11
|
-
*
|
|
12
|
-
* @module HardwareBreakpoint
|
|
13
|
-
*/
|
|
14
|
-
const toHex = (v) => `0x${v.toString(16).toUpperCase()}`;
|
|
15
|
-
var HardwareBreakpointEngine = class {
|
|
16
|
-
breakpoints = /* @__PURE__ */ new Map();
|
|
17
|
-
attachedPids = /* @__PURE__ */ new Set();
|
|
18
|
-
drAllocation = [
|
|
19
|
-
false,
|
|
20
|
-
false,
|
|
21
|
-
false,
|
|
22
|
-
false
|
|
23
|
-
];
|
|
24
|
-
/** Attach to process as debugger (required before setting breakpoints) */
|
|
25
|
-
async attach(pid) {
|
|
26
|
-
if (this.attachedPids.has(pid)) return;
|
|
27
|
-
DebugActiveProcess(pid);
|
|
28
|
-
DebugSetProcessKillOnExit(false);
|
|
29
|
-
this.attachedPids.add(pid);
|
|
30
|
-
for (let i = 0; i < 100; i++) {
|
|
31
|
-
const evt = WaitForDebugEvent(100);
|
|
32
|
-
if (!evt) break;
|
|
33
|
-
ContinueDebugEvent(evt.processId, evt.threadId, DBG.CONTINUE);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/** Detach from process */
|
|
37
|
-
async detach(pid) {
|
|
38
|
-
for (const [id, bp] of this.breakpoints) if (bp.pid === pid) {
|
|
39
|
-
this.clearDR(pid, bp.drIndex);
|
|
40
|
-
this.drAllocation[bp.drIndex] = false;
|
|
41
|
-
this.breakpoints.delete(id);
|
|
42
|
-
}
|
|
43
|
-
if (this.attachedPids.has(pid)) {
|
|
44
|
-
try {
|
|
45
|
-
DebugActiveProcessStop(pid);
|
|
46
|
-
} catch {}
|
|
47
|
-
this.attachedPids.delete(pid);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/** Set a hardware breakpoint using an available DR register */
|
|
51
|
-
async setBreakpoint(pid, address, access, size = 4) {
|
|
52
|
-
if (!this.attachedPids.has(pid)) await this.attach(pid);
|
|
53
|
-
const drIndex = this.allocateDR();
|
|
54
|
-
const targetAddr = BigInt(address.startsWith("0x") ? address : `0x${address}`);
|
|
55
|
-
this.applyDRToAllThreads(pid, drIndex, targetAddr, access, size, true);
|
|
56
|
-
const config = {
|
|
57
|
-
id: randomUUID(),
|
|
58
|
-
pid,
|
|
59
|
-
address: `0x${targetAddr.toString(16).toUpperCase()}`,
|
|
60
|
-
access,
|
|
61
|
-
size,
|
|
62
|
-
enabled: true,
|
|
63
|
-
drIndex,
|
|
64
|
-
hitCount: 0
|
|
65
|
-
};
|
|
66
|
-
this.breakpoints.set(config.id, config);
|
|
67
|
-
return config;
|
|
68
|
-
}
|
|
69
|
-
/** Remove a hardware breakpoint */
|
|
70
|
-
async removeBreakpoint(id) {
|
|
71
|
-
const bp = this.breakpoints.get(id);
|
|
72
|
-
if (!bp) return false;
|
|
73
|
-
this.clearDR(bp.pid, bp.drIndex);
|
|
74
|
-
this.drAllocation[bp.drIndex] = false;
|
|
75
|
-
this.breakpoints.delete(id);
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
/** List all active breakpoints */
|
|
79
|
-
listBreakpoints() {
|
|
80
|
-
return Array.from(this.breakpoints.values()).map((bp) => ({
|
|
81
|
-
id: bp.id,
|
|
82
|
-
address: bp.address,
|
|
83
|
-
access: bp.access,
|
|
84
|
-
size: bp.size,
|
|
85
|
-
enabled: bp.enabled,
|
|
86
|
-
hitCount: bp.hitCount,
|
|
87
|
-
lastHit: bp.lastHit
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
/** Wait for a breakpoint hit */
|
|
91
|
-
async waitForHit(timeoutMs) {
|
|
92
|
-
const timeout = timeoutMs ?? BREAKPOINT_HIT_TIMEOUT_MS;
|
|
93
|
-
const deadline = Date.now() + timeout;
|
|
94
|
-
while (Date.now() < deadline) {
|
|
95
|
-
const remaining = Math.max(100, deadline - Date.now());
|
|
96
|
-
const evt = WaitForDebugEvent(Math.min(remaining, 500));
|
|
97
|
-
if (!evt) continue;
|
|
98
|
-
if (evt.exceptionCode === EXCEPTION_CODE.SINGLE_STEP) {
|
|
99
|
-
const hit = this.processHit(evt.threadId, evt.processId, evt.exceptionAddress);
|
|
100
|
-
ContinueDebugEvent(evt.processId, evt.threadId, DBG.CONTINUE);
|
|
101
|
-
if (hit) return hit;
|
|
102
|
-
} else ContinueDebugEvent(evt.processId, evt.threadId, DBG.CONTINUE);
|
|
103
|
-
}
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
/** Trace access: collect multiple hits, answers "who reads/writes this address?" */
|
|
107
|
-
async traceAccess(pid, address, access, maxHits, timeoutMs) {
|
|
108
|
-
const max = maxHits ?? BREAKPOINT_TRACE_MAX_HITS;
|
|
109
|
-
const timeout = timeoutMs ?? BREAKPOINT_HIT_TIMEOUT_MS;
|
|
110
|
-
const bp = await this.setBreakpoint(pid, address, access);
|
|
111
|
-
const hits = [];
|
|
112
|
-
const deadline = Date.now() + timeout;
|
|
113
|
-
while (hits.length < max && Date.now() < deadline) {
|
|
114
|
-
const hit = await this.waitForHit(Math.min(1e3, deadline - Date.now()));
|
|
115
|
-
if (hit?.breakpointId === bp.id) hits.push(hit);
|
|
116
|
-
}
|
|
117
|
-
await this.removeBreakpoint(bp.id);
|
|
118
|
-
return hits;
|
|
119
|
-
}
|
|
120
|
-
allocateDR() {
|
|
121
|
-
for (let i = 0; i < 4; i++) if (!this.drAllocation[i]) {
|
|
122
|
-
this.drAllocation[i] = true;
|
|
123
|
-
return i;
|
|
124
|
-
}
|
|
125
|
-
throw new Error("All 4 hardware breakpoint registers (DR0-DR3) are in use");
|
|
126
|
-
}
|
|
127
|
-
applyDRToAllThreads(pid, drIndex, address, access, size, enable) {
|
|
128
|
-
const threads = EnumerateProcessThreads(pid);
|
|
129
|
-
const drAccessMap = {
|
|
130
|
-
execute: "execute",
|
|
131
|
-
write: "write",
|
|
132
|
-
readwrite: "readwrite",
|
|
133
|
-
read: "read"
|
|
134
|
-
};
|
|
135
|
-
for (const tid of threads) {
|
|
136
|
-
let hThread;
|
|
137
|
-
try {
|
|
138
|
-
hThread = openThreadForDebug(tid);
|
|
139
|
-
} catch {
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
try {
|
|
143
|
-
SuspendThread(hThread);
|
|
144
|
-
const ctxBuf = GetThreadContext(hThread, CONTEXT_FLAGS.ALL);
|
|
145
|
-
const drOffsets = [
|
|
146
|
-
72,
|
|
147
|
-
80,
|
|
148
|
-
88,
|
|
149
|
-
96
|
|
150
|
-
];
|
|
151
|
-
if (enable) ctxBuf.writeBigUInt64LE(address, drOffsets[drIndex]);
|
|
152
|
-
else ctxBuf.writeBigUInt64LE(0n, drOffsets[drIndex]);
|
|
153
|
-
const entries = Array.from(this.breakpoints.values()).filter((bp) => bp.enabled).map((bp) => ({
|
|
154
|
-
drIndex: bp.drIndex,
|
|
155
|
-
enabled: true,
|
|
156
|
-
access: drAccessMap[bp.access],
|
|
157
|
-
size: bp.size
|
|
158
|
-
}));
|
|
159
|
-
if (enable) entries.push({
|
|
160
|
-
drIndex,
|
|
161
|
-
enabled: true,
|
|
162
|
-
access: drAccessMap[access],
|
|
163
|
-
size
|
|
164
|
-
});
|
|
165
|
-
const dr7 = encodeDR7(entries);
|
|
166
|
-
ctxBuf.writeBigUInt64LE(dr7, 112);
|
|
167
|
-
writeContext(ctxBuf, { contextFlags: CONTEXT_FLAGS.ALL });
|
|
168
|
-
SetThreadContext(hThread, ctxBuf);
|
|
169
|
-
ResumeThread(hThread);
|
|
170
|
-
} catch {
|
|
171
|
-
try {
|
|
172
|
-
ResumeThread(hThread);
|
|
173
|
-
} catch {}
|
|
174
|
-
} finally {
|
|
175
|
-
CloseHandle(hThread);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
clearDR(pid, drIndex) {
|
|
180
|
-
this.applyDRToAllThreads(pid, drIndex, 0n, "write", 1, false);
|
|
181
|
-
}
|
|
182
|
-
processHit(threadId, processId, _exceptionAddress) {
|
|
183
|
-
let hThread;
|
|
184
|
-
try {
|
|
185
|
-
hThread = openThreadForDebug(threadId);
|
|
186
|
-
} catch {
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
try {
|
|
190
|
-
const ctxBuf = GetThreadContext(hThread, CONTEXT_FLAGS.ALL);
|
|
191
|
-
const ctx = parseContext(ctxBuf);
|
|
192
|
-
for (const [id, bp] of this.breakpoints) {
|
|
193
|
-
if (bp.pid !== processId) continue;
|
|
194
|
-
const drBit = 1n << BigInt(bp.drIndex);
|
|
195
|
-
if (ctx.dr6 & drBit) {
|
|
196
|
-
bp.hitCount++;
|
|
197
|
-
bp.lastHit = Date.now();
|
|
198
|
-
ctxBuf.writeBigUInt64LE(0n, 104);
|
|
199
|
-
SetThreadContext(hThread, ctxBuf);
|
|
200
|
-
return {
|
|
201
|
-
breakpointId: id,
|
|
202
|
-
address: bp.address,
|
|
203
|
-
accessAddress: bp.address,
|
|
204
|
-
instructionAddress: toHex(ctx.rip),
|
|
205
|
-
threadId,
|
|
206
|
-
accessType: bp.access,
|
|
207
|
-
timestamp: Date.now(),
|
|
208
|
-
registers: {
|
|
209
|
-
rax: toHex(ctx.rax),
|
|
210
|
-
rbx: toHex(ctx.rbx),
|
|
211
|
-
rcx: toHex(ctx.rcx),
|
|
212
|
-
rdx: toHex(ctx.rdx),
|
|
213
|
-
rsi: toHex(ctx.rsi),
|
|
214
|
-
rdi: toHex(ctx.rdi),
|
|
215
|
-
rsp: toHex(ctx.rsp),
|
|
216
|
-
rbp: toHex(ctx.rbp),
|
|
217
|
-
r8: toHex(ctx.r8),
|
|
218
|
-
r9: toHex(ctx.r9),
|
|
219
|
-
r10: toHex(ctx.r10),
|
|
220
|
-
r11: toHex(ctx.r11),
|
|
221
|
-
r12: toHex(ctx.r12),
|
|
222
|
-
r13: toHex(ctx.r13),
|
|
223
|
-
r14: toHex(ctx.r14),
|
|
224
|
-
r15: toHex(ctx.r15),
|
|
225
|
-
rip: toHex(ctx.rip),
|
|
226
|
-
rflags: `0x${ctx.eflags.toString(16).toUpperCase()}`
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return null;
|
|
232
|
-
} finally {
|
|
233
|
-
CloseHandle(hThread);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
const hardwareBreakpointEngine = new HardwareBreakpointEngine();
|
|
238
|
-
//#endregion
|
|
239
|
-
export { HardwareBreakpointEngine, hardwareBreakpointEngine };
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { t as logger } from "./logger-Dh_xb7_2.mjs";
|
|
2
|
-
import { ct as HEAP_SPRAY_THRESHOLD, lt as HEAP_SUSPICIOUS_BLOCK_SIZE, ot as HEAP_ENUMERATE_MAX_BLOCKS, st as HEAP_SPRAY_SIZE_TOLERANCE } from "./constants-CDZLOoVv.mjs";
|
|
3
|
-
import { b as openProcessForMemory, d as ReadProcessMemory, t as CloseHandle } from "./Win32API-C2kjj0ze.mjs";
|
|
4
|
-
import { m as TH32CS } from "./Win32Debug-CKrGOTpo.mjs";
|
|
5
|
-
import koffi from "koffi";
|
|
6
|
-
//#region src/native/HeapAnalyzer.types.ts
|
|
7
|
-
/** Heap block flags */
|
|
8
|
-
const LF32 = {
|
|
9
|
-
FIXED: 1,
|
|
10
|
-
FREE: 2,
|
|
11
|
-
MOVEABLE: 4
|
|
12
|
-
};
|
|
13
|
-
/** Heap flags */
|
|
14
|
-
const HF32 = {
|
|
15
|
-
DEFAULT: 1,
|
|
16
|
-
SHARED: 2
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/native/HeapAnalyzer.ts
|
|
20
|
-
/**
|
|
21
|
-
* Heap Analysis Engine.
|
|
22
|
-
*
|
|
23
|
-
* Enumerates process heaps and blocks via Toolhelp32 Snapshot APIs,
|
|
24
|
-
* provides statistical analysis and anomaly detection (spray, UAF heuristic).
|
|
25
|
-
*
|
|
26
|
-
* @module HeapAnalyzer
|
|
27
|
-
*/
|
|
28
|
-
let heapApisCache = null;
|
|
29
|
-
function loadHeapApis() {
|
|
30
|
-
const k32 = koffi.load("kernel32.dll");
|
|
31
|
-
return {
|
|
32
|
-
CreateToolhelp32Snapshot: k32.func("CreateToolhelp32Snapshot", "intptr", ["uint32", "uint32"]),
|
|
33
|
-
Heap32ListFirst: k32.func("Heap32ListFirst", "bool", ["intptr", "_Inout_ uint8_t *"]),
|
|
34
|
-
Heap32ListNext: k32.func("Heap32ListNext", "bool", ["intptr", "_Inout_ uint8_t *"]),
|
|
35
|
-
Heap32First: k32.func("Heap32First", "bool", [
|
|
36
|
-
"_Inout_ uint8_t *",
|
|
37
|
-
"uint32",
|
|
38
|
-
"uintptr_t"
|
|
39
|
-
]),
|
|
40
|
-
Heap32Next: k32.func("Heap32Next", "bool", ["_Inout_ uint8_t *"]),
|
|
41
|
-
CloseHandle: k32.func("int CloseHandle(intptr)"),
|
|
42
|
-
HEAPLIST32_SIZE: 36,
|
|
43
|
-
HEAPENTRY32_SIZE: 56
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function getHeapApis() {
|
|
47
|
-
if (!heapApisCache) heapApisCache = loadHeapApis();
|
|
48
|
-
return heapApisCache;
|
|
49
|
-
}
|
|
50
|
-
const SIZE_RANGES = [
|
|
51
|
-
[
|
|
52
|
-
"0-64B",
|
|
53
|
-
0,
|
|
54
|
-
64
|
|
55
|
-
],
|
|
56
|
-
[
|
|
57
|
-
"64-256B",
|
|
58
|
-
64,
|
|
59
|
-
256
|
|
60
|
-
],
|
|
61
|
-
[
|
|
62
|
-
"256B-1KB",
|
|
63
|
-
256,
|
|
64
|
-
1024
|
|
65
|
-
],
|
|
66
|
-
[
|
|
67
|
-
"1-4KB",
|
|
68
|
-
1024,
|
|
69
|
-
4096
|
|
70
|
-
],
|
|
71
|
-
[
|
|
72
|
-
"4-16KB",
|
|
73
|
-
4096,
|
|
74
|
-
16384
|
|
75
|
-
],
|
|
76
|
-
[
|
|
77
|
-
"16-64KB",
|
|
78
|
-
16384,
|
|
79
|
-
65536
|
|
80
|
-
],
|
|
81
|
-
[
|
|
82
|
-
"64KB-1MB",
|
|
83
|
-
65536,
|
|
84
|
-
1048576
|
|
85
|
-
],
|
|
86
|
-
[
|
|
87
|
-
">1MB",
|
|
88
|
-
1048576,
|
|
89
|
-
Number.MAX_SAFE_INTEGER
|
|
90
|
-
]
|
|
91
|
-
];
|
|
92
|
-
function classifyBlock(size) {
|
|
93
|
-
for (let i = 0; i < SIZE_RANGES.length; i++) {
|
|
94
|
-
const range = SIZE_RANGES[i];
|
|
95
|
-
if (size >= range[1] && size < range[2]) return i;
|
|
96
|
-
}
|
|
97
|
-
return SIZE_RANGES.length - 1;
|
|
98
|
-
}
|
|
99
|
-
var HeapAnalyzer = class {
|
|
100
|
-
/**
|
|
101
|
-
* Enumerate all heaps in a process and return info + stats.
|
|
102
|
-
*/
|
|
103
|
-
async enumerateHeaps(pid) {
|
|
104
|
-
const apis = getHeapApis();
|
|
105
|
-
const hSnap = apis.CreateToolhelp32Snapshot(TH32CS.SNAPHEAPLIST, pid);
|
|
106
|
-
if (hSnap === -1n && typeof hSnap === "bigint") throw new Error(`Failed to create heap snapshot for PID ${pid}`);
|
|
107
|
-
const heaps = [];
|
|
108
|
-
try {
|
|
109
|
-
const hlBuf = Buffer.alloc(apis.HEAPLIST32_SIZE);
|
|
110
|
-
hlBuf.writeBigUInt64LE(BigInt(apis.HEAPLIST32_SIZE), 0);
|
|
111
|
-
let hasHeap = apis.Heap32ListFirst(hSnap, hlBuf);
|
|
112
|
-
while (hasHeap) {
|
|
113
|
-
const processId = hlBuf.readUInt32LE(8);
|
|
114
|
-
const heapId = hlBuf.readBigUInt64LE(12);
|
|
115
|
-
const flags = hlBuf.readUInt32LE(20);
|
|
116
|
-
const blocks = await this.enumerateBlocksInternal(pid, heapId, HEAP_ENUMERATE_MAX_BLOCKS);
|
|
117
|
-
heaps.push({
|
|
118
|
-
heapId: `0x${heapId.toString(16)}`,
|
|
119
|
-
processId,
|
|
120
|
-
flags,
|
|
121
|
-
isDefault: (flags & HF32.DEFAULT) !== 0,
|
|
122
|
-
blockCount: blocks.length,
|
|
123
|
-
totalSize: blocks.reduce((sum, b) => sum + b.size, 0)
|
|
124
|
-
});
|
|
125
|
-
hlBuf.writeBigUInt64LE(BigInt(apis.HEAPLIST32_SIZE), 0);
|
|
126
|
-
hasHeap = apis.Heap32ListNext(hSnap, hlBuf);
|
|
127
|
-
}
|
|
128
|
-
} finally {
|
|
129
|
-
apis.CloseHandle(hSnap);
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
heaps,
|
|
133
|
-
stats: this.computeStats(heaps, [])
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Enumerate blocks within a specific heap.
|
|
138
|
-
*/
|
|
139
|
-
async enumerateBlocks(pid, heapId, options) {
|
|
140
|
-
const id = BigInt(heapId);
|
|
141
|
-
const max = options?.maxBlocks ?? HEAP_ENUMERATE_MAX_BLOCKS;
|
|
142
|
-
return this.enumerateBlocksInternal(pid, id, max);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Get full statistical breakdown for all heaps.
|
|
146
|
-
*/
|
|
147
|
-
async getStats(pid) {
|
|
148
|
-
const { heaps } = await this.enumerateHeaps(pid);
|
|
149
|
-
const allBlocks = [];
|
|
150
|
-
for (const heap of heaps) {
|
|
151
|
-
const blocks = await this.enumerateBlocksInternal(pid, BigInt(heap.heapId), HEAP_ENUMERATE_MAX_BLOCKS);
|
|
152
|
-
allBlocks.push(...blocks);
|
|
153
|
-
}
|
|
154
|
-
return this.computeStats(heaps, allBlocks);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Detect heap anomalies: spray, UAF heuristic, suspicious sizes.
|
|
158
|
-
*/
|
|
159
|
-
async detectAnomalies(pid) {
|
|
160
|
-
const anomalies = [];
|
|
161
|
-
const { heaps } = await this.enumerateHeaps(pid);
|
|
162
|
-
for (const heap of heaps) {
|
|
163
|
-
const blocks = await this.enumerateBlocksInternal(pid, BigInt(heap.heapId), HEAP_ENUMERATE_MAX_BLOCKS);
|
|
164
|
-
this.detectSpray(blocks, heap.heapId, anomalies);
|
|
165
|
-
this.detectSuspiciousSizes(blocks, heap.heapId, anomalies);
|
|
166
|
-
await this.detectPossibleUaf(pid, blocks, heap.heapId, anomalies);
|
|
167
|
-
}
|
|
168
|
-
return anomalies;
|
|
169
|
-
}
|
|
170
|
-
async enumerateBlocksInternal(pid, heapId, maxBlocks) {
|
|
171
|
-
const apis = getHeapApis();
|
|
172
|
-
const blocks = [];
|
|
173
|
-
const heBuf = Buffer.alloc(apis.HEAPENTRY32_SIZE);
|
|
174
|
-
heBuf.writeBigUInt64LE(BigInt(apis.HEAPENTRY32_SIZE), 0);
|
|
175
|
-
let hasBlock = apis.Heap32First(heBuf, pid, heapId);
|
|
176
|
-
while (hasBlock && blocks.length < maxBlocks) {
|
|
177
|
-
const address = heBuf.readBigUInt64LE(16);
|
|
178
|
-
const blockSize = Number(heBuf.readBigUInt64LE(24));
|
|
179
|
-
const flags = heBuf.readUInt32LE(32);
|
|
180
|
-
blocks.push({
|
|
181
|
-
address: `0x${address.toString(16)}`,
|
|
182
|
-
size: blockSize,
|
|
183
|
-
flags,
|
|
184
|
-
heapId: `0x${heapId.toString(16)}`,
|
|
185
|
-
isFree: (flags & LF32.FREE) !== 0
|
|
186
|
-
});
|
|
187
|
-
heBuf.writeBigUInt64LE(BigInt(apis.HEAPENTRY32_SIZE), 0);
|
|
188
|
-
hasBlock = apis.Heap32Next(heBuf);
|
|
189
|
-
}
|
|
190
|
-
return blocks;
|
|
191
|
-
}
|
|
192
|
-
computeStats(heaps, blocks) {
|
|
193
|
-
const buckets = SIZE_RANGES.map(([range]) => ({
|
|
194
|
-
range,
|
|
195
|
-
count: 0,
|
|
196
|
-
totalBytes: 0
|
|
197
|
-
}));
|
|
198
|
-
let totalSize = 0;
|
|
199
|
-
let freeSize = 0;
|
|
200
|
-
let largestBlock = 0;
|
|
201
|
-
let smallestBlock = Number.MAX_SAFE_INTEGER;
|
|
202
|
-
for (const block of blocks) {
|
|
203
|
-
totalSize += block.size;
|
|
204
|
-
if (block.isFree) freeSize += block.size;
|
|
205
|
-
if (block.size > largestBlock) largestBlock = block.size;
|
|
206
|
-
if (!block.isFree && block.size < smallestBlock) smallestBlock = block.size;
|
|
207
|
-
const idx = classifyBlock(block.size);
|
|
208
|
-
buckets[idx].count++;
|
|
209
|
-
buckets[idx].totalBytes += block.size;
|
|
210
|
-
}
|
|
211
|
-
if (smallestBlock === Number.MAX_SAFE_INTEGER) smallestBlock = 0;
|
|
212
|
-
if (totalSize === 0 && heaps.length > 0) totalSize = heaps.reduce((s, h) => s + h.totalSize, 0);
|
|
213
|
-
return {
|
|
214
|
-
totalHeaps: heaps.length,
|
|
215
|
-
totalBlocks: blocks.length || heaps.reduce((s, h) => s + h.blockCount, 0),
|
|
216
|
-
totalSize,
|
|
217
|
-
freeSize,
|
|
218
|
-
usedSize: totalSize - freeSize,
|
|
219
|
-
largestBlock,
|
|
220
|
-
smallestBlock,
|
|
221
|
-
averageBlockSize: blocks.length > 0 ? Math.round(totalSize / blocks.length) : 0,
|
|
222
|
-
sizeDistribution: buckets,
|
|
223
|
-
fragmentationRatio: totalSize > 0 ? freeSize / totalSize : 0
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
detectSpray(blocks, heapId, anomalies) {
|
|
227
|
-
const sizeGroups = /* @__PURE__ */ new Map();
|
|
228
|
-
for (const block of blocks) {
|
|
229
|
-
if (block.isFree) continue;
|
|
230
|
-
const rounded = Math.round(block.size / HEAP_SPRAY_SIZE_TOLERANCE) * HEAP_SPRAY_SIZE_TOLERANCE;
|
|
231
|
-
const group = sizeGroups.get(rounded) ?? [];
|
|
232
|
-
group.push(block);
|
|
233
|
-
sizeGroups.set(rounded, group);
|
|
234
|
-
}
|
|
235
|
-
for (const [size, group] of sizeGroups) if (group.length >= HEAP_SPRAY_THRESHOLD) anomalies.push({
|
|
236
|
-
type: "heap_spray_pattern",
|
|
237
|
-
severity: "high",
|
|
238
|
-
address: group[0].address,
|
|
239
|
-
details: `${group.length} blocks of ~${size} bytes detected — possible heap spray`,
|
|
240
|
-
heapId
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
detectSuspiciousSizes(blocks, heapId, anomalies) {
|
|
244
|
-
for (const block of blocks) if (block.size === 0) anomalies.push({
|
|
245
|
-
type: "suspicious_size",
|
|
246
|
-
severity: "medium",
|
|
247
|
-
address: block.address,
|
|
248
|
-
details: "Block with zero size",
|
|
249
|
-
heapId
|
|
250
|
-
});
|
|
251
|
-
else if (block.size > HEAP_SUSPICIOUS_BLOCK_SIZE) anomalies.push({
|
|
252
|
-
type: "suspicious_size",
|
|
253
|
-
severity: "medium",
|
|
254
|
-
address: block.address,
|
|
255
|
-
details: `Unusually large block: ${(block.size / (1024 * 1024)).toFixed(1)} MB`,
|
|
256
|
-
heapId
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
async detectPossibleUaf(pid, blocks, heapId, anomalies) {
|
|
260
|
-
const sampled = blocks.filter((b) => b.isFree && b.size >= 8).slice(0, 100);
|
|
261
|
-
let hProcess = null;
|
|
262
|
-
try {
|
|
263
|
-
hProcess = openProcessForMemory(pid);
|
|
264
|
-
for (const block of sampled) {
|
|
265
|
-
const addr = BigInt(block.address);
|
|
266
|
-
const data = ReadProcessMemory(hProcess, addr, 8);
|
|
267
|
-
if (data && data.readBigUInt64LE(0) !== 0n) anomalies.push({
|
|
268
|
-
type: "possible_uaf",
|
|
269
|
-
severity: "low",
|
|
270
|
-
address: block.address,
|
|
271
|
-
details: `Free block has non-zero data: 0x${data.readBigUInt64LE(0).toString(16)}`,
|
|
272
|
-
heapId
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
} catch (e) {
|
|
276
|
-
logger.debug(`UAF check failed for PID ${pid}: ${e}`);
|
|
277
|
-
} finally {
|
|
278
|
-
if (hProcess) CloseHandle(hProcess);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
const heapAnalyzer = new HeapAnalyzer();
|
|
283
|
-
//#endregion
|
|
284
|
-
export { HeapAnalyzer, heapAnalyzer };
|