@jshookmcp/jshook 0.2.9 → 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-CtcdK78Q.mjs → HookGeneratorBuilders.core.generators.storage-Bf1fbrNK.mjs} +66 -174
- 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-CqDTB_uk.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-Bl8zkwz1.mjs → handlers-pVNpaw4A.mjs} +144 -841
- package/dist/handlers.impl-CD2_kOcC.mjs +1 -0
- package/dist/hooks-DDKppogd.mjs +600 -0
- package/dist/index.mjs +12 -5225
- 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 +12 -7
- package/dist/AntiCheatDetector-BNk-EoBt.mjs +0 -244
- package/dist/CacheAdapters-CDe5WPSV.mjs +0 -80
- package/dist/CodeInjector-Cq8q01kp.mjs +0 -150
- package/dist/ConsoleMonitor-CPVQW1Y-.mjs +0 -2201
- package/dist/DarwinAPI-BNPxu0RH.mjs +0 -363
- package/dist/DetailedDataManager-BQQcxh64.mjs +0 -217
- package/dist/EventBus-DgPmwpeu.mjs +0 -141
- package/dist/EvidenceGraphBridge-SFesNera.mjs +0 -153
- package/dist/ExtensionManager-CWYgw0YW.mjs +0 -714
- package/dist/FingerprintManager-gzWtkKuf.mjs +0 -96
- package/dist/HardwareBreakpoint-B9gZCdFP.mjs +0 -239
- package/dist/HeapAnalyzer-BLDH0dCv.mjs +0 -284
- package/dist/InstrumentationSession-CvPC7Jwy.mjs +0 -244
- package/dist/MemoryController-CbVdCIJF.mjs +0 -167
- package/dist/MemoryScanSession-BsDZbLYm.mjs +0 -278
- package/dist/MemoryScanner-Bcpml6II.mjs +0 -425
- package/dist/NativeMemoryManager.impl-dZtA1ZGn.mjs +0 -482
- package/dist/NativeMemoryManager.utils-B-FjA2mJ.mjs +0 -165
- package/dist/PEAnalyzer-D1lzJ_VG.mjs +0 -385
- package/dist/PageController-Bqm2kZ_X.mjs +0 -417
- package/dist/PointerChainEngine-BOhyVsjx.mjs +0 -322
- package/dist/PrerequisiteError-Dl33Svkz.mjs +0 -20
- package/dist/ResponseBuilder-D3iFYx2N.mjs +0 -143
- package/dist/ReverseEvidenceGraph-Dlsk94LC.mjs +0 -269
- package/dist/ScriptManager-aHHq0X7U.mjs +0 -3000
- package/dist/Speedhack-CqdIFlQl.mjs +0 -156
- package/dist/StealthVerifier-Bo4T3bz8.mjs +0 -135
- package/dist/StructureAnalyzer-DhFaPvRO.mjs +0 -426
- package/dist/ToolCatalog-C0JGZoOm.mjs +0 -582
- package/dist/ToolError-jh9whhMd.mjs +0 -15
- package/dist/ToolProbe-oC7aPrkv.mjs +0 -45
- package/dist/ToolRegistry-BjaF4oNz.mjs +0 -131
- package/dist/ToolRouter.policy-BWV67ZK-.mjs +0 -304
- package/dist/TraceRecorder-DgxyVbdQ.mjs +0 -519
- package/dist/VersionDetector-CwVLVdDM.mjs +0 -104
- package/dist/Win32API-CePkipZY.mjs +0 -340
- package/dist/Win32Debug-BvKs-gxc.mjs +0 -274
- package/dist/WorkflowEngine-CuvkZtWu.mjs +0 -598
- package/dist/analysis-CL9uACt9.mjs +0 -463
- package/dist/artifactRetention-CFEprwPw.mjs +0 -591
- package/dist/artifacts-Bk2-_uPq.mjs +0 -59
- package/dist/betterSqlite3-0pqusHHH.mjs +0 -74
- package/dist/binary-instrument-CXfpx6fT.mjs +0 -979
- package/dist/bind-helpers-xFfRF-qm.mjs +0 -22
- package/dist/boringssl-inspector-BH2D3VKc.mjs +0 -180
- package/dist/browser-BpOr5PEx.mjs +0 -4082
- package/dist/chunk-CjcI7cDX.mjs +0 -15
- package/dist/concurrency-Bt0yv1kJ.mjs +0 -41
- package/dist/constants-B0OANIBL.mjs +0 -519
- package/dist/coordination-qUbyF8KU.mjs +0 -259
- package/dist/debugger-gnKxRSN0.mjs +0 -1271
- package/dist/definitions-6M-eejaT.mjs +0 -53
- package/dist/definitions-B18eyf0B.mjs +0 -18
- package/dist/definitions-B3QdlrHv.mjs +0 -34
- package/dist/definitions-B4rAvHNZ.mjs +0 -63
- package/dist/definitions-BB_4jnmy.mjs +0 -37
- package/dist/definitions-BMfYXoNC.mjs +0 -43
- package/dist/definitions-Beid2EB3.mjs +0 -27
- package/dist/definitions-C1UvM5Iy.mjs +0 -126
- package/dist/definitions-CXEI7QC72.mjs +0 -216
- package/dist/definitions-C_4r7Fo-2.mjs +0 -14
- package/dist/definitions-CkFDALoa.mjs +0 -26
- package/dist/definitions-Cke7zEb8.mjs +0 -94
- package/dist/definitions-ClJLzsJQ.mjs +0 -25
- package/dist/definitions-Cq-zroAU.mjs +0 -28
- package/dist/definitions-Cy3Sl6gV.mjs +0 -34
- package/dist/definitions-D3VsGcvz.mjs +0 -47
- package/dist/definitions-DVGfrn7y.mjs +0 -96
- package/dist/definitions-LKpC3-nL.mjs +0 -9
- package/dist/definitions-bAhHQJq9.mjs +0 -359
- package/dist/encoding-Bvz5jLRv.mjs +0 -1065
- package/dist/evidence-graph-bridge-C_fv9PuC.mjs +0 -135
- package/dist/factory-DxlGh9Xf.mjs +0 -575
- package/dist/formatAddress-DVkj9kpI.mjs +0 -17
- package/dist/graphql-DYWzJ29s.mjs +0 -1026
- package/dist/handlers-9sAbfIg-.mjs +0 -2552
- package/dist/handlers-C67ktuRN.mjs +0 -710
- package/dist/handlers-C87g8oCe.mjs +0 -276
- package/dist/handlers-CTsDAO6p.mjs +0 -681
- package/dist/handlers-Cgyg6c0U.mjs +0 -645
- package/dist/handlers-D6j6yka7.mjs +0 -2124
- package/dist/handlers-DdFzXLvF.mjs +0 -446
- package/dist/handlers-DeLOCd5m.mjs +0 -799
- package/dist/handlers-DlCJN4Td.mjs +0 -757
- package/dist/handlers-DxGIq15_2.mjs +0 -917
- package/dist/handlers-U6L4xhuF.mjs +0 -585
- package/dist/handlers-tB9Mp9ZK.mjs +0 -84
- package/dist/handlers-tiy7EIBp.mjs +0 -572
- package/dist/handlers.impl-DS0d9fUw.mjs +0 -761
- package/dist/hooks-CzCWByww.mjs +0 -898
- package/dist/logger-Dh_xb7_2.mjs +0 -93
- package/dist/maintenance-P7ePRXQC.mjs +0 -830
- package/dist/manifest-2ToTpjv8.mjs +0 -106
- package/dist/manifest-3g71z6Bg.mjs +0 -79
- package/dist/manifest-82baTv4U.mjs +0 -45
- package/dist/manifest-B3QVVeBS.mjs +0 -82
- package/dist/manifest-BB2J8IMJ.mjs +0 -149
- package/dist/manifest-BKbgbSiY.mjs +0 -60
- package/dist/manifest-Bcf-TJzH.mjs +0 -848
- package/dist/manifest-BmtZzQiQ2.mjs +0 -45
- package/dist/manifest-Bnd7kqEY.mjs +0 -55
- package/dist/manifest-BqQX6OQC2.mjs +0 -65
- package/dist/manifest-BqrQ4Tpj.mjs +0 -81
- package/dist/manifest-Br4RPFt5.mjs +0 -370
- package/dist/manifest-C5qDjysN.mjs +0 -107
- package/dist/manifest-C9RT5nk32.mjs +0 -34
- package/dist/manifest-CAhOuvSl.mjs +0 -204
- package/dist/manifest-CBYWCUBJ.mjs +0 -51
- package/dist/manifest-CFADCRa1.mjs +0 -37
- package/dist/manifest-CQVhavRF.mjs +0 -114
- package/dist/manifest-CT7zZBV1.mjs +0 -48
- package/dist/manifest-CV12bcrF.mjs +0 -121
- package/dist/manifest-CXsRWjjI.mjs +0 -224
- package/dist/manifest-CZLUCfG02.mjs +0 -95
- package/dist/manifest-D6phHKFd.mjs +0 -131
- package/dist/manifest-DCyjf4n2.mjs +0 -294
- package/dist/manifest-DHsnKgP6.mjs +0 -60
- package/dist/manifest-Df_dliIe.mjs +0 -55
- package/dist/manifest-Dh8WBmEW.mjs +0 -129
- package/dist/manifest-DhKRAT8_.mjs +0 -92
- package/dist/manifest-DlpTj4ic2.mjs +0 -193
- package/dist/manifest-DrbmZcFl2.mjs +0 -253
- package/dist/manifest-DuwHjUa5.mjs +0 -70
- package/dist/manifest-DzwvxPJX.mjs +0 -38
- package/dist/manifest-NXctwWQq.mjs +0 -68
- package/dist/manifest-Sc_0JQ13.mjs +0 -418
- package/dist/manifest-gZ4s_UtG.mjs +0 -96
- package/dist/manifest-qSleDqdO.mjs +0 -1023
- package/dist/modules-C184v-S9.mjs +0 -11365
- package/dist/mojo-ipc-B_H61Afw.mjs +0 -525
- package/dist/network-671Cw6hV.mjs +0 -3346
- package/dist/outputPaths-B1uGmrWZ.mjs +0 -1145
- package/dist/parse-args-BlRjqlkL.mjs +0 -39
- package/dist/platform-WmNn8Sxb.mjs +0 -2070
- package/dist/process-QcbIy5Zq.mjs +0 -1401
- package/dist/proxy-DqNs0bAd.mjs +0 -170
- package/dist/registry-D-6e18lB.mjs +0 -34
- package/dist/response-BQVP-xUn.mjs +0 -28
- package/dist/shared-state-board-DV-dpHFJ.mjs +0 -586
- package/dist/sourcemap-Dq8ez8vS.mjs +0 -650
- package/dist/ssrf-policy-ZaUfvhq7.mjs +0 -166
- package/dist/streaming-BUQ0VJsg.mjs +0 -725
- package/dist/tool-builder-DCbIC5Eo.mjs +0 -186
- package/dist/transform-CiYJfNX0.mjs +0 -1007
- package/dist/types-Bx92KJfT.mjs +0 -4
- package/dist/types-CPhOReNX.mjs +0 -37
- package/dist/wasm-DQTnHDs4.mjs +0 -531
- package/dist/workflow-f3xJOcjx.mjs +0 -725
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import { t as logger } from "./logger-Dh_xb7_2.mjs";
|
|
2
|
-
import { a as GetModuleFileNameEx, b as openProcessForMemory, d as ReadProcessMemory, i as GetModuleBaseName, n as EnumProcessModules, s as GetModuleInformation, t as CloseHandle } from "./Win32API-CePkipZY.mjs";
|
|
3
|
-
import { promises } from "node:fs";
|
|
4
|
-
//#region src/native/PEAnalyzer.types.ts
|
|
5
|
-
/** PE section characteristic flags */
|
|
6
|
-
const IMAGE_SCN = {
|
|
7
|
-
CNT_CODE: 32,
|
|
8
|
-
CNT_INITIALIZED_DATA: 64,
|
|
9
|
-
CNT_UNINITIALIZED_DATA: 128,
|
|
10
|
-
MEM_EXECUTE: 536870912,
|
|
11
|
-
MEM_READ: 1073741824,
|
|
12
|
-
MEM_WRITE: 2147483648
|
|
13
|
-
};
|
|
14
|
-
/** Data directory indices */
|
|
15
|
-
const IMAGE_DIRECTORY_ENTRY = {
|
|
16
|
-
EXPORT: 0,
|
|
17
|
-
IMPORT: 1,
|
|
18
|
-
RESOURCE: 2,
|
|
19
|
-
EXCEPTION: 3,
|
|
20
|
-
IAT: 12,
|
|
21
|
-
DELAY_IMPORT: 13
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/native/PEAnalyzer.ts
|
|
25
|
-
/**
|
|
26
|
-
* PE Analyzer Engine.
|
|
27
|
-
*
|
|
28
|
-
* Parses PE headers from process memory using ReadProcessMemory.
|
|
29
|
-
* Provides import/export table resolution, inline hook detection,
|
|
30
|
-
* and section anomaly analysis.
|
|
31
|
-
*
|
|
32
|
-
* @module PEAnalyzer
|
|
33
|
-
*/
|
|
34
|
-
const MZ_MAGIC = 23117;
|
|
35
|
-
const PE_SIGNATURE = 17744;
|
|
36
|
-
const PE32PLUS_MAGIC = 523;
|
|
37
|
-
const SECTION_HEADER_SIZE = 40;
|
|
38
|
-
const IMPORT_DESCRIPTOR_SIZE = 20;
|
|
39
|
-
const COMPARE_BYTES = 16;
|
|
40
|
-
var PEAnalyzer = class {
|
|
41
|
-
/**
|
|
42
|
-
* Parse PE headers from a module's base address in process memory.
|
|
43
|
-
*/
|
|
44
|
-
async parseHeaders(pid, moduleBase) {
|
|
45
|
-
const base = BigInt(moduleBase);
|
|
46
|
-
const hProcess = openProcessForMemory(pid);
|
|
47
|
-
try {
|
|
48
|
-
const dosData = ReadProcessMemory(hProcess, base, 64);
|
|
49
|
-
const e_magic = dosData.readUInt16LE(0);
|
|
50
|
-
if (e_magic !== MZ_MAGIC) throw new Error(`Invalid DOS header: expected 0x5A4D, got 0x${e_magic.toString(16)}`);
|
|
51
|
-
const e_lfanew = dosData.readUInt32LE(60);
|
|
52
|
-
const ntData = ReadProcessMemory(hProcess, base + BigInt(e_lfanew), 264);
|
|
53
|
-
const ntSignature = ntData.readUInt32LE(0);
|
|
54
|
-
if (ntSignature !== PE_SIGNATURE) throw new Error(`Invalid PE signature: expected 0x4550, got 0x${ntSignature.toString(16)}`);
|
|
55
|
-
const machine = ntData.readUInt16LE(4);
|
|
56
|
-
const numberOfSections = ntData.readUInt16LE(6);
|
|
57
|
-
const timeDateStamp = ntData.readUInt32LE(8);
|
|
58
|
-
const characteristics = ntData.readUInt16LE(22);
|
|
59
|
-
const magic = ntData.readUInt16LE(24);
|
|
60
|
-
const isPE32Plus = magic === PE32PLUS_MAGIC;
|
|
61
|
-
let imageBase;
|
|
62
|
-
let entryPoint;
|
|
63
|
-
let sizeOfImage;
|
|
64
|
-
let numberOfRvaAndSizes;
|
|
65
|
-
if (isPE32Plus) {
|
|
66
|
-
entryPoint = ntData.readUInt32LE(40);
|
|
67
|
-
imageBase = ntData.readBigUInt64LE(48);
|
|
68
|
-
sizeOfImage = ntData.readUInt32LE(80);
|
|
69
|
-
numberOfRvaAndSizes = ntData.readUInt32LE(132);
|
|
70
|
-
} else {
|
|
71
|
-
entryPoint = ntData.readUInt32LE(40);
|
|
72
|
-
imageBase = BigInt(ntData.readUInt32LE(52));
|
|
73
|
-
sizeOfImage = ntData.readUInt32LE(80);
|
|
74
|
-
numberOfRvaAndSizes = ntData.readUInt32LE(116);
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
dosHeader: {
|
|
78
|
-
e_magic,
|
|
79
|
-
e_lfanew
|
|
80
|
-
},
|
|
81
|
-
ntSignature,
|
|
82
|
-
fileHeader: {
|
|
83
|
-
machine,
|
|
84
|
-
numberOfSections,
|
|
85
|
-
timeDateStamp,
|
|
86
|
-
characteristics
|
|
87
|
-
},
|
|
88
|
-
optionalHeader: {
|
|
89
|
-
magic,
|
|
90
|
-
imageBase: `0x${imageBase.toString(16)}`,
|
|
91
|
-
entryPoint: `0x${entryPoint.toString(16)}`,
|
|
92
|
-
sizeOfImage,
|
|
93
|
-
numberOfRvaAndSizes
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
} finally {
|
|
97
|
-
CloseHandle(hProcess);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* List all PE sections with permissions.
|
|
102
|
-
*/
|
|
103
|
-
async listSections(pid, moduleBase) {
|
|
104
|
-
const base = BigInt(moduleBase);
|
|
105
|
-
const hProcess = openProcessForMemory(pid);
|
|
106
|
-
try {
|
|
107
|
-
const headers = await this._readCoreHeaders(hProcess, base);
|
|
108
|
-
const sections = [];
|
|
109
|
-
for (let i = 0; i < headers.numSections; i++) {
|
|
110
|
-
const off = headers.firstSectionOffset + i * SECTION_HEADER_SIZE;
|
|
111
|
-
const secData = ReadProcessMemory(hProcess, base + BigInt(off), SECTION_HEADER_SIZE);
|
|
112
|
-
const nameEnd = secData.indexOf(0);
|
|
113
|
-
const name = secData.subarray(0, nameEnd > 0 && nameEnd <= 8 ? nameEnd : 8).toString("ascii");
|
|
114
|
-
const virtualSize = secData.readUInt32LE(8);
|
|
115
|
-
const virtualAddress = secData.readUInt32LE(12);
|
|
116
|
-
const rawSize = secData.readUInt32LE(16);
|
|
117
|
-
const chars = secData.readUInt32LE(36);
|
|
118
|
-
sections.push({
|
|
119
|
-
name,
|
|
120
|
-
virtualAddress: `0x${virtualAddress.toString(16)}`,
|
|
121
|
-
virtualSize,
|
|
122
|
-
rawSize,
|
|
123
|
-
characteristics: chars,
|
|
124
|
-
isExecutable: (chars & IMAGE_SCN.MEM_EXECUTE) !== 0,
|
|
125
|
-
isWritable: (chars & IMAGE_SCN.MEM_WRITE) !== 0,
|
|
126
|
-
isReadable: (chars & IMAGE_SCN.MEM_READ) !== 0
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
return sections;
|
|
130
|
-
} finally {
|
|
131
|
-
CloseHandle(hProcess);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Parse import table.
|
|
136
|
-
*/
|
|
137
|
-
async parseImports(pid, moduleBase) {
|
|
138
|
-
const base = BigInt(moduleBase);
|
|
139
|
-
const hProcess = openProcessForMemory(pid);
|
|
140
|
-
try {
|
|
141
|
-
const headers = await this._readCoreHeaders(hProcess, base);
|
|
142
|
-
const importRva = headers.dataDirectories[IMAGE_DIRECTORY_ENTRY.IMPORT];
|
|
143
|
-
if (!importRva || importRva.rva === 0) return [];
|
|
144
|
-
const imports = [];
|
|
145
|
-
let descOffset = importRva.rva;
|
|
146
|
-
for (let i = 0; i < 500; i++) {
|
|
147
|
-
const desc = ReadProcessMemory(hProcess, base + BigInt(descOffset), IMPORT_DESCRIPTOR_SIZE);
|
|
148
|
-
const nameRva = desc.readUInt32LE(12);
|
|
149
|
-
if (nameRva === 0) break;
|
|
150
|
-
const nameData = ReadProcessMemory(hProcess, base + BigInt(nameRva), 256);
|
|
151
|
-
const nullIdx = nameData.indexOf(0);
|
|
152
|
-
const dllName = nameData.subarray(0, nullIdx > 0 ? nullIdx : 256).toString("ascii");
|
|
153
|
-
const originalFirstThunkRva = desc.readUInt32LE(0) || desc.readUInt32LE(16);
|
|
154
|
-
const functions = this._readThunkArray(hProcess, base, originalFirstThunkRva, headers.isPE32Plus);
|
|
155
|
-
imports.push({
|
|
156
|
-
dllName,
|
|
157
|
-
functions
|
|
158
|
-
});
|
|
159
|
-
descOffset += IMPORT_DESCRIPTOR_SIZE;
|
|
160
|
-
}
|
|
161
|
-
return imports;
|
|
162
|
-
} finally {
|
|
163
|
-
CloseHandle(hProcess);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Parse export table.
|
|
168
|
-
*/
|
|
169
|
-
async parseExports(pid, moduleBase) {
|
|
170
|
-
const base = BigInt(moduleBase);
|
|
171
|
-
const hProcess = openProcessForMemory(pid);
|
|
172
|
-
try {
|
|
173
|
-
const exportDir = (await this._readCoreHeaders(hProcess, base)).dataDirectories[IMAGE_DIRECTORY_ENTRY.EXPORT];
|
|
174
|
-
if (!exportDir || exportDir.rva === 0) return [];
|
|
175
|
-
const expData = ReadProcessMemory(hProcess, base + BigInt(exportDir.rva), 40);
|
|
176
|
-
const numberOfNames = expData.readUInt32LE(24);
|
|
177
|
-
const addressOfFunctionsRva = expData.readUInt32LE(28);
|
|
178
|
-
const addressOfNamesRva = expData.readUInt32LE(32);
|
|
179
|
-
const addressOfNameOrdinalsRva = expData.readUInt32LE(36);
|
|
180
|
-
const ordinalBase = expData.readUInt32LE(16);
|
|
181
|
-
const exports = [];
|
|
182
|
-
const namesBuf = ReadProcessMemory(hProcess, base + BigInt(addressOfNamesRva), numberOfNames * 4);
|
|
183
|
-
const ordsBuf = ReadProcessMemory(hProcess, base + BigInt(addressOfNameOrdinalsRva), numberOfNames * 2);
|
|
184
|
-
for (let i = 0; i < Math.min(numberOfNames, 2e3); i++) {
|
|
185
|
-
const nameRva = namesBuf.readUInt32LE(i * 4);
|
|
186
|
-
const ordIndex = ordsBuf.readUInt16LE(i * 2);
|
|
187
|
-
const nameBuf = ReadProcessMemory(hProcess, base + BigInt(nameRva), 256);
|
|
188
|
-
const nullIdx = nameBuf.indexOf(0);
|
|
189
|
-
const name = nameBuf.subarray(0, nullIdx > 0 ? nullIdx : 256).toString("ascii");
|
|
190
|
-
const funcRva = ReadProcessMemory(hProcess, base + BigInt(addressOfFunctionsRva + ordIndex * 4), 4).readUInt32LE(0);
|
|
191
|
-
let forwardedTo = null;
|
|
192
|
-
if (funcRva >= exportDir.rva && funcRva < exportDir.rva + exportDir.size) {
|
|
193
|
-
const fwdBuf = ReadProcessMemory(hProcess, base + BigInt(funcRva), 256);
|
|
194
|
-
const fwdEnd = fwdBuf.indexOf(0);
|
|
195
|
-
forwardedTo = fwdBuf.subarray(0, fwdEnd > 0 ? fwdEnd : 256).toString("ascii");
|
|
196
|
-
}
|
|
197
|
-
exports.push({
|
|
198
|
-
name,
|
|
199
|
-
ordinal: ordinalBase + ordIndex,
|
|
200
|
-
rva: `0x${funcRva.toString(16)}`,
|
|
201
|
-
forwardedTo
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
return exports;
|
|
205
|
-
} finally {
|
|
206
|
-
CloseHandle(hProcess);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Detect inline hooks by comparing first bytes of exported functions (disk vs memory).
|
|
211
|
-
*/
|
|
212
|
-
async detectInlineHooks(pid, moduleName) {
|
|
213
|
-
const hProcess = openProcessForMemory(pid);
|
|
214
|
-
const detections = [];
|
|
215
|
-
try {
|
|
216
|
-
const modules = this._enumerateModulesInternal(hProcess);
|
|
217
|
-
const targets = moduleName ? modules.filter((m) => m.name.toLowerCase().includes(moduleName.toLowerCase())) : modules;
|
|
218
|
-
for (const mod of targets) try {
|
|
219
|
-
const diskData = await promises.readFile(mod.path);
|
|
220
|
-
const exports = await this.parseExports(pid, mod.base);
|
|
221
|
-
for (const exp of exports) {
|
|
222
|
-
const funcRva = parseInt(exp.rva, 16);
|
|
223
|
-
if (funcRva === 0 || exp.forwardedTo) continue;
|
|
224
|
-
const memBytes = ReadProcessMemory(hProcess, BigInt(mod.base) + BigInt(funcRva), COMPARE_BYTES);
|
|
225
|
-
const diskOffset = this._rvaToFileOffset(diskData, funcRva);
|
|
226
|
-
if (diskOffset < 0 || diskOffset + COMPARE_BYTES > diskData.length) continue;
|
|
227
|
-
const diskBytes = diskData.subarray(diskOffset, diskOffset + COMPARE_BYTES);
|
|
228
|
-
if (!memBytes.equals(diskBytes)) {
|
|
229
|
-
const hookType = this._classifyHook(memBytes);
|
|
230
|
-
const jumpTarget = this._decodeJumpTarget(memBytes, BigInt(mod.base) + BigInt(funcRva));
|
|
231
|
-
detections.push({
|
|
232
|
-
address: `0x${(BigInt(mod.base) + BigInt(funcRva)).toString(16)}`,
|
|
233
|
-
moduleName: mod.name,
|
|
234
|
-
functionName: exp.name,
|
|
235
|
-
originalBytes: Array.from(diskBytes),
|
|
236
|
-
currentBytes: Array.from(memBytes),
|
|
237
|
-
hookType,
|
|
238
|
-
jumpTarget
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
} catch (e) {
|
|
243
|
-
logger.debug(`Hook check skipped for ${mod.name}: ${e}`);
|
|
244
|
-
}
|
|
245
|
-
} finally {
|
|
246
|
-
CloseHandle(hProcess);
|
|
247
|
-
}
|
|
248
|
-
return detections;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Analyze sections for anomalies (RWX, writable code, etc.).
|
|
252
|
-
*/
|
|
253
|
-
async analyzeSections(pid, moduleBase) {
|
|
254
|
-
const sections = await this.listSections(pid, moduleBase);
|
|
255
|
-
const anomalies = [];
|
|
256
|
-
for (const sec of sections) if (sec.isReadable && sec.isWritable && sec.isExecutable) anomalies.push({
|
|
257
|
-
sectionName: sec.name,
|
|
258
|
-
anomalyType: "rwx",
|
|
259
|
-
severity: "high",
|
|
260
|
-
details: `Section ${sec.name} has Read+Write+Execute permissions — unusual and potentially malicious`
|
|
261
|
-
});
|
|
262
|
-
else if (sec.isWritable && sec.isExecutable) anomalies.push({
|
|
263
|
-
sectionName: sec.name,
|
|
264
|
-
anomalyType: "writable_code",
|
|
265
|
-
severity: "high",
|
|
266
|
-
details: `Section ${sec.name} is writable and executable — code may be self-modifying or packed`
|
|
267
|
-
});
|
|
268
|
-
else if (sec.isExecutable && !sec.name.startsWith(".text") && !sec.name.startsWith(".code") && (sec.characteristics & IMAGE_SCN.CNT_INITIALIZED_DATA) !== 0) anomalies.push({
|
|
269
|
-
sectionName: sec.name,
|
|
270
|
-
anomalyType: "executable_data",
|
|
271
|
-
severity: "medium",
|
|
272
|
-
details: `Data section ${sec.name} has execute permission`
|
|
273
|
-
});
|
|
274
|
-
return anomalies;
|
|
275
|
-
}
|
|
276
|
-
async _readCoreHeaders(hProcess, base) {
|
|
277
|
-
const e_lfanew = ReadProcessMemory(hProcess, base, 64).readUInt32LE(60);
|
|
278
|
-
const ntData = ReadProcessMemory(hProcess, base + BigInt(e_lfanew), 264);
|
|
279
|
-
const numSections = ntData.readUInt16LE(6);
|
|
280
|
-
const sizeOfOptionalHeader = ntData.readUInt16LE(20);
|
|
281
|
-
const isPE32Plus = ntData.readUInt16LE(24) === PE32PLUS_MAGIC;
|
|
282
|
-
const numberOfRvaAndSizes = isPE32Plus ? ntData.readUInt32LE(132) : ntData.readUInt32LE(116);
|
|
283
|
-
const dataDirectoriesOffset = isPE32Plus ? 136 : 120;
|
|
284
|
-
const dataDirectories = [];
|
|
285
|
-
for (let i = 0; i < Math.min(numberOfRvaAndSizes, 16); i++) {
|
|
286
|
-
const off = dataDirectoriesOffset + i * 8;
|
|
287
|
-
if (off + 8 <= ntData.length) dataDirectories.push({
|
|
288
|
-
rva: ntData.readUInt32LE(off),
|
|
289
|
-
size: ntData.readUInt32LE(off + 4)
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
return {
|
|
293
|
-
numSections,
|
|
294
|
-
isPE32Plus,
|
|
295
|
-
firstSectionOffset: e_lfanew + 4 + 20 + sizeOfOptionalHeader,
|
|
296
|
-
dataDirectories
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
_readThunkArray(hProcess, base, thunkRva, isPE32Plus) {
|
|
300
|
-
const thunkSize = isPE32Plus ? 8 : 4;
|
|
301
|
-
const functions = [];
|
|
302
|
-
const IMAGE_ORDINAL_FLAG = isPE32Plus ? 9223372036854775808n : 2147483648n;
|
|
303
|
-
for (let i = 0; i < 2e3; i++) {
|
|
304
|
-
const thunkData = ReadProcessMemory(hProcess, base + BigInt(thunkRva + i * thunkSize), thunkSize);
|
|
305
|
-
const thunkValue = isPE32Plus ? thunkData.readBigUInt64LE(0) : BigInt(thunkData.readUInt32LE(0));
|
|
306
|
-
if (thunkValue === 0n) break;
|
|
307
|
-
if ((thunkValue & IMAGE_ORDINAL_FLAG) !== 0n) functions.push({
|
|
308
|
-
name: `Ordinal#${Number(thunkValue & 65535n)}`,
|
|
309
|
-
ordinal: Number(thunkValue & 65535n),
|
|
310
|
-
hint: 0,
|
|
311
|
-
thunkRva: `0x${(thunkRva + i * thunkSize).toString(16)}`
|
|
312
|
-
});
|
|
313
|
-
else {
|
|
314
|
-
const hintNameRva = Number(thunkValue);
|
|
315
|
-
const hintNameData = ReadProcessMemory(hProcess, base + BigInt(hintNameRva), 258);
|
|
316
|
-
const hint = hintNameData.readUInt16LE(0);
|
|
317
|
-
const nullIdx = hintNameData.indexOf(0, 2);
|
|
318
|
-
const name = hintNameData.subarray(2, nullIdx > 2 ? nullIdx : 258).toString("ascii");
|
|
319
|
-
functions.push({
|
|
320
|
-
name,
|
|
321
|
-
ordinal: 0,
|
|
322
|
-
hint,
|
|
323
|
-
thunkRva: `0x${(thunkRva + i * thunkSize).toString(16)}`
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return functions;
|
|
328
|
-
}
|
|
329
|
-
_enumerateModulesInternal(hProcess) {
|
|
330
|
-
const modules = [];
|
|
331
|
-
try {
|
|
332
|
-
const { modules: modHandles, count } = EnumProcessModules(hProcess);
|
|
333
|
-
for (let i = 0; i < count; i++) {
|
|
334
|
-
const hMod = modHandles[i];
|
|
335
|
-
const name = GetModuleBaseName(hProcess, hMod);
|
|
336
|
-
const info = GetModuleInformation(hProcess, hMod);
|
|
337
|
-
const modulePath = GetModuleFileNameEx(hProcess, hMod) ?? name;
|
|
338
|
-
if (info.success) modules.push({
|
|
339
|
-
name,
|
|
340
|
-
base: `0x${info.info.lpBaseOfDll.toString(16)}`,
|
|
341
|
-
path: modulePath,
|
|
342
|
-
size: info.info.SizeOfImage
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
} catch (e) {
|
|
346
|
-
logger.debug(`Module enumeration failed: ${e}`);
|
|
347
|
-
}
|
|
348
|
-
return modules;
|
|
349
|
-
}
|
|
350
|
-
_rvaToFileOffset(peData, rva) {
|
|
351
|
-
const e_lfanew = peData.readUInt32LE(60);
|
|
352
|
-
const numSections = peData.readUInt16LE(e_lfanew + 6);
|
|
353
|
-
const sizeOfOptionalHeader = peData.readUInt16LE(e_lfanew + 20);
|
|
354
|
-
const secStart = e_lfanew + 24 + sizeOfOptionalHeader;
|
|
355
|
-
for (let i = 0; i < numSections; i++) {
|
|
356
|
-
const off = secStart + i * 40;
|
|
357
|
-
if (off + 40 > peData.length) break;
|
|
358
|
-
const virtualAddr = peData.readUInt32LE(off + 12);
|
|
359
|
-
const virtualSize = peData.readUInt32LE(off + 8);
|
|
360
|
-
const rawOffset = peData.readUInt32LE(off + 20);
|
|
361
|
-
if (rva >= virtualAddr && rva < virtualAddr + virtualSize) return rawOffset + (rva - virtualAddr);
|
|
362
|
-
}
|
|
363
|
-
return -1;
|
|
364
|
-
}
|
|
365
|
-
_classifyHook(memBytes) {
|
|
366
|
-
if (memBytes[0] === 233) return "jmp_rel32";
|
|
367
|
-
if (memBytes[0] === 255 && memBytes[1] === 37) return "jmp_abs64";
|
|
368
|
-
if (memBytes[0] === 104 && memBytes[5] === 195) return "push_ret";
|
|
369
|
-
return "unknown";
|
|
370
|
-
}
|
|
371
|
-
_decodeJumpTarget(memBytes, funcAddr) {
|
|
372
|
-
if (memBytes[0] === 233) {
|
|
373
|
-
const rel32 = memBytes.readInt32LE(1);
|
|
374
|
-
return `0x${(funcAddr + 5n + BigInt(rel32)).toString(16)}`;
|
|
375
|
-
}
|
|
376
|
-
if (memBytes[0] === 255 && memBytes[1] === 37) {
|
|
377
|
-
if (memBytes.length >= 14) return `0x${memBytes.readBigUInt64LE(6).toString(16)}`;
|
|
378
|
-
}
|
|
379
|
-
if (memBytes[0] === 104) return `0x${memBytes.readUInt32LE(1).toString(16)}`;
|
|
380
|
-
return "0x0";
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
const peAnalyzer = new PEAnalyzer();
|
|
384
|
-
//#endregion
|
|
385
|
-
export { PEAnalyzer, peAnalyzer };
|