@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Rt as e}from"./constants-Cp6hBrrx.mjs";function t(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}function n(e,n){return t({success:!1,tool:e,error:n instanceof Error?n.message:String(n)})}var r=class{sessionManager;constructor(e){this.sessionManager=e}async handleScanList(e){try{let e=this.sessionManager.listSessions();return t({success:!0,sessions:e,count:e.length})}catch(e){return n(`memory_scan_session`,e)}}async handleScanDelete(e){try{return t({success:!0,deleted:this.sessionManager.deleteSession(e.sessionId)})}catch(e){return n(`memory_scan_session`,e)}}async handleScanExport(e){try{return t({success:!0,exportedData:this.sessionManager.exportSession(e.sessionId)})}catch(e){return n(`memory_scan_session`,e)}}};function i(t){return t===void 0||!Number.isFinite(t)||t<=0?e:Math.min(t,e)}function a(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}function o(e,t){return a({success:!1,tool:e,error:t instanceof Error?t.message:String(t)})}var s=class{scanner;eventBus;constructor(e,t){this.scanner=e,this.eventBus=t}async handleFirstScan(e){try{let t={valueType:e.valueType,alignment:e.alignment,maxResults:i(e.maxResults),regionFilter:e.regionFilter,onProgress:e.onProgress},n=await this.scanner.firstScan(e.pid,e.value,t);return this.eventBus?.emit(`memory:scan_completed`,{scanType:`first`,resultCount:n.totalMatches??0,timestamp:new Date().toISOString()}),a({success:!0,...n,hint:n.totalMatches>0?`Found ${n.totalMatches} matches. Use memory_next_scan with sessionId "${n.sessionId}" to narrow down.`:`No matches found. Try a different value or type.`})}catch(e){return o(`memory_first_scan`,e)}}async handleNextScan(e){try{let t=await this.scanner.nextScan(e.sessionId,e.mode,e.value,e.value2);return a({success:!0,...t,hint:t.totalMatches<=10?`Few matches remaining — inspect these addresses.`:`${t.totalMatches} matches remain. Continue narrowing with memory_next_scan.`})}catch(e){return o(`memory_next_scan`,e)}}async handleUnknownScan(e){try{let t={valueType:e.valueType,alignment:e.alignment,maxResults:i(e.maxResults),regionFilter:e.regionFilter,onProgress:e.onProgress},n=await this.scanner.unknownInitialScan(e.pid,t);return a({success:!0,...n,hint:`Captured ${n.totalMatches} addresses. Use memory_next_scan with changed/unchanged/increased/decreased to narrow.`})}catch(e){return o(`memory_unknown_scan`,e)}}async handlePointerScan(e){try{return a({success:!0,...await this.scanner.pointerScan(e.pid,e.targetAddress,{maxResults:i(e.maxResults),moduleOnly:e.moduleOnly})})}catch(e){return o(`memory_pointer_scan`,e)}}async handleGroupScan(e){try{return a({success:!0,...await this.scanner.groupScan(e.pid,e.pattern,{alignment:e.alignment,maxResults:i(e.maxResults)})})}catch(e){return o(`memory_group_scan`,e)}}};function c(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}function l(e,t){return c({success:!1,tool:e,error:t instanceof Error?t.message:String(t)})}var u=class{ptrEngine;constructor(e){this.ptrEngine=e}async handlePointerChainScan(e){try{let t=await this.ptrEngine.scan(e.pid,e.targetAddress,{maxDepth:e.maxDepth,maxOffset:e.maxOffset,staticOnly:e.staticOnly,modules:e.modules,maxResults:e.maxResults});return c({success:!0,...t,hint:t.totalFound>0?`Found ${t.totalFound} pointer chains. Static chains survive process restarts.`:`No pointer chains found. Try increasing maxDepth or maxOffset.`})}catch(e){return l(`memory_pointer_chain_scan`,e)}}async handlePointerChainValidate(e){try{let t=JSON.parse(e.chains),n=await this.ptrEngine.validateChains(e.pid,t);return c({success:!0,results:n,validCount:n.filter(e=>e.isValid).length,totalChecked:t.length})}catch(e){return l(`memory_pointer_chain_validate`,e)}}async handlePointerChainResolve(e){try{let t=JSON.parse(e.chain),n=await this.ptrEngine.resolveChain(e.pid,t);return c({success:!0,chainId:t.id,resolvedAddress:n,isResolvable:n!==null})}catch(e){return l(`memory_pointer_chain_resolve`,e)}}async handlePointerChainExport(e){try{let t=JSON.parse(e.chains);return c({success:!0,exportedData:this.ptrEngine.exportChains(t),chainCount:t.length})}catch(e){return l(`memory_pointer_chain_export`,e)}}};function d(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}function f(e,t){return d({success:!1,tool:e,error:t instanceof Error?t.message:String(t)})}const p={int8_t:`int8`,uint8_t:`uint8`,int16_t:`int16`,uint16_t:`uint16`,int32_t:`int32`,uint32_t:`uint32`,int64_t:`int64`,uint64_t:`uint64`,void_ptr:`pointer`,char_ptr:`string_ptr`};function m(e){if(typeof e!=`string`||e.length===0)return`unknown`;let t=e.toLowerCase().replace(/\s+/g,`_`).replace(/\*/g,`_ptr`);return p[t]??t}function h(e){if(!e||typeof e!=`object`)throw Error(`structure must be a JSON object`);let t=e,n=(Array.isArray(t.fields)?t.fields:[]).map((e,t)=>{let n=e;return{offset:typeof n.offset==`number`?n.offset:0,size:typeof n.size==`number`?n.size:1,type:m(n.type),name:typeof n.name==`string`&&n.name.length>0?n.name:`field_${t}`,value:typeof n.value==`string`?n.value:``,confidence:typeof n.confidence==`number`?n.confidence:1,notes:typeof n.notes==`string`?n.notes:void 0}}),r=n.reduce((e,t)=>Math.max(e,t.offset+t.size),0),i=typeof t.totalSize==`number`?t.totalSize:typeof t.size==`number`?t.size:r;return{baseAddress:typeof t.baseAddress==`string`?t.baseAddress:`0x0`,totalSize:i,fields:n,vtableAddress:typeof t.vtableAddress==`string`?t.vtableAddress:void 0,className:typeof t.className==`string`?t.className:void 0,baseClasses:Array.isArray(t.baseClasses)?t.baseClasses.filter(e=>typeof e==`string`):void 0,timestamp:typeof t.timestamp==`number`?t.timestamp:Date.now()}}var g=class{structAnalyzer;constructor(e){this.structAnalyzer=e}async handleStructureAnalyze(e){try{let t=await this.structAnalyzer.analyzeStructure(e.pid,e.address,{size:e.size,otherInstances:e.otherInstances,parseRtti:e.parseRtti});return d({success:!0,...t,hint:t.className?`Detected class: ${t.className}${t.baseClasses?.length?` (inherits: ${t.baseClasses.join(` → `)})`:``}`:`Inferred ${t.fields.length} fields. Use memory_structure_export_c to export as C struct.`})}catch(e){return f(`memory_structure_analyze`,e)}}async handleVtableParse(e){try{return d({success:!0,...await this.structAnalyzer.parseVtable(e.pid,e.vtableAddress)})}catch(e){return f(`memory_vtable_parse`,e)}}async handleStructureExportC(e){try{let t=h(JSON.parse(e.structure));return d({success:!0,...this.structAnalyzer.exportToCStruct(t,e.name)})}catch(e){return f(`memory_structure_export_c`,e)}}async handleStructureCompare(e){try{let t=await this.structAnalyzer.compareInstances(e.pid,e.address1,e.address2,e.size);return d({success:!0,matchingFieldCount:t.matching.length,differingFieldCount:t.differing.length,...t})}catch(e){return f(`memory_structure_compare`,e)}}};function _(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}function v(e,t){return _({success:!1,tool:e,error:t instanceof Error?t.message:String(t)})}var y=class{bpEngine;injector;constructor(e,t){this.bpEngine=e,this.injector=t}async handleBreakpointSet(e){try{return _({success:!0,...await this.bpEngine.setBreakpoint(e.pid,e.address,e.access,e.size??4),hint:`Hardware breakpoint set on DR register. Use memory_breakpoint with action='trace' to collect hits.`})}catch(e){return v(`memory_breakpoint`,e)}}async handleBreakpointRemove(e){try{return _({success:!0,removed:await this.bpEngine.removeBreakpoint(e.breakpointId)})}catch(e){return v(`memory_breakpoint`,e)}}async handleBreakpointList(e){try{let e=this.bpEngine.listBreakpoints();return _({success:!0,breakpoints:e,count:e.length})}catch(e){return v(`memory_breakpoint`,e)}}async handleBreakpointTrace(e){try{let t=await this.bpEngine.traceAccess(e.pid,e.address,e.access,e.maxHits,e.timeoutMs);return _({success:!0,hits:t,hitCount:t.length,hint:t.length>0?`${t.length} accesses captured. Check instructionAddress to find the code accessing this address.`:`No hits captured within timeout.`})}catch(e){return v(`memory_breakpoint`,e)}}async handlePatchBytes(e){try{let t=await this.injector.patchBytes(e.pid,e.address,e.bytes);return _({success:!0,...t,hint:`Patch applied. Use memory_patch_undo with patchId "${t.id}" to restore.`})}catch(e){return v(`memory_patch_bytes`,e)}}async handlePatchNop(e){try{return _({success:!0,...await this.injector.nopBytes(e.pid,e.address,e.count),hint:`${e.count} bytes NOP'd. Use memory_patch_undo to restore.`})}catch(e){return v(`memory_patch_nop`,e)}}async handlePatchUndo(e){try{return _({success:!0,restored:await this.injector.unpatch(e.patchId)})}catch(e){return v(`memory_patch_undo`,e)}}async handleCodeCaves(e){try{let t=await this.injector.findCodeCaves(e.pid,e.minSize);return _({success:!0,caves:t,count:t.length})}catch(e){return v(`memory_code_caves`,e)}}};function b(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}function x(e,t){return b({success:!1,tool:e,error:t instanceof Error?t.message:String(t)})}var S=class{memCtrl;constructor(e){this.memCtrl=e}async handleWriteValue(e){try{return b({success:!0,...await this.memCtrl.writeValue(e.pid,e.address,e.value,e.valueType),hint:`Use memory_write_history with action='undo' to revert.`})}catch(e){return x(`memory_write_value`,e)}}async handleFreeze(e){try{let t=await this.memCtrl.freeze(e.pid,e.address,e.value,e.valueType,e.intervalMs);return b({success:!0,...t,hint:`Frozen. Use memory_freeze with action="unfreeze" and freezeId "${t.id}" to stop.`})}catch(e){return x(`memory_freeze`,e)}}async handleUnfreeze(e){try{return b({success:!0,unfrozen:await this.memCtrl.unfreeze(e.freezeId)})}catch(e){return x(`memory_freeze`,e)}}async handleDump(e){try{return b({success:!0,dump:await this.memCtrl.dumpMemoryHex(e.pid,e.address,e.size??256)})}catch(e){return x(`memory_dump`,e)}}async handleWriteUndo(e){try{let e=await this.memCtrl.undo();return b({success:!0,undone:e!==null,entry:e})}catch(e){return x(`memory_write_history`,e)}}async handleWriteRedo(e){try{let e=await this.memCtrl.redo();return b({success:!0,redone:e!==null,entry:e})}catch(e){return x(`memory_write_history`,e)}}};function C(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}function w(e,t){return C({success:!1,tool:e,error:t instanceof Error?t.message:String(t)})}var T=class{speedhackEngine;heapAnalyzer;peAnalyzer;antiCheatDetector;constructor(e,t,n,r){this.speedhackEngine=e,this.heapAnalyzer=t,this.peAnalyzer=n,this.antiCheatDetector=r}async handleSpeedhackApply(e){try{return C({...await this.speedhackEngine.apply(e.pid,e.speed),success:!0,hint:`Speedhack active (${e.speed}x). Use memory_speedhack({ action: 'set' }) to adjust.`})}catch(e){return w(`memory_speedhack`,e)}}async handleSpeedhackSet(e){try{return C({success:!0,updated:await this.speedhackEngine.setSpeed(e.pid,e.speed),newSpeed:e.speed})}catch(e){return w(`memory_speedhack`,e)}}async handleHeapEnumerate(e){try{let t=await this.heapAnalyzer.enumerateHeaps(e.pid);return C({success:!0,...t,hint:`Enumerated ${t.heaps.length} heaps. Use memory_heap_stats for statistics or memory_heap_anomalies to check for issues.`})}catch(e){return w(`memory_heap_enumerate`,e)}}async handleHeapStats(e){try{return C({success:!0,...await this.heapAnalyzer.getStats(e.pid)})}catch(e){return w(`memory_heap_stats`,e)}}async handleHeapAnomalies(e){try{let t=await this.heapAnalyzer.detectAnomalies(e.pid);return C({success:!0,anomalies:t,count:t.length,hint:t.length>0?`Found ${t.length} anomalies — inspect types for spray, UAF, or suspicious patterns.`:`No heap anomalies detected.`})}catch(e){return w(`memory_heap_anomalies`,e)}}async handlePEHeaders(e){try{return C({success:!0,...await this.peAnalyzer.parseHeaders(e.pid,e.moduleBase)})}catch(e){return w(`memory_pe_headers`,e)}}async handlePEImportsExports(e){try{let t=e.table||`both`,n=e.moduleBase,r=e.pid,i={success:!0};return(t===`imports`||t===`both`)&&(i.imports=await this.peAnalyzer.parseImports(r,n)),(t===`exports`||t===`both`)&&(i.exports=await this.peAnalyzer.parseExports(r,n)),C(i)}catch(e){return w(`memory_pe_imports_exports`,e)}}async handleInlineHookDetect(e){try{let t=await this.peAnalyzer.detectInlineHooks(e.pid,e.moduleName);return C({success:!0,hooks:t,count:t.length,hint:t.length>0?`Detected ${t.length} inline hooks — check hookType and jumpTarget for each.`:`No inline hooks detected — exports match disk bytes.`})}catch(e){return w(`memory_inline_hook_detect`,e)}}async handleAntiCheatDetect(e){try{let t=await this.antiCheatDetector.detect(e.pid);return C({success:!0,detections:t,count:t.length,hint:t.length>0?`Found ${t.length} anti-debug mechanisms. Each includes a bypassSuggestion.`:`No anti-debug mechanisms detected in imports.`})}catch(e){return w(`memory_anticheat_detect`,e)}}async handleGuardPages(e){try{let{guardPages:t,stats:n}=await this.antiCheatDetector.scanGuardPages(e.pid);return C({success:!0,guardPages:t,count:t.length,scan:n,hint:n.truncated?`Scan stopped after ${n.scannedRegions} regions in ${n.durationMs}ms to avoid hanging. Results may be partial.`:t.length>0?`Found ${t.length} guard page regions — these may indicate anti-tampering.`:`No guard pages found.`})}catch(e){return w(`memory_guard_pages`,e)}}async handleIntegrityCheck(e){try{let{sections:t,stats:n}=await this.antiCheatDetector.scanIntegrity(e.pid,e.moduleName),r=t.filter(e=>e.isModified);return C({success:!0,sections:t,totalChecked:t.length,modifiedCount:r.length,scan:n,hint:n.truncated?`Checked ${n.scannedSections} executable section(s) across ${n.scannedModules} module(s) before hitting safety limits. Results may be partial.`:r.length>0?`${r.length} section(s) modified — code may have been patched or hooked.`:`All checked sections match disk — no runtime modifications detected.`})}catch(e){return w(`memory_integrity_check`,e)}}},E=class{sessions;scans;ptrChains;structures;hooks;readwrite;integrity;constructor(e,t,n,i,a,o,c,l,d,f,p,m){this.sessions=new r(t),this.scans=new s(e,m),this.ptrChains=new u(n),this.structures=new g(i),this.hooks=new y(a,o),this.readwrite=new S(c),this.integrity=new T(l,d,f,p)}handleScanSessionDispatch(e){switch(String(e.action??``)){case`delete`:return this.sessions.handleScanDelete(e);case`export`:return this.sessions.handleScanExport(e);default:return this.sessions.handleScanList(e)}}handleScanList=e=>this.sessions.handleScanList(e);handleScanDelete=e=>this.sessions.handleScanDelete(e);handleScanExport=e=>this.sessions.handleScanExport(e);handleFirstScan=e=>this.scans.handleFirstScan(e);handleNextScan=e=>this.scans.handleNextScan(e);handleUnknownScan=e=>this.scans.handleUnknownScan(e);handlePointerScan=e=>this.scans.handlePointerScan(e);handleGroupScan=e=>this.scans.handleGroupScan(e);handlePointerChainDispatch(e){switch(String(e.action??``)){case`validate`:return this.ptrChains.handlePointerChainValidate(e);case`resolve`:return this.ptrChains.handlePointerChainResolve(e);case`export`:return this.ptrChains.handlePointerChainExport(e);default:return this.ptrChains.handlePointerChainScan(e)}}handlePointerChainScan=e=>this.ptrChains.handlePointerChainScan(e);handlePointerChainValidate=e=>this.ptrChains.handlePointerChainValidate(e);handlePointerChainResolve=e=>this.ptrChains.handlePointerChainResolve(e);handlePointerChainExport=e=>this.ptrChains.handlePointerChainExport(e);handleStructureAnalyze=e=>this.structures.handleStructureAnalyze(e);handleVtableParse=e=>this.structures.handleVtableParse(e);handleStructureExportC=e=>this.structures.handleStructureExportC(e);handleStructureCompare=e=>this.structures.handleStructureCompare(e);handleBreakpointDispatch(e){switch(String(e.action??``)){case`remove`:return this.hooks.handleBreakpointRemove(e);case`list`:return this.hooks.handleBreakpointList(e);case`trace`:return this.hooks.handleBreakpointTrace(e);default:return this.hooks.handleBreakpointSet(e)}}handleBreakpointSet=e=>this.hooks.handleBreakpointSet(e);handleBreakpointRemove=e=>this.hooks.handleBreakpointRemove(e);handleBreakpointList=e=>this.hooks.handleBreakpointList(e);handleBreakpointTrace=e=>this.hooks.handleBreakpointTrace(e);handlePatchBytes=e=>this.hooks.handlePatchBytes(e);handlePatchNop=e=>this.hooks.handlePatchNop(e);handlePatchUndo=e=>this.hooks.handlePatchUndo(e);handleCodeCaves=e=>this.hooks.handleCodeCaves(e);handleFreezeDispatch(e){return String(e.action??``)===`unfreeze`?this.readwrite.handleUnfreeze(e):this.readwrite.handleFreeze(e)}handleWriteHistoryDispatch(e){return String(e.action??``)===`redo`?this.readwrite.handleWriteRedo(e):this.readwrite.handleWriteUndo(e)}handleWriteValue=e=>this.readwrite.handleWriteValue(e);handleFreeze=e=>this.readwrite.handleFreeze(e);handleUnfreeze=e=>this.readwrite.handleUnfreeze(e);handleDump=e=>this.readwrite.handleDump(e);handleWriteUndo=e=>this.readwrite.handleWriteUndo(e);handleWriteRedo=e=>this.readwrite.handleWriteRedo(e);handleSpeedhackDispatch(e){return String(e.action??``)===`set`?this.integrity.handleSpeedhackSet(e):this.integrity.handleSpeedhackApply(e)}handleSpeedhackApply=e=>this.integrity.handleSpeedhackApply(e);handleSpeedhackSet=e=>this.integrity.handleSpeedhackSet(e);handleHeapEnumerate=e=>this.integrity.handleHeapEnumerate(e);handleHeapStats=e=>this.integrity.handleHeapStats(e);handleHeapAnomalies=e=>this.integrity.handleHeapAnomalies(e);handlePEHeaders=e=>this.integrity.handlePEHeaders(e);handlePEImportsExports=e=>this.integrity.handlePEImportsExports(e);handleInlineHookDetect=e=>this.integrity.handleInlineHookDetect(e);handleAntiCheatDetect=e=>this.integrity.handleAntiCheatDetect(e);handleGuardPages=e=>this.integrity.handleGuardPages(e);handleIntegrityCheck=e=>this.integrity.handleIntegrityCheck(e)};export{E as MemoryScanHandlers};
|
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import{t as e}from"./logger-sBC6IdRT.mjs";import{a as t,o as n,s as r,t as i}from"./parse-args-Cuk7-xUt.mjs";import{o as a,s as o}from"./PageController-D9jVkH0i.mjs";import"./definitions-CCP9gphV.mjs";var s=class{pageController;injectedHooks=new Map;constructor(e){this.pageController=e}hasAttachedTargetSession(){return this.pageController.hasAttachedTargetSession()}async evaluateInAttachedTarget(e){return await this.pageController.evaluateAttachedTarget(e,{returnByValue:!0,awaitPromise:!0})}async addScriptToAttachedTarget(e){await this.pageController.addScriptToAttachedTarget(e)}async handleAIHookInject(n){try{let i=r(n,`hookId`),s=r(n,`code`),c=t(n,`method`,`evaluate`);if(this.hasAttachedTargetSession())c===`evaluateOnNewDocument`?(await this.addScriptToAttachedTarget(s),e.info(`Hook injected into attached target (evaluateOnNewDocument): ${i}`)):(await this.evaluateInAttachedTarget(s),e.info(`Hook injected into attached target (evaluate): ${i}`));else{let t=await this.pageController.getPage();c===`evaluateOnNewDocument`?(await a(t,s),e.info(`Hook injected (evaluateOnNewDocument): ${i}`)):(await o(t,s),e.info(`Hook injected (evaluate): ${i}`))}return this.injectedHooks.set(i,{code:s,injectionTime:Date.now()}),{content:[{type:`text`,text:JSON.stringify({success:!0,hookId:i,message:`Hook (: ${c})`,injectionTime:new Date().toISOString()},null,2)}]}}catch(t){return e.error(`Hook injection failed`,t),{content:[{type:`text`,text:JSON.stringify({success:!1,error:t instanceof Error?t.message:String(t)},null,2)}]}}}async handleAIHookGetData(t){try{let e=r(t,`hookId`),n=this.hasAttachedTargetSession()?await this.evaluateInAttachedTarget(`(() => {
|
|
2
|
+
const hookId = ${JSON.stringify(e)};
|
|
3
|
+
const hooks = globalThis.__aiHooks;
|
|
4
|
+
if (!hooks?.[hookId]) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
hookId,
|
|
9
|
+
metadata: globalThis.__aiHookMetadata?.[hookId],
|
|
10
|
+
records: hooks[hookId],
|
|
11
|
+
totalRecords: hooks[hookId].length,
|
|
12
|
+
};
|
|
13
|
+
})()`):await o(await this.pageController.getPage(),e=>window.__aiHooks?.[e]?{hookId:e,metadata:window.__aiHookMetadata?.[e],records:window.__aiHooks[e],totalRecords:window.__aiHooks[e].length}:null,e);return n?{content:[{type:`text`,text:JSON.stringify({success:!0,...n},null,2)}]}:{content:[{type:`text`,text:JSON.stringify({success:!1,message:`Hook: ${e}`},null,2)}]}}catch(t){return e.error(`Failed to get hook data`,t),{content:[{type:`text`,text:JSON.stringify({success:!1,error:t instanceof Error?t.message:String(t)},null,2)}]}}}async handleAIHookList(t){try{let e=this.hasAttachedTargetSession()?await this.evaluateInAttachedTarget(`(() => {
|
|
14
|
+
const metadata = globalThis.__aiHookMetadata;
|
|
15
|
+
const hooks = globalThis.__aiHooks;
|
|
16
|
+
if (!metadata) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
return Object.keys(metadata).map((hookId) => ({
|
|
20
|
+
hookId,
|
|
21
|
+
metadata: metadata[hookId],
|
|
22
|
+
recordCount: hooks?.[hookId]?.length || 0,
|
|
23
|
+
}));
|
|
24
|
+
})()`):await o(await this.pageController.getPage(),()=>window.__aiHookMetadata?Object.keys(window.__aiHookMetadata).map(e=>({hookId:e,metadata:window.__aiHookMetadata[e],recordCount:window.__aiHooks?.[e]?.length||0})):[]);return{content:[{type:`text`,text:JSON.stringify({success:!0,totalHooks:e.length,hooks:e},null,2)}]}}catch(t){return e.error(`Failed to list hooks`,t),{content:[{type:`text`,text:JSON.stringify({success:!1,error:t instanceof Error?t.message:String(t)},null,2)}]}}}async handleAIHookClear(n){try{let e=t(n,`hookId`);return e?(this.hasAttachedTargetSession()?await this.evaluateInAttachedTarget(`(() => {
|
|
25
|
+
const hookId = ${JSON.stringify(e)};
|
|
26
|
+
if (globalThis.__aiHooks?.[hookId]) {
|
|
27
|
+
globalThis.__aiHooks[hookId] = [];
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
})()`):await o(await this.pageController.getPage(),e=>{window.__aiHooks?.[e]&&(window.__aiHooks[e]=[])},e),{content:[{type:`text`,text:JSON.stringify({success:!0,message:`Hook: ${e}`},null,2)}]}):(this.hasAttachedTargetSession()?await this.evaluateInAttachedTarget(`(() => {
|
|
31
|
+
if (globalThis.__aiHooks) {
|
|
32
|
+
for (const key in globalThis.__aiHooks) {
|
|
33
|
+
globalThis.__aiHooks[key] = [];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
})()`):await o(await this.pageController.getPage(),()=>{if(window.__aiHooks)for(let e in window.__aiHooks)window.__aiHooks[e]=[]}),{content:[{type:`text`,text:JSON.stringify({success:!0,message:`Hook`},null,2)}]})}catch(t){return e.error(`Failed to clear hook data`,t),{content:[{type:`text`,text:JSON.stringify({success:!1,error:t instanceof Error?t.message:String(t)},null,2)}]}}}async handleAIHookToggle(t){try{let e=r(t,`hookId`),n=i(t,`enabled`);return this.hasAttachedTargetSession()?await this.evaluateInAttachedTarget(`(() => {
|
|
38
|
+
const hookId = ${JSON.stringify(e)};
|
|
39
|
+
const enabled = ${JSON.stringify(n)};
|
|
40
|
+
if (globalThis.__aiHookMetadata?.[hookId]) {
|
|
41
|
+
globalThis.__aiHookMetadata[hookId].enabled = enabled;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
})()`):await o(await this.pageController.getPage(),(e,t)=>{window.__aiHookMetadata?.[e]&&(window.__aiHookMetadata[e].enabled=t)},e,n),{content:[{type:`text`,text:JSON.stringify({success:!0,hookId:e,enabled:n,message:`Hook`},null,2)}]}}catch(t){return e.error(`Failed to toggle hook`,t),{content:[{type:`text`,text:JSON.stringify({success:!1,error:t instanceof Error?t.message:String(t)},null,2)}]}}}async handleAIHookExport(n){try{let e=t(n,`hookId`),r=t(n,`format`,`json`),i=this.hasAttachedTargetSession()?await this.evaluateInAttachedTarget(`(() => {
|
|
45
|
+
const hookId = ${JSON.stringify(e)};
|
|
46
|
+
if (hookId) {
|
|
47
|
+
return {
|
|
48
|
+
hookId,
|
|
49
|
+
metadata: globalThis.__aiHookMetadata?.[hookId],
|
|
50
|
+
records: globalThis.__aiHooks?.[hookId] || [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
metadata: globalThis.__aiHookMetadata || {},
|
|
55
|
+
records: globalThis.__aiHooks || {},
|
|
56
|
+
};
|
|
57
|
+
})()`):await o(await this.pageController.getPage(),e=>e?{hookId:e,metadata:window.__aiHookMetadata?.[e],records:window.__aiHooks?.[e]||[]}:{metadata:window.__aiHookMetadata||{},records:window.__aiHooks||{}},e);return{content:[{type:`text`,text:JSON.stringify({success:!0,format:r,data:i,exportTime:new Date().toISOString()},null,2)}]}}catch(t){return e.error(`Failed to export hook data`,t),{content:[{type:`text`,text:JSON.stringify({success:!1,error:t instanceof Error?t.message:String(t)},null,2)}]}}}async handleAIHook(e){let t=String(e.action??``);switch(t){case`inject`:return this.handleAIHookInject(e);case`get_data`:return this.handleAIHookGetData(e);case`list`:return this.handleAIHookList(e);case`clear`:return this.handleAIHookClear(e);case`toggle`:return this.handleAIHookToggle(e);case`export`:return this.handleAIHookExport(e);default:return{content:[{type:`text`,text:JSON.stringify({success:!1,error:`Unknown action: ${t}. Valid actions: inject, get_data, list, clear, toggle, export`})}]}}}};function c(e,t,n,r){let i=n?`const __stack = new Error().stack?.split('\\n').slice(1,4).join(' | ') || '';`:`const __stack = '';`,a=r?`console.log(__msg + (__stack ? ' | Stack: ' + __stack : ''));`:``;return`
|
|
58
|
+
(function() {
|
|
59
|
+
if (window.__hookPresets === undefined) window.__hookPresets = {};
|
|
60
|
+
if (window.__hookPresets['${e}']) return;
|
|
61
|
+
${t.replace(/\{\{STACK_CODE\}\}/g,i).replace(/\{\{LOG_FN\}\}/g,a)}
|
|
62
|
+
window.__hookPresets['${e}'] = true;
|
|
63
|
+
window.__aiHooks = window.__aiHooks || {};
|
|
64
|
+
window.__aiHooks['preset-${e}'] = window.__aiHooks['preset-${e}'] || [];
|
|
65
|
+
})();`}const l={eval:{description:` Hook eval() to capture dynamic code execution`,buildCode:(e,t)=>c(`eval`,`
|
|
66
|
+
const _orig = window.eval;
|
|
67
|
+
window.eval = function(code) {
|
|
68
|
+
{{STACK_CODE}}
|
|
69
|
+
const __msg = '[Hook:eval] code=' + String(code).substring(0, 200);
|
|
70
|
+
{{LOG_FN}}
|
|
71
|
+
window.__aiHooks['preset-eval'].push({ code: String(code).substring(0, 500), stack: __stack, ts: Date.now() });
|
|
72
|
+
return _orig.call(this, code);
|
|
73
|
+
};`,e,t)},"function-constructor":{description:` Hook new Function() to capture dynamic function creation`,buildCode:(e,t)=>c(`function-constructor`,`
|
|
74
|
+
const _orig = Function;
|
|
75
|
+
window.Function = function(...args) {
|
|
76
|
+
{{STACK_CODE}}
|
|
77
|
+
const __msg = '[Hook:Function] args=' + JSON.stringify(args).substring(0, 200);
|
|
78
|
+
{{LOG_FN}}
|
|
79
|
+
window.__aiHooks['preset-function-constructor'].push(
|
|
80
|
+
{
|
|
81
|
+
args: args.map(a => String(a).substring(0,200)),
|
|
82
|
+
stack: __stack,
|
|
83
|
+
ts: Date.now(),
|
|
84
|
+
});
|
|
85
|
+
return _orig(...args);
|
|
86
|
+
};
|
|
87
|
+
window.Function.prototype = _orig.prototype;`,e,t)},"atob-btoa":{description:` Hook atob/btoa to capture Base64 encode/decode operations`,buildCode:(e,t)=>c(`atob-btoa`,`
|
|
88
|
+
const _atob = window.atob.bind(window);
|
|
89
|
+
const _btoa = window.btoa.bind(window);
|
|
90
|
+
window.atob = function(s) {
|
|
91
|
+
{{STACK_CODE}}
|
|
92
|
+
const result = _atob(s);
|
|
93
|
+
const __msg = '[Hook:atob] in=' + String(s).substring(0,100) + ' out=' + result.substring(0,100);
|
|
94
|
+
{{LOG_FN}}
|
|
95
|
+
window.__aiHooks['preset-atob-btoa'].push(
|
|
96
|
+
{
|
|
97
|
+
fn:'atob',
|
|
98
|
+
input: String(s).substring(0,200),
|
|
99
|
+
output: result.substring(0,200),
|
|
100
|
+
stack: __stack,
|
|
101
|
+
ts: Date.now(),
|
|
102
|
+
});
|
|
103
|
+
return result;
|
|
104
|
+
};
|
|
105
|
+
window.btoa = function(s) {
|
|
106
|
+
{{STACK_CODE}}
|
|
107
|
+
const result = _btoa(s);
|
|
108
|
+
const __msg = '[Hook:btoa] in=' + String(s).substring(0,100) + ' out=' + result;
|
|
109
|
+
{{LOG_FN}}
|
|
110
|
+
window.__aiHooks['preset-atob-btoa'].push(
|
|
111
|
+
{
|
|
112
|
+
fn:'btoa',
|
|
113
|
+
input: String(s).substring(0,200),
|
|
114
|
+
output: result,
|
|
115
|
+
stack: __stack,
|
|
116
|
+
ts: Date.now(),
|
|
117
|
+
});
|
|
118
|
+
return result;
|
|
119
|
+
};`,e,t)},"crypto-subtle":{description:` Hook crypto.subtle.encrypt/decrypt to intercept WebCrypto operations`,buildCode:(e,t)=>c(`crypto-subtle`,`
|
|
120
|
+
if (window.crypto && window.crypto.subtle) {
|
|
121
|
+
const _enc = window.crypto.subtle.encrypt.bind(window.crypto.subtle);
|
|
122
|
+
const _dec = window.crypto.subtle.decrypt.bind(window.crypto.subtle);
|
|
123
|
+
window.crypto.subtle.encrypt = function(algo, key, data) {
|
|
124
|
+
{{STACK_CODE}}
|
|
125
|
+
const __msg = '[Hook:crypto.encrypt] algo=' + JSON.stringify(algo);
|
|
126
|
+
{{LOG_FN}}
|
|
127
|
+
window.__aiHooks['preset-crypto-subtle'].push(
|
|
128
|
+
{
|
|
129
|
+
fn:'encrypt',
|
|
130
|
+
algo: JSON.stringify(algo),
|
|
131
|
+
stack: __stack,
|
|
132
|
+
ts: Date.now(),
|
|
133
|
+
});
|
|
134
|
+
return _enc(algo, key, data);
|
|
135
|
+
};
|
|
136
|
+
window.crypto.subtle.decrypt = function(algo, key, data) {
|
|
137
|
+
{{STACK_CODE}}
|
|
138
|
+
const __msg = '[Hook:crypto.decrypt] algo=' + JSON.stringify(algo);
|
|
139
|
+
{{LOG_FN}}
|
|
140
|
+
window.__aiHooks['preset-crypto-subtle'].push(
|
|
141
|
+
{
|
|
142
|
+
fn:'decrypt',
|
|
143
|
+
algo: JSON.stringify(algo),
|
|
144
|
+
stack: __stack,
|
|
145
|
+
ts: Date.now(),
|
|
146
|
+
});
|
|
147
|
+
return _dec(algo, key, data);
|
|
148
|
+
};
|
|
149
|
+
}`,e,t)},"json-stringify":{description:` Hook JSON.stringify/parse to capture serialization activity`,buildCode:(e,t)=>c(`json-stringify`,`
|
|
150
|
+
const _stringify = JSON.stringify;
|
|
151
|
+
const _parse = JSON.parse;
|
|
152
|
+
JSON.stringify = function(v, r, s) {
|
|
153
|
+
{{STACK_CODE}}
|
|
154
|
+
const result = _stringify(v, r, s);
|
|
155
|
+
const __msg = '[Hook:JSON.stringify] out=' + (result||'').substring(0,100);
|
|
156
|
+
{{LOG_FN}}
|
|
157
|
+
window.__aiHooks['preset-json-stringify'].push(
|
|
158
|
+
{
|
|
159
|
+
fn:'stringify',
|
|
160
|
+
output: (result||'').substring(0,300),
|
|
161
|
+
stack: __stack,
|
|
162
|
+
ts: Date.now(),
|
|
163
|
+
});
|
|
164
|
+
return result;
|
|
165
|
+
};
|
|
166
|
+
JSON.parse = function(text, r) {
|
|
167
|
+
{{STACK_CODE}}
|
|
168
|
+
const result = _parse(text, r);
|
|
169
|
+
const __msg = '[Hook:JSON.parse] in=' + String(text).substring(0,100);
|
|
170
|
+
{{LOG_FN}}
|
|
171
|
+
window.__aiHooks['preset-json-stringify'].push(
|
|
172
|
+
{
|
|
173
|
+
fn:'parse',
|
|
174
|
+
input: String(text).substring(0,300),
|
|
175
|
+
stack: __stack,
|
|
176
|
+
ts: Date.now(),
|
|
177
|
+
});
|
|
178
|
+
return result;
|
|
179
|
+
};`,e,t)},"object-defineproperty":{description:` Hook Object.defineProperty to monitor property definitions`,buildCode:(e,t)=>c(`object-defineproperty`,`
|
|
180
|
+
const _define = Object.defineProperty;
|
|
181
|
+
Object.defineProperty = function(obj, prop, descriptor) {
|
|
182
|
+
{{STACK_CODE}}
|
|
183
|
+
const __msg = '[Hook:Object.defineProperty] prop=' + String(prop);
|
|
184
|
+
{{LOG_FN}}
|
|
185
|
+
window.__aiHooks['preset-object-defineproperty'].push(
|
|
186
|
+
{
|
|
187
|
+
prop: String(prop),
|
|
188
|
+
descriptor: JSON.stringify(descriptor||{}).substring(0,200),
|
|
189
|
+
stack: __stack,
|
|
190
|
+
ts: Date.now(),
|
|
191
|
+
});
|
|
192
|
+
return _define(obj, prop, descriptor);
|
|
193
|
+
};`,e,t)},settimeout:{description:` Hook setTimeout to capture timer callbacks and delays`,buildCode:(e,t)=>c(`settimeout`,`
|
|
194
|
+
const _orig = window.setTimeout;
|
|
195
|
+
window.setTimeout = function(fn, delay, ...args) {
|
|
196
|
+
{{STACK_CODE}}
|
|
197
|
+
const fnStr = typeof fn === 'string' ? fn : fn?.toString().substring(0,100);
|
|
198
|
+
const __msg = '[Hook:setTimeout] delay=' + delay + ' fn=' + fnStr;
|
|
199
|
+
{{LOG_FN}}
|
|
200
|
+
window.__aiHooks['preset-settimeout'].push({ delay, fn: fnStr, stack: __stack, ts: Date.now() });
|
|
201
|
+
return _orig(fn, delay, ...args);
|
|
202
|
+
};`,e,t)},setinterval:{description:` Hook setInterval to capture repeating timer callbacks`,buildCode:(e,t)=>c(`setinterval`,`
|
|
203
|
+
const _orig = window.setInterval;
|
|
204
|
+
window.setInterval = function(fn, delay, ...args) {
|
|
205
|
+
{{STACK_CODE}}
|
|
206
|
+
const fnStr = typeof fn === 'string' ? fn : fn?.toString().substring(0,100);
|
|
207
|
+
const __msg = '[Hook:setInterval] delay=' + delay + ' fn=' + fnStr;
|
|
208
|
+
{{LOG_FN}}
|
|
209
|
+
window.__aiHooks['preset-setinterval'].push({ delay, fn: fnStr, stack: __stack, ts: Date.now() });
|
|
210
|
+
return _orig(fn, delay, ...args);
|
|
211
|
+
};`,e,t)},addeventlistener:{description:` Hook addEventListener to trace event listener registrations`,buildCode:(e,t)=>c(`addeventlistener`,`
|
|
212
|
+
const _orig = EventTarget.prototype.addEventListener;
|
|
213
|
+
EventTarget.prototype.addEventListener = function(type, listener, options) {
|
|
214
|
+
{{STACK_CODE}}
|
|
215
|
+
const __msg = '[Hook:addEventListener] type=' + type;
|
|
216
|
+
{{LOG_FN}}
|
|
217
|
+
window.__aiHooks['preset-addeventlistener'].push(
|
|
218
|
+
{
|
|
219
|
+
type,
|
|
220
|
+
target: this?.tagName || String(this).substring(0,50),
|
|
221
|
+
stack: __stack,
|
|
222
|
+
ts: Date.now(),
|
|
223
|
+
});
|
|
224
|
+
return _orig.call(this, type, listener, options);
|
|
225
|
+
};`,e,t)},postmessage:{description:` Hook postMessage to capture cross-origin and iframe messages`,buildCode:(e,t)=>c(`postmessage`,`
|
|
226
|
+
const _orig = window.postMessage.bind(window);
|
|
227
|
+
window.postMessage = function(data, origin, transfer) {
|
|
228
|
+
{{STACK_CODE}}
|
|
229
|
+
const __msg = '[Hook:postMessage] origin=' + origin + ' data=' + JSON.stringify(data).substring(0,100);
|
|
230
|
+
{{LOG_FN}}
|
|
231
|
+
window.__aiHooks['preset-postmessage'].push(
|
|
232
|
+
{
|
|
233
|
+
origin,
|
|
234
|
+
data: JSON.stringify(data||{}).substring(0,300),
|
|
235
|
+
stack: __stack,
|
|
236
|
+
ts: Date.now(),
|
|
237
|
+
});
|
|
238
|
+
return _orig(data, origin, transfer);
|
|
239
|
+
};
|
|
240
|
+
window.addEventListener('message', function(e) {
|
|
241
|
+
window.__aiHooks['preset-postmessage'].push(
|
|
242
|
+
{
|
|
243
|
+
direction:'received',
|
|
244
|
+
origin: e.origin,
|
|
245
|
+
data: JSON.stringify(e.data||{}).substring(0,300),
|
|
246
|
+
ts: Date.now(),
|
|
247
|
+
});
|
|
248
|
+
});`,e,t)},webassembly:{description:` Hook WebAssembly.instantiate/compile to detect WASM module loading`,buildCode:(e,t)=>c(`webassembly`,`
|
|
249
|
+
if (typeof WebAssembly !== 'undefined') {
|
|
250
|
+
const _inst = WebAssembly.instantiate;
|
|
251
|
+
WebAssembly.instantiate = function(bufferSource, importObject) {
|
|
252
|
+
{{STACK_CODE}}
|
|
253
|
+
const size = bufferSource?.byteLength || bufferSource?.length || 0;
|
|
254
|
+
const __msg = '[Hook:WebAssembly.instantiate] size=' + size;
|
|
255
|
+
{{LOG_FN}}
|
|
256
|
+
window.__aiHooks['preset-webassembly'].push({ fn:'instantiate', size, stack: __stack, ts: Date.now() });
|
|
257
|
+
return _inst(bufferSource, importObject);
|
|
258
|
+
};
|
|
259
|
+
}`,e,t)},proxy:{description:` Hook Proxy constructor to detect proxy-based anti-debugging`,buildCode:(e,t)=>c(`proxy`,`
|
|
260
|
+
const _Proxy = window.Proxy;
|
|
261
|
+
window.Proxy = function(target, handler) {
|
|
262
|
+
{{STACK_CODE}}
|
|
263
|
+
const __msg = '[Hook:Proxy] target=' + String(target).substring(0,50);
|
|
264
|
+
{{LOG_FN}}
|
|
265
|
+
window.__aiHooks['preset-proxy'].push(
|
|
266
|
+
{
|
|
267
|
+
target: String(target).substring(0,100),
|
|
268
|
+
handlerKeys: Object.keys(handler||{}),
|
|
269
|
+
stack: __stack,
|
|
270
|
+
ts: Date.now(),
|
|
271
|
+
});
|
|
272
|
+
return new _Proxy(target, handler);
|
|
273
|
+
};
|
|
274
|
+
window.Proxy.prototype = _Proxy.prototype;
|
|
275
|
+
window.Proxy.revocable = _Proxy.revocable;`,e,t)},reflect:{description:` Hook Reflect.apply to capture indirect function calls`,buildCode:(e,t)=>c(`reflect`,`
|
|
276
|
+
const _apply = Reflect.apply;
|
|
277
|
+
Reflect.apply = function(target, thisArg, args) {
|
|
278
|
+
{{STACK_CODE}}
|
|
279
|
+
const __msg = '[Hook:Reflect.apply] fn=' + (target?.name || 'anonymous');
|
|
280
|
+
{{LOG_FN}}
|
|
281
|
+
window.__aiHooks['preset-reflect'].push(
|
|
282
|
+
{
|
|
283
|
+
fn: target?.name || 'anonymous',
|
|
284
|
+
argsCount: (args||[]).length,
|
|
285
|
+
stack: __stack,
|
|
286
|
+
ts: Date.now(),
|
|
287
|
+
});
|
|
288
|
+
return _apply(target, thisArg, args);
|
|
289
|
+
};`,e,t)},"history-pushstate":{description:` Hook history.pushState/replaceState to trace SPA navigation`,buildCode:(e,t)=>c(`history-pushstate`,`
|
|
290
|
+
const _push = history.pushState.bind(history);
|
|
291
|
+
const _replace = history.replaceState.bind(history);
|
|
292
|
+
history.pushState = function(state, title, url) {
|
|
293
|
+
{{STACK_CODE}}
|
|
294
|
+
const __msg = '[Hook:history.pushState] url=' + url;
|
|
295
|
+
{{LOG_FN}}
|
|
296
|
+
window.__aiHooks['preset-history-pushstate'].push(
|
|
297
|
+
{
|
|
298
|
+
fn:'pushState',
|
|
299
|
+
url: String(url),
|
|
300
|
+
state: JSON.stringify(state||{}).substring(0,100),
|
|
301
|
+
stack: __stack,
|
|
302
|
+
ts: Date.now(),
|
|
303
|
+
});
|
|
304
|
+
return _push(state, title, url);
|
|
305
|
+
};
|
|
306
|
+
history.replaceState = function(state, title, url) {
|
|
307
|
+
{{STACK_CODE}}
|
|
308
|
+
const __msg = '[Hook:history.replaceState] url=' + url;
|
|
309
|
+
{{LOG_FN}}
|
|
310
|
+
window.__aiHooks['preset-history-pushstate'].push(
|
|
311
|
+
{
|
|
312
|
+
fn:'replaceState',
|
|
313
|
+
url: String(url),
|
|
314
|
+
state: JSON.stringify(state||{}).substring(0,100),
|
|
315
|
+
stack: __stack,
|
|
316
|
+
ts: Date.now(),
|
|
317
|
+
});
|
|
318
|
+
return _replace(state, title, url);
|
|
319
|
+
};`,e,t)},"location-href":{description:` Hook location.href setter to intercept URL redirects`,buildCode:(e,t)=>c(`location-href`,`
|
|
320
|
+
const _desc = Object.getOwnPropertyDescriptor(window.location, 'href') ||
|
|
321
|
+
Object.getOwnPropertyDescriptor(Location.prototype, 'href');
|
|
322
|
+
if (_desc && _desc.set) {
|
|
323
|
+
const _origSet = _desc.set;
|
|
324
|
+
Object.defineProperty(window.location, 'href', {
|
|
325
|
+
get: _desc.get,
|
|
326
|
+
set: function(url) {
|
|
327
|
+
{{STACK_CODE}}
|
|
328
|
+
const __msg = '[Hook:location.href] url=' + url;
|
|
329
|
+
{{LOG_FN}}
|
|
330
|
+
window.__aiHooks['preset-location-href'].push({ url: String(url), stack: __stack, ts: Date.now() });
|
|
331
|
+
return _origSet.call(this, url);
|
|
332
|
+
},
|
|
333
|
+
configurable: true,
|
|
334
|
+
});
|
|
335
|
+
}`,e,t)},"navigator-useragent":{description:` Hook navigator.userAgent getter to detect UA fingerprinting`,buildCode:(e,t)=>c(`navigator-useragent`,`
|
|
336
|
+
const _desc = Object.getOwnPropertyDescriptor(Navigator.prototype, 'userAgent');
|
|
337
|
+
if (_desc && _desc.get) {
|
|
338
|
+
const _origGet = _desc.get;
|
|
339
|
+
Object.defineProperty(Navigator.prototype, 'userAgent', {
|
|
340
|
+
get: function() {
|
|
341
|
+
{{STACK_CODE}}
|
|
342
|
+
const result = _origGet.call(this);
|
|
343
|
+
const __msg = '[Hook:navigator.userAgent] ua=' + result.substring(0,80);
|
|
344
|
+
{{LOG_FN}}
|
|
345
|
+
window.__aiHooks['preset-navigator-useragent'].push(
|
|
346
|
+
{
|
|
347
|
+
ua: result.substring(0,200),
|
|
348
|
+
stack: __stack,
|
|
349
|
+
ts: Date.now(),
|
|
350
|
+
});
|
|
351
|
+
return result;
|
|
352
|
+
},
|
|
353
|
+
configurable: true,
|
|
354
|
+
});
|
|
355
|
+
}`,e,t)},eventsource:{description:` Hook EventSource to capture SSE connections`,buildCode:(e,t)=>c(`eventsource`,`
|
|
356
|
+
if (typeof EventSource !== 'undefined') {
|
|
357
|
+
const _ES = EventSource;
|
|
358
|
+
window.EventSource = function(url, opts) {
|
|
359
|
+
{{STACK_CODE}}
|
|
360
|
+
const __msg = '[Hook:EventSource] url=' + url;
|
|
361
|
+
{{LOG_FN}}
|
|
362
|
+
window.__aiHooks['preset-eventsource'].push({ url: String(url), stack: __stack, ts: Date.now() });
|
|
363
|
+
return new _ES(url, opts);
|
|
364
|
+
};
|
|
365
|
+
window.EventSource.prototype = _ES.prototype;
|
|
366
|
+
}`,e,t)},"window-open":{description:` Hook window.open to capture popup and new tab creation`,buildCode:(e,t)=>c(`window-open`,`
|
|
367
|
+
const _orig = window.open.bind(window);
|
|
368
|
+
window.open = function(url, target, features) {
|
|
369
|
+
{{STACK_CODE}}
|
|
370
|
+
const __msg = '[Hook:window.open] url=' + url + ' target=' + target;
|
|
371
|
+
{{LOG_FN}}
|
|
372
|
+
window.__aiHooks['preset-window-open'].push(
|
|
373
|
+
{
|
|
374
|
+
url: String(url),
|
|
375
|
+
target: String(target||''),
|
|
376
|
+
stack: __stack,
|
|
377
|
+
ts: Date.now(),
|
|
378
|
+
});
|
|
379
|
+
return _orig(url, target, features);
|
|
380
|
+
};`,e,t)},mutationobserver:{description:` Hook MutationObserver to track dynamic DOM mutation watchers`,buildCode:(e,t)=>c(`mutationobserver`,`
|
|
381
|
+
const _MO = MutationObserver;
|
|
382
|
+
window.MutationObserver = function(callback) {
|
|
383
|
+
{{STACK_CODE}}
|
|
384
|
+
const __msg = '[Hook:MutationObserver] created';
|
|
385
|
+
{{LOG_FN}}
|
|
386
|
+
window.__aiHooks['preset-mutationobserver'].push({ stack: __stack, ts: Date.now() });
|
|
387
|
+
return new _MO(callback);
|
|
388
|
+
};
|
|
389
|
+
window.MutationObserver.prototype = _MO.prototype;`,e,t)},formdata:{description:` Hook FormData.append to capture form data before submission`,buildCode:(e,t)=>c(`formdata`,`
|
|
390
|
+
const _orig = FormData.prototype.append;
|
|
391
|
+
FormData.prototype.append = function(name, value, filename) {
|
|
392
|
+
{{STACK_CODE}}
|
|
393
|
+
const __msg = '[Hook:FormData.append] name=' + name + ' value=' + String(value).substring(0,100);
|
|
394
|
+
{{LOG_FN}}
|
|
395
|
+
window.__aiHooks['preset-formdata'].push(
|
|
396
|
+
{
|
|
397
|
+
name: String(name),
|
|
398
|
+
value: String(value).substring(0,200),
|
|
399
|
+
stack: __stack,
|
|
400
|
+
ts: Date.now(),
|
|
401
|
+
});
|
|
402
|
+
return _orig.call(this, name, value, filename);
|
|
403
|
+
};`,e,t)}},u={"anti-debug-bypass":{description:` Block anti-debugging: setInterval/setTimeout debugger traps, console.clear spam, timing attacks (performance.now freeze), outerWidth/outerHeight devtools detection`,buildCode:(e,t)=>c(`anti-debug-bypass`,`
|
|
404
|
+
window.__aiHooks['preset-anti-debug-bypass'] = window.__aiHooks['preset-anti-debug-bypass'] || [];
|
|
405
|
+
// 1. Block setInterval/setTimeout containing debugger/devtools
|
|
406
|
+
const _si = window.setInterval;
|
|
407
|
+
window.setInterval = function(fn, delay) {
|
|
408
|
+
const rest = Array.prototype.slice.call(arguments, 2);
|
|
409
|
+
const fnStr = typeof fn === 'function' ? fn.toString() : String(fn);
|
|
410
|
+
if (fnStr.includes('debugger') || fnStr.includes('devtools') || fnStr.includes('disable-devtool')) {
|
|
411
|
+
window.__aiHooks['preset-anti-debug-bypass'].push(
|
|
412
|
+
{
|
|
413
|
+
blocked: 'setInterval',
|
|
414
|
+
fn: fnStr.substring(0, 200),
|
|
415
|
+
ts: Date.now(),
|
|
416
|
+
});
|
|
417
|
+
return -1;
|
|
418
|
+
}
|
|
419
|
+
return _si.apply(this, [fn, delay].concat(rest));
|
|
420
|
+
};
|
|
421
|
+
const _st = window.setTimeout;
|
|
422
|
+
window.setTimeout = function(fn, delay) {
|
|
423
|
+
const rest = Array.prototype.slice.call(arguments, 2);
|
|
424
|
+
const fnStr = typeof fn === 'function' ? fn.toString() : String(fn);
|
|
425
|
+
if (fnStr.includes('debugger') || fnStr.includes('devtools')) {
|
|
426
|
+
window.__aiHooks['preset-anti-debug-bypass'].push(
|
|
427
|
+
{
|
|
428
|
+
blocked: 'setTimeout',
|
|
429
|
+
fn: fnStr.substring(0, 200),
|
|
430
|
+
ts: Date.now(),
|
|
431
|
+
});
|
|
432
|
+
return -1;
|
|
433
|
+
}
|
|
434
|
+
return _st.apply(this, [fn, delay].concat(rest));
|
|
435
|
+
};
|
|
436
|
+
// 2. Suppress console.clear spam
|
|
437
|
+
console.clear = function() {
|
|
438
|
+
window.__aiHooks['preset-anti-debug-bypass'].push({ blocked: 'console.clear', ts: Date.now() });
|
|
439
|
+
};
|
|
440
|
+
// 3. Freeze performance.now to defeat timing attacks
|
|
441
|
+
const _pn = performance.now.bind(performance);
|
|
442
|
+
let _t = _pn();
|
|
443
|
+
performance.now = function() { return (_t += 0.001); };
|
|
444
|
+
// 4. Fix outerWidth/outerHeight DevTools size detection
|
|
445
|
+
Object.defineProperty(window, 'outerWidth', { get: function() { return window.innerWidth; }, configurable: true });
|
|
446
|
+
Object.defineProperty(window, 'outerHeight',
|
|
447
|
+
{ get: function() { return window.innerHeight; }, configurable: true });`,e,t)},"crypto-key-capture":{description:` Force extractable:true on all WebCrypto importKey calls and capture plaintext/ciphertext + key material for encrypt/decrypt/sign/verify`,buildCode:(e,t)=>c(`crypto-key-capture`,`
|
|
448
|
+
if (window.crypto && window.crypto.subtle) {
|
|
449
|
+
const _subtle = window.crypto.subtle;
|
|
450
|
+
const _importKey = _subtle.importKey.bind(_subtle);
|
|
451
|
+
const _encrypt = _subtle.encrypt.bind(_subtle);
|
|
452
|
+
const _decrypt = _subtle.decrypt.bind(_subtle);
|
|
453
|
+
const _sign = _subtle.sign.bind(_subtle);
|
|
454
|
+
const _verify = _subtle.verify.bind(_subtle);
|
|
455
|
+
const _exportKey = _subtle.exportKey.bind(_subtle);
|
|
456
|
+
const toHex = function(buf) {
|
|
457
|
+
return Array.from(new Uint8Array(buf instanceof ArrayBuffer ? buf : buf.buffer || buf))
|
|
458
|
+
.map(function(b) { return b.toString(16).padStart(2,'0'); }).join('');
|
|
459
|
+
};
|
|
460
|
+
const tryExport = async function(key) {
|
|
461
|
+
try { return await _exportKey('jwk', key); } catch(e) { return null; }
|
|
462
|
+
};
|
|
463
|
+
_subtle.importKey = async function(format, keyData, algorithm, extractable, usages) {
|
|
464
|
+
{{STACK_CODE}}
|
|
465
|
+
const keyHex = (keyData instanceof ArrayBuffer || ArrayBuffer.isView(keyData)) ?
|
|
466
|
+
toHex(keyData) :
|
|
467
|
+
JSON.stringify(keyData);
|
|
468
|
+
const __msg = '[Hook:importKey] format=' + format + ' algo=' + JSON.stringify(algorithm) +
|
|
469
|
+
' key=' + keyHex.substring(0,64);
|
|
470
|
+
{{LOG_FN}}
|
|
471
|
+
const key = await _importKey(format, keyData, algorithm, true, usages);
|
|
472
|
+
window.__aiHooks['preset-crypto-key-capture'].push(
|
|
473
|
+
{
|
|
474
|
+
fn:'importKey',
|
|
475
|
+
format,
|
|
476
|
+
algorithm: JSON.stringify(algorithm),
|
|
477
|
+
keyHex,
|
|
478
|
+
stack: __stack,
|
|
479
|
+
ts: Date.now(),
|
|
480
|
+
});
|
|
481
|
+
return key;
|
|
482
|
+
};
|
|
483
|
+
_subtle.encrypt = async function(algo, key, data) {
|
|
484
|
+
{{STACK_CODE}}
|
|
485
|
+
const plainHex = toHex(data);
|
|
486
|
+
const result = await _encrypt(algo, key, data);
|
|
487
|
+
const cipherHex = toHex(result);
|
|
488
|
+
const keyJwk = await tryExport(key);
|
|
489
|
+
const __msg = '[Hook:encrypt] algo=' + JSON.stringify(algo) + ' plain=' + plainHex.substring(0,64);
|
|
490
|
+
{{LOG_FN}}
|
|
491
|
+
window.__aiHooks['preset-crypto-key-capture'].push(
|
|
492
|
+
{
|
|
493
|
+
fn:'encrypt',
|
|
494
|
+
algo: JSON.stringify(algo),
|
|
495
|
+
plainHex,
|
|
496
|
+
cipherHex,
|
|
497
|
+
key: keyJwk,
|
|
498
|
+
stack: __stack,
|
|
499
|
+
ts: Date.now(),
|
|
500
|
+
});
|
|
501
|
+
return result;
|
|
502
|
+
};
|
|
503
|
+
_subtle.decrypt = async function(algo, key, data) {
|
|
504
|
+
{{STACK_CODE}}
|
|
505
|
+
const result = await _decrypt(algo, key, data);
|
|
506
|
+
const plainHex = toHex(result);
|
|
507
|
+
const keyJwk = await tryExport(key);
|
|
508
|
+
const __msg = '[Hook:decrypt] algo=' + JSON.stringify(algo) + ' plain=' +
|
|
509
|
+
new TextDecoder().decode(new Uint8Array(result instanceof ArrayBuffer ? result : result.buffer,
|
|
510
|
+
0, Math.min(100, (result.byteLength || result.length || 0))));
|
|
511
|
+
{{LOG_FN}}
|
|
512
|
+
window.__aiHooks['preset-crypto-key-capture'].push(
|
|
513
|
+
{
|
|
514
|
+
fn:'decrypt',
|
|
515
|
+
algo: JSON.stringify(algo),
|
|
516
|
+
plainHex,
|
|
517
|
+
key: keyJwk,
|
|
518
|
+
stack: __stack,
|
|
519
|
+
ts: Date.now(),
|
|
520
|
+
});
|
|
521
|
+
return result;
|
|
522
|
+
};
|
|
523
|
+
_subtle.sign = async function(algo, key, data) {
|
|
524
|
+
{{STACK_CODE}}
|
|
525
|
+
const result = await _sign(algo, key, data);
|
|
526
|
+
const keyJwk = await tryExport(key);
|
|
527
|
+
const __msg = '[Hook:sign] algo=' + JSON.stringify(algo);
|
|
528
|
+
{{LOG_FN}}
|
|
529
|
+
window.__aiHooks['preset-crypto-key-capture'].push(
|
|
530
|
+
{
|
|
531
|
+
fn:'sign',
|
|
532
|
+
algo: JSON.stringify(algo),
|
|
533
|
+
sigHex: toHex(result),
|
|
534
|
+
key: keyJwk,
|
|
535
|
+
stack: __stack,
|
|
536
|
+
ts: Date.now(),
|
|
537
|
+
});
|
|
538
|
+
return result;
|
|
539
|
+
};
|
|
540
|
+
}`,e,t)},"webassembly-full":{description:` Hook WebAssembly.instantiate to log all import calls, export names, and memory creation`,buildCode:(e,t)=>c(`webassembly-full`,`
|
|
541
|
+
if (typeof WebAssembly !== 'undefined') {
|
|
542
|
+
const _inst = WebAssembly.instantiate;
|
|
543
|
+
WebAssembly.instantiate = async function(bufferSource, importObject) {
|
|
544
|
+
{{STACK_CODE}}
|
|
545
|
+
const size = bufferSource && (bufferSource.byteLength || bufferSource.length) || 0;
|
|
546
|
+
const __msg = '[Hook:WASM.instantiate] size=' + size;
|
|
547
|
+
{{LOG_FN}}
|
|
548
|
+
// Wrap all imported functions to trace calls
|
|
549
|
+
if (importObject && typeof importObject === 'object') {
|
|
550
|
+
Object.keys(importObject).forEach(function(modName) {
|
|
551
|
+
const mod = importObject[modName];
|
|
552
|
+
if (mod && typeof mod === 'object') {
|
|
553
|
+
Object.keys(mod).forEach(function(fnName) {
|
|
554
|
+
if (typeof mod[fnName] === 'function') {
|
|
555
|
+
const _fn = mod[fnName];
|
|
556
|
+
mod[fnName] = function() {
|
|
557
|
+
const args = Array.prototype.slice.call(arguments);
|
|
558
|
+
window.__aiHooks['preset-webassembly-full'].push(
|
|
559
|
+
{
|
|
560
|
+
type:'import_call',
|
|
561
|
+
mod: modName,
|
|
562
|
+
fn: fnName,
|
|
563
|
+
args: args.map(function(a){ return typeof a === 'number' ? a : '?'; }),
|
|
564
|
+
ts: Date.now(),
|
|
565
|
+
});
|
|
566
|
+
return _fn.apply(this, args);
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
const result = await _inst(bufferSource, importObject);
|
|
574
|
+
const exports = result && result.instance ? Object.keys(result.instance.exports) : [];
|
|
575
|
+
window.__aiHooks['preset-webassembly-full'].push(
|
|
576
|
+
{
|
|
577
|
+
type:'instantiated',
|
|
578
|
+
size,
|
|
579
|
+
exports,
|
|
580
|
+
importMods: importObject ? Object.keys(importObject) : [],
|
|
581
|
+
stack: __stack,
|
|
582
|
+
ts: Date.now(),
|
|
583
|
+
});
|
|
584
|
+
return result;
|
|
585
|
+
};
|
|
586
|
+
// Also hook WebAssembly.Memory creation
|
|
587
|
+
const _Memory = WebAssembly.Memory;
|
|
588
|
+
WebAssembly.Memory = function(descriptor) {
|
|
589
|
+
window.__aiHooks['preset-webassembly-full'].push(
|
|
590
|
+
{
|
|
591
|
+
type:'memory_created',
|
|
592
|
+
initial: descriptor && descriptor.initial,
|
|
593
|
+
maximum: descriptor && descriptor.maximum,
|
|
594
|
+
shared: descriptor && descriptor.shared,
|
|
595
|
+
ts: Date.now(),
|
|
596
|
+
});
|
|
597
|
+
return new _Memory(descriptor);
|
|
598
|
+
};
|
|
599
|
+
WebAssembly.Memory.prototype = _Memory.prototype;
|
|
600
|
+
}`,e,t)}},d={...l,...u},f=Object.entries(d).map(([e,t])=>({id:e,description:t.description}));var p=class{pageController;constructor(e){this.pageController=e}async handleHookPreset(r){try{let a=this.buildCustomPresetMap(r),o={...d,...a},s=[...f,...Object.entries(a).map(([e,t])=>({id:e,description:`${t.description} (custom)`}))];if(r.listPresets===!0)return{content:[{type:`text`,text:JSON.stringify({success:!0,totalPresets:s.length,presets:s},null,2)}]};let c=i(r,`captureStack`,!1),l=i(r,`logToConsole`,!0),u=t(r,`method`,`evaluate`),p=[];if(r.preset)p=[t(r,`preset`)];else if(Array.isArray(r.presets))p=n(r,`presets`);else return{content:[{type:`text`,text:JSON.stringify({success:!1,error:` Provide either preset (single) or presets (multiple), or set listPresets=true to list available presets`},null,2)}]};let m=p.filter(e=>!o[e]);if(m.length>0)return{content:[{type:`text`,text:JSON.stringify({success:!1,error:`: ${m.join(`, `)}`,availablePresets:s.map(e=>e.id)},null,2)}]};let h=await this.pageController.getPage(),g=[],_=[];for(let t of p)try{let n=o[t].buildCode(c,l);u===`evaluateOnNewDocument`?await h.evaluateOnNewDocument(n):await h.evaluate(n),g.push(t),e.info(` Hook preset injected: ${t}`)}catch(n){let r=n instanceof Error?n.message:String(n);_.push({preset:t,error:r}),e.error(` Failed to inject preset ${t}:`,n)}return{content:[{type:`text`,text:JSON.stringify({success:_.length===0,injected:g,failed:_,method:u,captureStack:c,message:` ${g.length}/${p.length} Hook`,usage:` ai_hook_get_data(hookId: "preset-<>") `},null,2)}]}}catch(t){return e.error(`Hook preset injection failed`,t),{content:[{type:`text`,text:JSON.stringify({success:!1,error:t instanceof Error?t.message:String(t)},null,2)}]}}}buildCustomPresetMap(e){let t=[];e.customTemplate&&typeof e.customTemplate==`object`&&t.push(e.customTemplate),Array.isArray(e.customTemplates)&&t.push(...e.customTemplates);let n={};for(let e of t){let t=e.id?.trim(),r=e.body?.trim();if(!t||!r)throw Error(`Each custom template requires non-empty id and body`);if(d[t])throw Error(`Custom template id conflicts with built-in preset: ${t}`);n[t]={description:e.description?.trim()||`Custom inline preset: ${t}`,buildCode:(e,n)=>c(t,r,e,n)}}return n}};export{s as AIHookToolHandlers,p as HookPresetToolHandlers};
|