@jshookmcp/jshook 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +32 -49
  3. package/README.zh.md +32 -47
  4. package/dist/AntiCheatDetector-B6d4Qe9D.mjs +1 -0
  5. package/dist/BrowserSessionCoordinator-BJ-HOxo0.mjs +1 -0
  6. package/dist/CacheAdapters-CsNtQIR8.mjs +1 -0
  7. package/dist/CodeInjector-Cll_7bLJ.mjs +1 -0
  8. package/dist/ConsoleMonitor-CxDJV15E.mjs +306 -0
  9. package/dist/DOMInspector-C19J4zeq.mjs +95 -0
  10. package/dist/DarwinAPI-ZfQdpLNI.mjs +1 -0
  11. package/dist/DetailedDataManager-DmQ1LT-W.mjs +1 -0
  12. package/dist/EventBus-DL8iLA09.mjs +1 -0
  13. package/dist/EvidenceGraphBridge-BtbwXsLC.mjs +1 -0
  14. package/dist/ExtensionManager-BD724zkO.mjs +1 -0
  15. package/dist/ExtensionManager.tools-oVMJgPcN.mjs +1 -0
  16. package/dist/FingerprintManager-DT0EAUEo.mjs +1 -0
  17. package/dist/HardwareBreakpoint-BUfPdp0f.mjs +1 -0
  18. package/dist/HeapAnalyzer-B_aqY8oj.mjs +1 -0
  19. package/dist/{HookGeneratorBuilders.core.generators.storage-CTbB4Lcx.mjs → HookGeneratorBuilders.core.generators.storage-DzD6dIJd.mjs} +66 -101
  20. package/dist/InstrumentationSession-D_G1ZPyd.mjs +1 -0
  21. package/dist/MCPServer.search.handlers.domain-BbS-6LnX.mjs +1 -0
  22. package/dist/MemoryController-X1XNSn1n.mjs +2 -0
  23. package/dist/MemoryScanSession-DG_F-PjE.mjs +1 -0
  24. package/dist/MemoryScanner-g1_L1ub5.mjs +1 -0
  25. package/dist/NativeMemoryManager.impl-DniBe2wf.mjs +1 -0
  26. package/dist/NativeMemoryManager.utils-BHy1P_jM.mjs +1 -0
  27. package/dist/NetworkMonitor-B_-au6aV.mjs +185 -0
  28. package/dist/PEAnalyzer-yWQaGrcx.mjs +1 -0
  29. package/dist/PageController-Dfsm1_o7.mjs +1 -0
  30. package/dist/PointerChainEngine-BhCUkmxY.mjs +1 -0
  31. package/dist/PrerequisiteError-BjCQA-gK.mjs +1 -0
  32. package/dist/ProcessRegistry-C-bN48oR.mjs +1 -0
  33. package/dist/ResponseBuilder-BfWP-uaT.mjs +1 -0
  34. package/dist/ReverseEvidenceGraph-BhSYYdiI.mjs +2 -0
  35. package/dist/RingBuffer-Dm54ELKT.mjs +1 -0
  36. package/dist/ScriptManager-LWGPTdvD.mjs +7 -0
  37. package/dist/ServerRuntimeState-D2bWHqEE.mjs +1 -0
  38. package/dist/Speedhack-yseDPSZ9.mjs +1 -0
  39. package/dist/StealthVerifier-BmcxfwSF.mjs +1 -0
  40. package/dist/StructureAnalyzer-C5lpuZkg.mjs +2 -0
  41. package/dist/ToolCatalog-CYdD9F5f.mjs +1 -0
  42. package/dist/ToolError-DWU_z7gp.mjs +1 -0
  43. package/dist/ToolProbe-C7ZU2x7M.mjs +1 -0
  44. package/dist/ToolRegistry-C5oB8KP8.mjs +1 -0
  45. package/dist/ToolRouter.policy-CfhJczkt.mjs +4 -0
  46. package/dist/TraceRecorder-BiJWBXHX.mjs +272 -0
  47. package/dist/VersionDetector-CHT36Az0.mjs +9 -0
  48. package/dist/Win32API-eUCF57l_.mjs +1 -0
  49. package/dist/Win32Debug-CYrIQBvr.mjs +1 -0
  50. package/dist/WorkflowEngine-D876meOO.mjs +1 -0
  51. package/dist/analysis-D4swdMvq.mjs +6 -0
  52. package/dist/{antidebug-BRKeyt27.mjs → antidebug-7L3ygj_9.mjs} +8 -259
  53. package/dist/apk-packer-BqXcInnX.mjs +1 -0
  54. package/dist/artifactRetention-BCPQASm7.mjs +1 -0
  55. package/dist/artifacts-CkodUM4j.mjs +1 -0
  56. package/dist/authorization-schema-BOFwSXUN.mjs +1 -0
  57. package/dist/betterSqlite3-Brtq-SIQ.mjs +1 -0
  58. package/dist/binary-instrument-DU7V6TUM.mjs +7 -0
  59. package/dist/binary-secrets-PdMVoyt0.mjs +1 -0
  60. package/dist/bind-helpers-m2U8glkF.mjs +1 -0
  61. package/dist/boringssl-inspector-BBaJwwkU.mjs +2 -0
  62. package/dist/browser-Qqco2rOT.mjs +11 -0
  63. package/dist/capabilities-CyXuKUl1.mjs +1 -0
  64. package/dist/chunk-C_pMuVsO.mjs +1 -0
  65. package/dist/collector-Bpl6qy2L.mjs +1 -0
  66. package/dist/concurrency-DCr8WQ2M.mjs +1 -0
  67. package/dist/constants-BYj8Xek8.mjs +1 -0
  68. package/dist/coordination-CWXW1o8K.mjs +1 -0
  69. package/dist/dart-inspector-7AkPeZ_Q.mjs +0 -0
  70. package/dist/debugger-DyALjYMk.mjs +1 -0
  71. package/dist/definitions-BWxBke3r.mjs +1 -0
  72. package/dist/definitions-BYwATKc-.mjs +1 -0
  73. package/dist/definitions-B_83XfNQ.mjs +1 -0
  74. package/dist/definitions-Bf3H1EwV.mjs +1 -0
  75. package/dist/definitions-BftdXgXI.mjs +1 -0
  76. package/dist/definitions-Bio5XJYy.mjs +1 -0
  77. package/dist/definitions-C3qNgSn1.mjs +1 -0
  78. package/dist/definitions-CB6vmOer.mjs +1 -0
  79. package/dist/definitions-CMZRSy3k.mjs +1 -0
  80. package/dist/definitions-CQd7yCQH.mjs +1 -0
  81. package/dist/definitions-CT8ln6GQ.mjs +1 -0
  82. package/dist/definitions-Cenu6mxo.mjs +1 -0
  83. package/dist/definitions-D4g-MS10.mjs +1 -0
  84. package/dist/definitions-D5wl_8HN.mjs +1 -0
  85. package/dist/definitions-DAQm1Xar.mjs +1 -0
  86. package/dist/definitions-DP1vgxEY.mjs +1 -0
  87. package/dist/definitions-DxFNRQNK2.mjs +1 -0
  88. package/dist/definitions-Ibci7e_L.mjs +1 -0
  89. package/dist/definitions-OeLvmlQy.mjs +1 -0
  90. package/dist/definitions-RZYGD_Ey.mjs +1 -0
  91. package/dist/definitions-Tls8c0A0.mjs +1 -0
  92. package/dist/definitions-bybDvnG0.mjs +26 -0
  93. package/dist/definitions-l7TjdE6V.mjs +1 -0
  94. package/dist/encoding-ycOaz8Vr.mjs +2 -0
  95. package/dist/ensure-browser-core-DxWC-NTp.mjs +1 -0
  96. package/dist/evidence-graph-bridge-CV_UdYqj.mjs +1 -0
  97. package/dist/factory-CKr4fAE1.mjs +1 -0
  98. package/dist/flat-target-session-DvcQX7J5.mjs +1 -0
  99. package/dist/formatAddress-vLA_hOJt.mjs +1 -0
  100. package/dist/graphql-B2TiPEow.mjs +62 -0
  101. package/dist/handlers-0yKLRIfo.mjs +2 -0
  102. package/dist/handlers-8zN_vBIz.mjs +1 -0
  103. package/dist/handlers-B62K4FTc.mjs +1 -0
  104. package/dist/handlers-BpDlVVVU.mjs +1 -0
  105. package/dist/handlers-CMJK7m1c.mjs +31 -0
  106. package/dist/handlers-D2ZOul9p.mjs +54 -0
  107. package/dist/handlers-D5E40ssn.mjs +5 -0
  108. package/dist/handlers-DGbdQAgD.mjs +4 -0
  109. package/dist/handlers-DHO3rjsW.mjs +1 -0
  110. package/dist/handlers-FJ80VzUI.mjs +2 -0
  111. package/dist/handlers-VHWrxbM_.mjs +1 -0
  112. package/dist/handlers-l8QIKqBj.mjs +2 -0
  113. package/dist/handlers-mPFiNPe8.mjs +302 -0
  114. package/dist/{handlers-Dz9PYsCa.mjs → handlers-yo_xYzT8.mjs} +118 -904
  115. package/dist/handlers.impl-D9Hh8Bgl.mjs +1 -0
  116. package/dist/hooks-D4XLfgtV.mjs +600 -0
  117. package/dist/index.mjs +13 -5240
  118. package/dist/jadx-search-B_Yse0Zh.mjs +5 -0
  119. package/dist/logger-sBC6IdRT.mjs +1 -0
  120. package/dist/maintenance-BUpIukhg.mjs +1 -0
  121. package/dist/manifest-0Jpt_AQa.mjs +1 -0
  122. package/dist/manifest-B3fZbSWR.mjs +1 -0
  123. package/dist/manifest-B7NB2rh2.mjs +1 -0
  124. package/dist/manifest-BDi4nbH1.mjs +1 -0
  125. package/dist/manifest-BLDfkE7n.mjs +1 -0
  126. package/dist/manifest-BcXbB4gf.mjs +1 -0
  127. package/dist/manifest-Bdnc_vrc.mjs +1 -0
  128. package/dist/manifest-BuYKgCnp.mjs +1 -0
  129. package/dist/manifest-CBfNnGPV.mjs +1 -0
  130. package/dist/manifest-CPS1Xv69.mjs +1 -0
  131. package/dist/manifest-CQH9FhwI.mjs +1 -0
  132. package/dist/manifest-CRryuZF4.mjs +1 -0
  133. package/dist/manifest-CctIumog.mjs +1 -0
  134. package/dist/manifest-CvTe5ZGV2.mjs +1 -0
  135. package/dist/manifest-D-5GH0DV.mjs +1 -0
  136. package/dist/manifest-D3Ssf3IC.mjs +1 -0
  137. package/dist/manifest-D5ck3NvC.mjs +1 -0
  138. package/dist/manifest-D9jUUJAu.mjs +1 -0
  139. package/dist/manifest-DCx6w2XV.mjs +1 -0
  140. package/dist/manifest-DG19q-Ld.mjs +1 -0
  141. package/dist/manifest-DLMlD0Zc.mjs +1 -0
  142. package/dist/manifest-DYpn8w_h.mjs +1 -0
  143. package/dist/manifest-DYzWI8Xs.mjs +1 -0
  144. package/dist/manifest-D_obs5F4.mjs +1 -0
  145. package/dist/manifest-DujQqEQR.mjs +2 -0
  146. package/dist/manifest-DwL2ik8P.mjs +1 -0
  147. package/dist/manifest-ItF5P8A12.mjs +1 -0
  148. package/dist/manifest-KZphqIyX.mjs +1 -0
  149. package/dist/manifest-LG42zPLY2.mjs +1 -0
  150. package/dist/manifest-LLdI5m4T.mjs +1 -0
  151. package/dist/manifest-QYbQXJn0.mjs +1 -0
  152. package/dist/manifest-RcpX_MyZ.mjs +123 -0
  153. package/dist/manifest-YgVd8Sgz.mjs +1 -0
  154. package/dist/manifest-Zy7Odg5J.mjs +1 -0
  155. package/dist/manifest-ff1H7Pdp.mjs +1 -0
  156. package/dist/manifest-iuhF6pTL2.mjs +1 -0
  157. package/dist/manifest-nXHmtMSp2.mjs +1 -0
  158. package/dist/manifest-xWfu6iLo.mjs +1 -0
  159. package/dist/manifest-yC16OhL2.mjs +1 -0
  160. package/dist/manifest-ztWJoXy4.mjs +1 -0
  161. package/dist/matchesWildcardPattern-BAG6LvX5.mjs +1 -0
  162. package/dist/modules-BPBcSaM-.mjs +333 -0
  163. package/dist/mojo-ipc-BhwsdVUW.mjs +9 -0
  164. package/dist/native/scripts/linux/enum-windows.sh +12 -12
  165. package/dist/native/scripts/macos/enum-windows.applescript +22 -22
  166. package/dist/native-j8l473zn.mjs +961 -0
  167. package/dist/network-T0VRwNPd.mjs +7 -0
  168. package/dist/outputPaths-B4Ic4RZh.mjs +2 -0
  169. package/dist/parse-args-Bw413PlW.mjs +1 -0
  170. package/dist/platform-CzaQtISh.mjs +93 -0
  171. package/dist/playwright-cdp-fallback-DqFdx9-s.mjs +1 -0
  172. package/dist/process-CWhsCWrf.mjs +2 -0
  173. package/dist/proxy-DZFlDsG3.mjs +2 -0
  174. package/dist/registry-DH4sc1dt.mjs +1 -0
  175. package/dist/renderer-pid-9tJnZ_9N.mjs +1 -0
  176. package/dist/response-C7rKQst4.mjs +1 -0
  177. package/dist/search-defaults-lYBVn_3L.mjs +1 -0
  178. package/dist/server/plugin-api.d.mts +19 -36
  179. package/dist/server/plugin-api.mjs +1 -293
  180. package/dist/shared-state-board-BSjXLUV1.mjs +1 -0
  181. package/dist/sourcemap-Dh3Ai_ur.mjs +1 -0
  182. package/dist/ssrf-policy-CsIJGkpd.mjs +1 -0
  183. package/dist/streaming-BcJ0B6ao.mjs +1 -0
  184. package/dist/tool-builder-qif8M9-K.mjs +1 -0
  185. package/dist/transform-DOxzeWPB.mjs +103 -0
  186. package/dist/types-D9EiE5o9.mjs +1 -0
  187. package/dist/types-Fz69RzbZ.mjs +1 -0
  188. package/dist/wasm-CZ_HTfKR.mjs +174 -0
  189. package/dist/webcrack-C1iYG_EX.mjs +46 -0
  190. package/dist/workflow-BdwQmARn.mjs +101 -0
  191. package/package.json +55 -82
  192. package/src/native/scripts/linux/enum-windows.sh +12 -12
  193. package/src/native/scripts/macos/enum-windows.applescript +22 -22
  194. package/dist/AntiCheatDetector-CqGDXmfc.mjs +0 -350
  195. package/dist/CacheAdapters-jJFy20G-.mjs +0 -80
  196. package/dist/CodeInjector-BdjRfNx7.mjs +0 -150
  197. package/dist/ConsoleMonitor-DykL3IAw.mjs +0 -2269
  198. package/dist/DarwinAPI-ETyy0xyo.mjs +0 -363
  199. package/dist/DetailedDataManager-HT49OrvF.mjs +0 -217
  200. package/dist/EventBus-DFKvADm3.mjs +0 -141
  201. package/dist/EvidenceGraphBridge-318Oi0Lf.mjs +0 -153
  202. package/dist/ExtensionManager-BDMsY2Dz.mjs +0 -721
  203. package/dist/FingerprintManager-BN4UQWnX.mjs +0 -96
  204. package/dist/HardwareBreakpoint-Cc2AFq1Y.mjs +0 -239
  205. package/dist/HeapAnalyzer-DruMgsgj.mjs +0 -284
  206. package/dist/InstrumentationSession-DLH0vd-z.mjs +0 -244
  207. package/dist/MemoryController-CMtviNW_.mjs +0 -167
  208. package/dist/MemoryScanSession-ITgb_NMi.mjs +0 -278
  209. package/dist/MemoryScanner-CiL7Z3ey.mjs +0 -428
  210. package/dist/NativeMemoryManager.impl-D9Lkovvn.mjs +0 -485
  211. package/dist/NativeMemoryManager.utils-BBlAixF5.mjs +0 -165
  212. package/dist/PEAnalyzer-DMQ44gen.mjs +0 -385
  213. package/dist/PageController-BPJNqqBN.mjs +0 -431
  214. package/dist/PointerChainEngine-K7wN8Z-w.mjs +0 -325
  215. package/dist/PrerequisiteError-TuyZIs6n.mjs +0 -20
  216. package/dist/ProcessRegistry-zGg12QbE.mjs +0 -74
  217. package/dist/ResponseBuilder-CJXWmWNw.mjs +0 -143
  218. package/dist/ReverseEvidenceGraph-C02-gXOh.mjs +0 -269
  219. package/dist/ScriptManager-ZuWD-0Jg.mjs +0 -3003
  220. package/dist/Speedhack-D-z0umeT.mjs +0 -156
  221. package/dist/StealthVerifier-BWmPgQsv.mjs +0 -135
  222. package/dist/StructureAnalyzer-Cav5AVSL.mjs +0 -429
  223. package/dist/ToolCatalog-5OJdMiF0.mjs +0 -582
  224. package/dist/ToolError-jh9whhMd.mjs +0 -15
  225. package/dist/ToolProbe-DbCFGyrg.mjs +0 -45
  226. package/dist/ToolRegistry-B9krbTtI.mjs +0 -180
  227. package/dist/ToolRouter.policy-BGDAGyeH.mjs +0 -344
  228. package/dist/TraceRecorder-B41Z5XBj.mjs +0 -1286
  229. package/dist/VersionDetector-K3V4vGsw.mjs +0 -104
  230. package/dist/Win32API-C2kjj0ze.mjs +0 -346
  231. package/dist/Win32Debug-CKrGOTpo.mjs +0 -274
  232. package/dist/WorkflowEngine-DJ6M4opp.mjs +0 -569
  233. package/dist/analysis-BHeJW2Nb.mjs +0 -1234
  234. package/dist/artifactRetention-CPXkUJXp.mjs +0 -598
  235. package/dist/artifacts-DkfosXH3.mjs +0 -59
  236. package/dist/authorization-schema-DRqyJMSk.mjs +0 -31
  237. package/dist/betterSqlite3-DLSBZodi.mjs +0 -74
  238. package/dist/binary-instrument--V3MAhJ4.mjs +0 -971
  239. package/dist/bind-helpers-ClV34xdn.mjs +0 -42
  240. package/dist/boringssl-inspector-Bo_LOLaS.mjs +0 -180
  241. package/dist/browser-Dx3_S2cG.mjs +0 -4369
  242. package/dist/capabilities-CcHlvWgK.mjs +0 -33
  243. package/dist/chunk-CjcI7cDX.mjs +0 -15
  244. package/dist/concurrency-Drev_Vz9.mjs +0 -41
  245. package/dist/constants-CDZLOoVv.mjs +0 -534
  246. package/dist/coordination-DgItD9DL.mjs +0 -259
  247. package/dist/debugger-RS3RSAqs.mjs +0 -1288
  248. package/dist/definitions-BEoYofW5.mjs +0 -47
  249. package/dist/definitions-BRaefg3u.mjs +0 -365
  250. package/dist/definitions-BbkvZkiv.mjs +0 -96
  251. package/dist/definitions-BtWSHJ3o.mjs +0 -17
  252. package/dist/definitions-C1gCHO0i.mjs +0 -43
  253. package/dist/definitions-CDOg_b-l.mjs +0 -138
  254. package/dist/definitions-CVPD9hzZ.mjs +0 -54
  255. package/dist/definitions-Cea8Lgl7.mjs +0 -94
  256. package/dist/definitions-DAgIyjxM.mjs +0 -10
  257. package/dist/definitions-DJA27nsL.mjs +0 -66
  258. package/dist/definitions-DKPFU3LW.mjs +0 -25
  259. package/dist/definitions-DPRpZQ96.mjs +0 -47
  260. package/dist/definitions-DUE5gmdn.mjs +0 -18
  261. package/dist/definitions-DYVjOtxa.mjs +0 -26
  262. package/dist/definitions-DcYLVLCo.mjs +0 -37
  263. package/dist/definitions-Pp5LI2H4.mjs +0 -27
  264. package/dist/definitions-j9KdHVNR.mjs +0 -14
  265. package/dist/definitions-uzkjBwa7.mjs +0 -258
  266. package/dist/definitions-va-AnLuQ.mjs +0 -28
  267. package/dist/encoding-DJeqHmpd.mjs +0 -1079
  268. package/dist/evidence-graph-bridge-DcYizFk2.mjs +0 -136
  269. package/dist/factory-C90tBff6.mjs +0 -575
  270. package/dist/flat-target-session-Dgax2Cy3.mjs +0 -29
  271. package/dist/formatAddress-nnMvEohD.mjs +0 -17
  272. package/dist/graphql-CoHrhweh.mjs +0 -1197
  273. package/dist/handlers-4jmR0nMs.mjs +0 -898
  274. package/dist/handlers-BAHPxcch.mjs +0 -789
  275. package/dist/handlers-BOs9b907.mjs +0 -2600
  276. package/dist/handlers-BWXEy6ef.mjs +0 -917
  277. package/dist/handlers-Bndn6QvE.mjs +0 -111
  278. package/dist/handlers-BqC4bD4s.mjs +0 -681
  279. package/dist/handlers-BtYq60bM2.mjs +0 -276
  280. package/dist/handlers-BzgcB4iv.mjs +0 -799
  281. package/dist/handlers-CRyRWj2b.mjs +0 -859
  282. package/dist/handlers-CVv2H1uq.mjs +0 -592
  283. package/dist/handlers-Dl5a7JS4.mjs +0 -572
  284. package/dist/handlers-Dx2d7jt7.mjs +0 -2537
  285. package/dist/handlers-HujRKC3b.mjs +0 -661
  286. package/dist/handlers.impl-XWXkQfyi.mjs +0 -807
  287. package/dist/hooks-B1B8NRHL.mjs +0 -898
  288. package/dist/logger-Dh_xb7_2.mjs +0 -93
  289. package/dist/maintenance-PRMkLVRW.mjs +0 -835
  290. package/dist/manifest-67Bok-Si.mjs +0 -58
  291. package/dist/manifest-6lNTMZAB2.mjs +0 -87
  292. package/dist/manifest-B2duEHiH.mjs +0 -90
  293. package/dist/manifest-B6EY9Vm8.mjs +0 -57
  294. package/dist/manifest-B6nKSbyY.mjs +0 -95
  295. package/dist/manifest-BL8AQNPF.mjs +0 -106
  296. package/dist/manifest-BSZvJJmV.mjs +0 -47
  297. package/dist/manifest-BU7qzUyX.mjs +0 -418
  298. package/dist/manifest-Bl62e8WK.mjs +0 -49
  299. package/dist/manifest-Bo5cXjdt.mjs +0 -82
  300. package/dist/manifest-BpS4gtUK.mjs +0 -1347
  301. package/dist/manifest-Bv65_e2W.mjs +0 -101
  302. package/dist/manifest-BytNIF4Z.mjs +0 -117
  303. package/dist/manifest-C-xtsjS3.mjs +0 -81
  304. package/dist/manifest-CDYl7OhA.mjs +0 -66
  305. package/dist/manifest-CRZ3xmkD.mjs +0 -61
  306. package/dist/manifest-CoW6u4Tp.mjs +0 -132
  307. package/dist/manifest-Cq5zN_8A.mjs +0 -50
  308. package/dist/manifest-D7YZM_2e.mjs +0 -194
  309. package/dist/manifest-DE_VrAeQ.mjs +0 -314
  310. package/dist/manifest-DGsXSCpT.mjs +0 -39
  311. package/dist/manifest-DJ2vfEuW.mjs +0 -156
  312. package/dist/manifest-DPXDYhEu.mjs +0 -80
  313. package/dist/manifest-Dd4fQb0a.mjs +0 -322
  314. package/dist/manifest-Deq6opGg.mjs +0 -223
  315. package/dist/manifest-DfJTafJK.mjs +0 -37
  316. package/dist/manifest-DgOdgN_j.mjs +0 -50
  317. package/dist/manifest-DlbMW4v4.mjs +0 -47
  318. package/dist/manifest-DmVfbH0w.mjs +0 -374
  319. package/dist/manifest-Dog6Ddjr.mjs +0 -109
  320. package/dist/manifest-DvgU5FWb.mjs +0 -58
  321. package/dist/manifest-HsfDBs7j.mjs +0 -50
  322. package/dist/manifest-I8oQHvCG.mjs +0 -186
  323. package/dist/manifest-NvH_a-av.mjs +0 -786
  324. package/dist/manifest-cEJU1v0Z.mjs +0 -129
  325. package/dist/manifest-wOl5XLB12.mjs +0 -112
  326. package/dist/modules-tZozf0LQ.mjs +0 -10635
  327. package/dist/mojo-ipc-DXNEXEqb.mjs +0 -640
  328. package/dist/network-CPVvwvFg.mjs +0 -3852
  329. package/dist/outputPaths-um7lCRY3.mjs +0 -1141
  330. package/dist/parse-args-B4cY5Vx5.mjs +0 -39
  331. package/dist/platform-CYeFoTWp.mjs +0 -2161
  332. package/dist/process-BTbgcVc6.mjs +0 -1306
  333. package/dist/proxy-r8YN6nP1.mjs +0 -192
  334. package/dist/registry-Bl8ZQW61.mjs +0 -34
  335. package/dist/response-CWhh2aLo.mjs +0 -34
  336. package/dist/shared-state-board-BoZnSoj-.mjs +0 -586
  337. package/dist/sourcemap-BIDHUVXy.mjs +0 -934
  338. package/dist/ssrf-policy-Dsqd-DTX.mjs +0 -166
  339. package/dist/streaming-Dal6utPp.mjs +0 -725
  340. package/dist/tool-builder-BHJp32mV.mjs +0 -186
  341. package/dist/transform-DRVgGG90.mjs +0 -1011
  342. package/dist/types-Bx92KJfT.mjs +0 -4
  343. package/dist/types-DDBWs9UP.mjs +0 -37
  344. package/dist/wasm-BYx5UOeG.mjs +0 -1044
  345. package/dist/webcrack-Be0_FccV.mjs +0 -747
  346. package/dist/workflow-BpuKEtvn.mjs +0 -725
@@ -1,1234 +0,0 @@
1
- import { t as logger } from "./logger-Dh_xb7_2.mjs";
2
- import { d as ANALYSIS_MAX_SAFE_RESPONSE_BYTES, f as ANALYSIS_MAX_SUMMARY_FILES, u as ANALYSIS_MAX_SAFE_COLLECTED_BYTES } from "./constants-CDZLOoVv.mjs";
3
- import { a as serializeError, n as asJsonResponse, r as asTextResponse, t as asErrorResponse } from "./response-CWhh2aLo.mjs";
4
- import { a as argString, i as argObject, n as argEnum, r as argNumber, s as argStringRequired, t as argBool } from "./parse-args-B4cY5Vx5.mjs";
5
- import { s as evaluateWithTimeout } from "./PageController-BPJNqqBN.mjs";
6
- import "./definitions-CDOg_b-l.mjs";
7
- import { n as JSVMPDeobfuscator, t as runWebcrack } from "./webcrack-Be0_FccV.mjs";
8
- import * as parser from "@babel/parser";
9
- import traverse from "@babel/traverse";
10
- import * as t from "@babel/types";
11
- //#region src/server/domains/analysis/handlers/ast-safe-replace.ts
12
- const REGEX_OPENER_PREV = new Set([
13
- "=",
14
- "(",
15
- "[",
16
- ",",
17
- ";",
18
- "{",
19
- "!",
20
- "&",
21
- "|",
22
- "?",
23
- ":",
24
- "~",
25
- "^",
26
- "+",
27
- "-",
28
- "*",
29
- "%",
30
- "<",
31
- ">",
32
- "\n"
33
- ]);
34
- function cloneRegex(pattern) {
35
- return new RegExp(pattern.source, pattern.flags);
36
- }
37
- function mergeProtectedRanges(ranges) {
38
- if (ranges.length === 0) return [];
39
- const merged = [];
40
- const sorted = ranges.toSorted((a, b) => a.start - b.start || a.end - b.end);
41
- for (const range of sorted) {
42
- const last = merged[merged.length - 1];
43
- if (!last || range.start > last.end) {
44
- merged.push({ ...range });
45
- continue;
46
- }
47
- last.end = Math.max(last.end, range.end);
48
- }
49
- return merged;
50
- }
51
- function collectProtectedRangesWithAst(code) {
52
- try {
53
- const ast = parser.parse(code, {
54
- sourceType: "unambiguous",
55
- plugins: ["jsx", "typescript"],
56
- errorRecovery: true
57
- });
58
- const ranges = [];
59
- const pushRange = (start, end) => {
60
- if (typeof start === "number" && typeof end === "number" && end > start) ranges.push({
61
- start,
62
- end
63
- });
64
- };
65
- const comments = Array.isArray(ast.comments) ? ast.comments : [];
66
- for (const comment of comments) pushRange(comment.start, comment.end);
67
- traverse(ast, {
68
- StringLiteral(path) {
69
- pushRange(path.node.start, path.node.end);
70
- path.skip();
71
- },
72
- TemplateElement(path) {
73
- pushRange(path.node.start, path.node.end);
74
- path.skip();
75
- },
76
- RegExpLiteral(path) {
77
- pushRange(path.node.start, path.node.end);
78
- path.skip();
79
- }
80
- });
81
- return mergeProtectedRanges(ranges);
82
- } catch {
83
- return null;
84
- }
85
- }
86
- function getReplaceCallbackOffset(args) {
87
- const maybeOffset = args[args.length - 2];
88
- if (typeof maybeOffset === "number") return maybeOffset;
89
- const fallbackOffset = args[args.length - 3];
90
- return typeof fallbackOffset === "number" ? fallbackOffset : null;
91
- }
92
- function isRegexOpener(code, pos) {
93
- let prevIndex = pos - 1;
94
- while (prevIndex >= 0 && (code[prevIndex] === " " || code[prevIndex] === " " || code[prevIndex] === "\r")) prevIndex--;
95
- if (prevIndex < 0) return true;
96
- const prev = code[prevIndex];
97
- if (REGEX_OPENER_PREV.has(prev)) return true;
98
- if (prev !== ")") return false;
99
- let depth = 1;
100
- let keywordIndex = prevIndex - 1;
101
- while (keywordIndex >= 0 && depth > 0) {
102
- if (code[keywordIndex] === ")") depth++;
103
- if (code[keywordIndex] === "(") depth--;
104
- keywordIndex--;
105
- }
106
- keywordIndex--;
107
- while (keywordIndex >= 0 && (code[keywordIndex] === " " || code[keywordIndex] === " ")) keywordIndex--;
108
- let keyword = "";
109
- while (keywordIndex >= 0 && /[a-z]/.test(code[keywordIndex])) {
110
- keyword = code[keywordIndex] + keyword;
111
- keywordIndex--;
112
- }
113
- return [
114
- "if",
115
- "while",
116
- "for",
117
- "switch",
118
- "return",
119
- "typeof",
120
- "void",
121
- "in",
122
- "of",
123
- "case"
124
- ].includes(keyword);
125
- }
126
- function insideStringLiteralOrComment(code, offset) {
127
- let inStr = null;
128
- let inBlockComment = false;
129
- let inLineComment = false;
130
- let inRegex = false;
131
- for (let index = 0; index < offset; index++) {
132
- const char = code[index];
133
- if (inBlockComment) {
134
- if (char === "*" && code[index + 1] === "/") {
135
- inBlockComment = false;
136
- index++;
137
- }
138
- continue;
139
- }
140
- if (inLineComment) {
141
- if (char === "\n") inLineComment = false;
142
- continue;
143
- }
144
- if (inRegex) {
145
- if (char === "\\") {
146
- index++;
147
- continue;
148
- }
149
- if (char === "/") {
150
- inRegex = false;
151
- index++;
152
- while (index < offset && /[gimsuy]/.test(code[index])) index++;
153
- continue;
154
- }
155
- if (char === "[") {
156
- index++;
157
- while (index < offset && code[index] !== "]") {
158
- if (code[index] === "\\") index++;
159
- index++;
160
- }
161
- continue;
162
- }
163
- continue;
164
- }
165
- if (inStr) {
166
- if (char === "\\") {
167
- index++;
168
- continue;
169
- }
170
- if (char === inStr) inStr = null;
171
- continue;
172
- }
173
- if (char === "/" && code[index + 1] === "/") {
174
- inLineComment = true;
175
- index++;
176
- continue;
177
- }
178
- if (char === "/" && code[index + 1] === "*") {
179
- inBlockComment = true;
180
- index++;
181
- continue;
182
- }
183
- if (char === "/" && isRegexOpener(code, index)) {
184
- inRegex = true;
185
- continue;
186
- }
187
- if (char === "'" || char === "\"" || char === "`") inStr = char;
188
- }
189
- return inStr !== null || inBlockComment || inLineComment || inRegex;
190
- }
191
- function replaceOutsideProtectedRanges(code, pattern, replacement) {
192
- const applyReplacement = (input) => typeof replacement === "string" ? input.replace(cloneRegex(pattern), replacement) : input.replace(cloneRegex(pattern), replacement);
193
- const protectedRanges = collectProtectedRangesWithAst(code);
194
- if (protectedRanges === null) return code.replace(cloneRegex(pattern), (...args) => {
195
- const fullMatch = typeof args[0] === "string" ? args[0] : "";
196
- const offset = getReplaceCallbackOffset(args);
197
- if (offset !== null && insideStringLiteralOrComment(code, offset)) return fullMatch;
198
- return typeof replacement === "string" ? replacement : replacement(fullMatch, ...args.slice(1));
199
- });
200
- if (protectedRanges.length === 0) return applyReplacement(code);
201
- let rewritten = "";
202
- let cursor = 0;
203
- for (const range of protectedRanges) {
204
- if (cursor < range.start) rewritten += applyReplacement(code.slice(cursor, range.start));
205
- rewritten += code.slice(range.start, range.end);
206
- cursor = range.end;
207
- }
208
- if (cursor < code.length) rewritten += applyReplacement(code.slice(cursor));
209
- return rewritten;
210
- }
211
- //#endregion
212
- //#region src/server/domains/analysis/handlers/inline-deobfuscation.ts
213
- const NUMERIC_BINARY_EXPR = /\b(-?\d+(?:\.\d+)?)\s*([+\-%*/])\s*(-?\d+(?:\.\d+)?)\b/g;
214
- const DEAD_CODE_IF_FALSE = /if\s*\(\s*false\s*\)\s*\{[^}]*\}\s*/g;
215
- const DEAD_CODE_IF_FALSE_WITH_ELSE = /if\s*\(\s*false\s*\)\s*\{[^}]*\}\s*else\s*\{([^}]*)\}/g;
216
- const DEAD_CODE_IF_TRUE = /if\s*\(\s*true\s*\)\s*\{([^}]*)\}\s*(?:else\s*\{[^}]*\}\s*)?/g;
217
- const CFF_PATTERN = /var\s+([A-Za-z_$]\w*)\s*=\s*['"]([^'"]+)['"]\.split\(['"]\|['"]\)\s*;\s*var\s+(\w+)\s*=\s*0\s*;\s*while\s*\(\s*!!\[\]\s*\)\s*\{\s*switch\s*\(\s*\1\[\s*\3\+\+\s*\]\s*\)\s*\{([\s\S]*?)\}\s*break;\s*\}/g;
218
- const CFF_PATTERN_VAR2 = /var\s+([A-Za-z_$]\w*)\s*=\s*\[(['"][^'"]*['"]\s*(?:,\s*['"][^'"]*['"]\s*)*)\];\s*var\s+(\w+)\s*=\s*(\d+);\s*while\s*\(\s*!!\[\]\s*\)\s*\{\s*switch\s*\(\s*\1\[\s*\3\+\+\]\s*\)\s*\{([\s\S]*?)\}\s*break;\s*\}/g;
219
- const STRING_CONCAT = /['"]([^'"]*)['"]\s*\+\s*['"]([^'"]*)['"]/g;
220
- function findNonWhitespace(input, start, step) {
221
- for (let index = start; index >= 0 && index < input.length; index += step) {
222
- const char = input[index];
223
- if (char && !/\s/.test(char)) return char;
224
- }
225
- return "";
226
- }
227
- function applyTextReplacements(code, replacements) {
228
- const sorted = replacements.toSorted((a, b) => b.start - a.start || b.end - a.end);
229
- let next = code;
230
- for (const replacement of sorted) next = `${next.slice(0, replacement.start)}${replacement.text}${next.slice(replacement.end)}`;
231
- return next;
232
- }
233
- function getBindingReplacement(path, renameMap) {
234
- const replacement = renameMap.get(path.node.name);
235
- if (!replacement) return null;
236
- const binding = path.scope.getBinding(path.node.name);
237
- if (!binding || !t.isVariableDeclarator(binding.path.node) || !t.isIdentifier(binding.path.node.id) || !renameMap.has(binding.path.node.id.name)) return null;
238
- const isBindingId = binding.identifier === path.node;
239
- const isReference = path.isReferencedIdentifier();
240
- const isAssignmentTarget = path.key === "left" && path.parentPath.isAssignmentExpression();
241
- const isForLoopTarget = path.key === "left" && (path.parentPath.isForInStatement() || path.parentPath.isForOfStatement());
242
- const isUpdateTarget = path.key === "argument" && path.parentPath.isUpdateExpression();
243
- if (!isBindingId && !isReference && !isAssignmentTarget && !isForLoopTarget && !isUpdateTarget) return null;
244
- return replacement;
245
- }
246
- function applyRenameVarsWithAst(code, renameMap) {
247
- try {
248
- const ast = parser.parse(code, {
249
- sourceType: "unambiguous",
250
- plugins: ["jsx", "typescript"],
251
- errorRecovery: true
252
- });
253
- const replacements = /* @__PURE__ */ new Map();
254
- traverse(ast, {
255
- ObjectProperty(path) {
256
- if (!path.node.shorthand || !t.isIdentifier(path.node.key) || !t.isIdentifier(path.node.value)) return;
257
- const valuePath = path.get("value");
258
- if (!valuePath.isIdentifier()) return;
259
- const replacement = getBindingReplacement(valuePath, renameMap);
260
- const { start, end } = path.node;
261
- if (!replacement || start === null || start === void 0) return;
262
- if (end === null || end === void 0) return;
263
- replacements.set(`${start}:${end}`, {
264
- start,
265
- end,
266
- text: `${path.node.key.name}: ${replacement}`
267
- });
268
- path.skip();
269
- },
270
- Identifier(path) {
271
- const replacement = getBindingReplacement(path, renameMap);
272
- const { start, end } = path.node;
273
- if (!replacement || start === null || start === void 0) return;
274
- if (end === null || end === void 0) return;
275
- replacements.set(`${start}:${end}`, {
276
- start,
277
- end,
278
- text: replacement
279
- });
280
- }
281
- });
282
- if (replacements.size === 0) return code;
283
- return applyTextReplacements(code, [...replacements.values()]);
284
- } catch {
285
- return null;
286
- }
287
- }
288
- function applyConstantFold(code) {
289
- let result = code;
290
- result = replaceOutsideProtectedRanges(result, NUMERIC_BINARY_EXPR, (_full, leftRaw, op, rightRaw) => {
291
- const left = Number(leftRaw);
292
- const right = Number(rightRaw);
293
- if (!Number.isFinite(left) || !Number.isFinite(right)) return _full;
294
- let value = null;
295
- if (op === "+") value = left + right;
296
- else if (op === "-") value = left - right;
297
- else if (op === "*") value = left * right;
298
- else if (op === "/" && right !== 0) value = left / right;
299
- else if (op === "%" && right !== 0) value = left % right;
300
- if (value === null || !Number.isFinite(value)) return _full;
301
- return Number.isInteger(value) ? String(value) : String(Number(value.toFixed(12)));
302
- });
303
- result = replaceOutsideProtectedRanges(result, STRING_CONCAT, (_full, left, right) => JSON.stringify(`${left}${right}`));
304
- result = replaceOutsideProtectedRanges(result, /--(\d)/g, (_full, digit) => digit);
305
- result = replaceOutsideProtectedRanges(result, /\+\s*(\d+(?:\.\d+)?)/g, (_full, num) => num);
306
- result = replaceOutsideProtectedRanges(result, /\b0x([0-9a-fA-F]{2,8})\b/g, (_full, hex) => {
307
- const value = Number.parseInt(hex, 16);
308
- return Number.isFinite(value) ? String(value) : _full;
309
- });
310
- return result;
311
- }
312
- function applyDeadCodeRemove(code) {
313
- let result = code;
314
- result = replaceOutsideProtectedRanges(result, DEAD_CODE_IF_FALSE_WITH_ELSE, (_full, elseBody) => elseBody);
315
- result = replaceOutsideProtectedRanges(result, DEAD_CODE_IF_FALSE, "");
316
- result = replaceOutsideProtectedRanges(result, DEAD_CODE_IF_TRUE, (_full, trueBody) => trueBody);
317
- result = replaceOutsideProtectedRanges(result, /\btrue\s*\?\s*([^:]+)\s*:\s*([^,;)\]}]+)/g, (_full, ifVal) => ifVal);
318
- result = replaceOutsideProtectedRanges(result, /\bfalse\s*\?\s*[^:]+\s*:\s*([^,;)}\]]+)/g, (_full, elseVal) => elseVal);
319
- result = replaceOutsideProtectedRanges(result, /if\s*\([^)]*\)\s*\{\s*\}\s*/g, "");
320
- return result;
321
- }
322
- function applyControlFlowFlatten(code) {
323
- let result = code;
324
- result = replaceOutsideProtectedRanges(result, CFF_PATTERN, (_full, _dispatcher, orderRaw, _cursor, switchBody) => {
325
- const caseRegex = /case\s*['"]([^'"]+)['"]\s*:\s*([\s\S]*?)(?=case\s*['"]|default\s*:|$)/g;
326
- const caseMap = /* @__PURE__ */ new Map();
327
- let match;
328
- while ((match = caseRegex.exec(switchBody)) !== null) {
329
- const key = match[1];
330
- const body = (match[2] ?? "").replace(/\bcontinue\s*;?/g, "").replace(/\bbreak\s*;?/g, "").trim();
331
- if (key && body.length > 0) caseMap.set(key, body);
332
- }
333
- const rebuilt = orderRaw.split("|").map((value) => value.trim()).map((token) => caseMap.get(token)).filter((value) => !!value).join("\n");
334
- return rebuilt.length > 0 ? rebuilt : _full;
335
- });
336
- result = replaceOutsideProtectedRanges(result, CFF_PATTERN_VAR2, (_full, _dispatcher, arrContent, _cursor, _startIdx, switchBody) => {
337
- const caseRegex = /case\s*['"]([^'"]+)['"]\s*:\s*([\s\S]*?)(?=case\s*['"]|default\s*:|$)/g;
338
- const caseMap = /* @__PURE__ */ new Map();
339
- let match;
340
- while ((match = caseRegex.exec(switchBody)) !== null) {
341
- const key = match[1];
342
- const body = (match[2] ?? "").replace(/\bcontinue\s*;?/g, "").replace(/\bbreak\s*;?/g, "").trim();
343
- if (key && body.length > 0) caseMap.set(key, body);
344
- }
345
- const rebuilt = arrContent.split(/,\s*/).map((value) => value.replace(/^['"]|['"]$/g, "").trim()).map((token) => caseMap.get(token)).filter((value) => !!value).join("\n");
346
- return rebuilt.length > 0 ? rebuilt : _full;
347
- });
348
- return result;
349
- }
350
- function applyRenameVars(code) {
351
- const declared = /* @__PURE__ */ new Set();
352
- const re = /\b(?:var|let|const)\s+([A-Za-z_$]\w{0,3})\b/g;
353
- let match;
354
- while ((match = re.exec(code)) !== null) {
355
- const name = match[1];
356
- if (name && (name.length <= 2 || name.startsWith("_0x") || name.startsWith("_"))) declared.add(name);
357
- }
358
- if (declared.size === 0) return {
359
- code,
360
- count: 0
361
- };
362
- const renameMap = /* @__PURE__ */ new Map();
363
- let counter = 1;
364
- for (const name of declared) {
365
- renameMap.set(name, `var_${counter}`);
366
- counter++;
367
- }
368
- const astRenamed = applyRenameVarsWithAst(code, renameMap);
369
- if (astRenamed !== null) return {
370
- code: astRenamed,
371
- count: astRenamed === code ? 0 : renameMap.size
372
- };
373
- const newCode = code.replace(new RegExp(`\\b(${[...declared].map((name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})\\b`, "g"), (token, id, offset, full) => {
374
- const replacement = renameMap.get(id);
375
- if (!replacement) return token;
376
- const prev = offset > 0 ? full[offset - 1] : "";
377
- const prevNonWhitespace = findNonWhitespace(full, offset - 1, -1);
378
- const nextNonWhitespace = findNonWhitespace(full, offset + token.length, 1);
379
- if (prev === "." || prev === "'" || prev === "\"" || prev === "`" || prev === "$") return token;
380
- if ((prevNonWhitespace === "{" || prevNonWhitespace === ",") && (nextNonWhitespace === ":" || nextNonWhitespace === "(")) return token;
381
- return replacement;
382
- });
383
- return {
384
- code: newCode,
385
- count: newCode === code ? 0 : renameMap.size
386
- };
387
- }
388
- //#endregion
389
- //#region src/server/domains/analysis/handlers/solve-constraints.ts
390
- const NUMERIC_COMPARATORS = {
391
- "<": (left, right) => left < right,
392
- ">": (left, right) => left > right,
393
- "<=": (left, right) => left <= right,
394
- "<==": (left, right) => left <= right,
395
- ">=": (left, right) => left >= right,
396
- ">==": (left, right) => left >= right,
397
- "==": (left, right) => left === right,
398
- "===": (left, right) => left === right,
399
- "!=": (left, right) => left !== right,
400
- "!==": (left, right) => left !== right
401
- };
402
- const JS_FUCK_RULES = [
403
- {
404
- pattern: "jsfuck",
405
- regex: /\[!\[\]\]\[\(['"]\)constructor['"]\)\]\(!!\[\]\+\[\]\)\(\)/g,
406
- replacement: "\"function Boolean() { [native code] }\""
407
- },
408
- {
409
- pattern: "jsfuck",
410
- regex: /!!\[\]\+\[\]/g,
411
- replacement: "\"true\""
412
- },
413
- {
414
- pattern: "jsfuck",
415
- regex: /!\[\]\+\[\]/g,
416
- replacement: "\"false\""
417
- },
418
- {
419
- pattern: "jsfuck",
420
- regex: /\+!!\[\]/g,
421
- replacement: "1"
422
- },
423
- {
424
- pattern: "jsfuck",
425
- regex: /\[\]\+\[\]/g,
426
- replacement: "\"\""
427
- },
428
- {
429
- pattern: "jsfuck",
430
- regex: /\+\[\]/g,
431
- replacement: "0"
432
- }
433
- ];
434
- const BOOLEAN_LITERAL_RULES = [
435
- {
436
- pattern: "boolean-literal",
437
- regex: /!!\[\]/g,
438
- replacement: "true"
439
- },
440
- {
441
- pattern: "boolean-literal",
442
- regex: /!\[\]/g,
443
- replacement: "false"
444
- },
445
- {
446
- pattern: "undefined-literal",
447
- regex: /void\s+0/g,
448
- replacement: "undefined"
449
- }
450
- ];
451
- const OPAQUE_TRUTHY_RULE = {
452
- pattern: "opaque-truthy",
453
- regex: /!0x0\b|!\b0(?![.\d])/g,
454
- replacement: "true"
455
- };
456
- const TYPE_COERCION_RULES = [
457
- {
458
- pattern: "type-coercion",
459
- regex: /typeof\s+undefined\s*===?\s*["']undefined["']/g,
460
- replacement: "true"
461
- },
462
- {
463
- pattern: "type-coercion",
464
- regex: /typeof\s+null\s*===?\s*["']object["']/g,
465
- replacement: "true"
466
- },
467
- {
468
- pattern: "type-coercion",
469
- regex: /typeof\s+NaN\s*===?\s*["']number["']/g,
470
- replacement: "true"
471
- },
472
- {
473
- pattern: "type-coercion",
474
- regex: /null\s*==\s*undefined/g,
475
- replacement: "true"
476
- },
477
- {
478
- pattern: "type-coercion",
479
- regex: /null\s*===\s*undefined/g,
480
- replacement: "false"
481
- },
482
- {
483
- pattern: "type-coercion",
484
- regex: /NaN\s*===?\s*NaN/g,
485
- replacement: "false"
486
- }
487
- ];
488
- const CONSTANT_COMPARISON_PATTERN = /if\s*\(\s*(-?\d+(?:\.\d+)?)\s*([<>!=]+)\s*(-?\d+(?:\.\d+)?)\s*\)/g;
489
- const OPAQUE_FALSY_PATTERN = /!\s*(-?\d+(?:\.\d+)?)(?![.\d\s\w])/g;
490
- const STRING_ARRAY_DECLARATION_PATTERN = /(?:var|let|const)\s+(\w+)\s*=\s*\[(['"][^'"]*['"]\s*(?:,\s*['"][^'"]*['"]\s*)*)\]/g;
491
- function recordSolve(state, pattern, original, result) {
492
- state.solved.push({
493
- pattern,
494
- original,
495
- result
496
- });
497
- return result;
498
- }
499
- function applyStaticRules(state, rules) {
500
- for (const rule of rules) state.output = replaceOutsideProtectedRanges(state.output, rule.regex, (fullMatch) => recordSolve(state, rule.pattern, fullMatch, rule.replacement));
501
- }
502
- function applyConstantComparisons(state) {
503
- state.output = replaceOutsideProtectedRanges(state.output, CONSTANT_COMPARISON_PATTERN, (fullMatch, leftRaw, operator, rightRaw) => {
504
- if (state.iterations >= state.maxIterations) return fullMatch;
505
- const compare = NUMERIC_COMPARATORS[operator];
506
- if (!compare) return fullMatch;
507
- state.iterations += 1;
508
- const result = compare(Number(leftRaw), Number(rightRaw));
509
- recordSolve(state, "constant-comparison", fullMatch, String(result));
510
- return state.replaceInPlace ? `/* ${fullMatch} => ${result} */ if (${result})` : `if (${result})`;
511
- });
512
- }
513
- function applyOpaqueFalsyRules(state) {
514
- state.output = replaceOutsideProtectedRanges(state.output, OPAQUE_FALSY_PATTERN, (fullMatch, numericRaw) => {
515
- const numericValue = Number(numericRaw);
516
- if (numericValue === 0 || !Number.isFinite(numericValue)) return fullMatch;
517
- return recordSolve(state, "opaque-falsy", fullMatch, "false");
518
- });
519
- }
520
- function escapeRegExp(value) {
521
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
522
- }
523
- function collectStringArrays(output) {
524
- const stringArrays = /* @__PURE__ */ new Map();
525
- replaceOutsideProtectedRanges(output, STRING_ARRAY_DECLARATION_PATTERN, (fullMatch, name, arrayContent) => {
526
- const items = arrayContent.split(/,\s*/).map((item) => item.replace(/^['"]|['"]$/g, ""));
527
- stringArrays.set(name, items);
528
- return fullMatch;
529
- });
530
- return stringArrays;
531
- }
532
- function applyStringArrayAccesses(state) {
533
- const stringArrays = collectStringArrays(state.output);
534
- if (stringArrays.size === 0) return;
535
- for (const [name, items] of stringArrays) {
536
- const accessPattern = new RegExp(`${escapeRegExp(name)}\\(['"]?(0x[0-9a-fA-F]+|\\d+)['"]?\\)`, "g");
537
- state.output = replaceOutsideProtectedRanges(state.output, accessPattern, (fullMatch, rawIndex) => {
538
- if (state.iterations >= state.maxIterations) return fullMatch;
539
- const index = rawIndex.startsWith("0x") ? Number.parseInt(rawIndex, 16) : Number(rawIndex);
540
- if (index < 0 || index >= items.length) return fullMatch;
541
- state.iterations += 1;
542
- return recordSolve(state, "string-array-access", fullMatch, JSON.stringify(items[index]));
543
- });
544
- }
545
- }
546
- function solveConstraints(options) {
547
- const state = {
548
- output: options.code,
549
- solved: [],
550
- replaceInPlace: options.replaceInPlace,
551
- maxIterations: options.maxIterations,
552
- iterations: 0
553
- };
554
- applyConstantComparisons(state);
555
- applyStaticRules(state, JS_FUCK_RULES);
556
- applyStaticRules(state, BOOLEAN_LITERAL_RULES);
557
- applyStaticRules(state, [OPAQUE_TRUTHY_RULE]);
558
- applyOpaqueFalsyRules(state);
559
- applyStringArrayAccesses(state);
560
- applyStaticRules(state, TYPE_COERCION_RULES);
561
- return {
562
- success: true,
563
- solvedCount: state.solved.length,
564
- solved: state.solved,
565
- transformedCode: options.replaceInPlace ? state.output : void 0
566
- };
567
- }
568
- //#endregion
569
- //#region src/server/domains/analysis/handlers/vm-analysis.ts
570
- const VM_DISPATCH_PATTERNS = [
571
- {
572
- type: "for-switch",
573
- test: /for.*switch/s
574
- },
575
- {
576
- type: "while-switch",
577
- test: /while.*switch/s
578
- },
579
- {
580
- type: "if-else-chain",
581
- test: /if\s*\(\s*\w+\s*===?\s*\w+/
582
- }
583
- ];
584
- function detectVmDispatchType(code) {
585
- for (const pattern of VM_DISPATCH_PATTERNS) if (pattern.test.test(code)) return pattern.type;
586
- return "switch";
587
- }
588
- function buildOpcodeDistribution(instructions) {
589
- const distribution = /* @__PURE__ */ new Map();
590
- for (const instruction of instructions) {
591
- const type = instruction.type || "unknown";
592
- distribution.set(type, (distribution.get(type) || 0) + 1);
593
- }
594
- return Object.fromEntries(distribution);
595
- }
596
- function buildVmAnalysisResponse(options) {
597
- const { code, extractBytecode, mapOpcodes, vmResult } = options;
598
- if (!vmResult.isJSVMP) return {
599
- success: true,
600
- isVM: false,
601
- message: "No VM/JSVMP patterns detected."
602
- };
603
- const analysis = {
604
- isVM: true,
605
- vmType: vmResult.vmType,
606
- dispatchType: detectVmDispatchType(code),
607
- complexity: vmResult.vmFeatures?.complexity,
608
- instructionCount: vmResult.vmFeatures?.instructionCount,
609
- interpreterLocation: vmResult.vmFeatures?.interpreterLocation
610
- };
611
- if (extractBytecode && vmResult.instructions) analysis.bytecode = vmResult.instructions;
612
- if (mapOpcodes && vmResult.instructions) {
613
- analysis.opcodeDistribution = buildOpcodeDistribution(vmResult.instructions);
614
- analysis.suggestedStrategy = vmResult.vmFeatures?.complexity === "high" ? "Use symbolic execution (js_deobfuscate_jsvmp with aggressive=true) for high-complexity VMs" : "Use standard deobfuscation pipeline (js_deobfuscate_pipeline)";
615
- }
616
- return {
617
- success: true,
618
- analysis
619
- };
620
- }
621
- //#endregion
622
- //#region src/server/domains/analysis/handlers.web-tools.ts
623
- const MAX_WEBPACK_MODULES = 100;
624
- async function runWebpackEnumerate(collector, args) {
625
- const searchKeyword = argString(args, "searchKeyword", "");
626
- const forceRequireAll = argBool(args, "forceRequireAll", !!searchKeyword);
627
- const maxResults = Math.min(argNumber(args, "maxResults", 20), MAX_WEBPACK_MODULES);
628
- try {
629
- const result = await evaluateWithTimeout(await collector.getActivePage(), async (opts) => {
630
- const w = window;
631
- let requireFn = null;
632
- if (typeof w["__webpack_require__"] === "function") requireFn = w["__webpack_require__"];
633
- const chunkKeys = Object.keys(w).filter((k) => k.startsWith("webpackChunk") || k.startsWith("webpackJsonp"));
634
- const moduleIdSet = /* @__PURE__ */ new Set();
635
- for (const key of chunkKeys) {
636
- const arr = w[key];
637
- if (!Array.isArray(arr)) continue;
638
- const arrWithM = arr;
639
- if (arrWithM.m && typeof arrWithM.m === "object") for (const id of Object.keys(arrWithM.m)) moduleIdSet.add(id);
640
- for (const chunk of arr) if (Array.isArray(chunk) && chunk[1] && typeof chunk[1] === "object") for (const id of Object.keys(chunk[1])) moduleIdSet.add(id);
641
- }
642
- if (typeof w["__webpack_modules__"] === "object" && w["__webpack_modules__"]) for (const id of Object.keys(w["__webpack_modules__"])) moduleIdSet.add(id);
643
- if (!requireFn) for (const key of chunkKeys) {
644
- const arr = w[key];
645
- if (arr?.m && typeof arr.m === "object") {
646
- const mods = arr.m;
647
- requireFn = (id) => {
648
- try {
649
- const fn = mods[id];
650
- return typeof fn === "function" ? fn() : fn;
651
- } catch {
652
- return;
653
- }
654
- };
655
- break;
656
- }
657
- }
658
- const allIds = Array.from(moduleIdSet);
659
- if (!opts.forceRequireAll || !requireFn) return {
660
- total: allIds.length,
661
- requireFound: !!requireFn,
662
- chunkKeys,
663
- moduleIds: allIds.slice(0, 200),
664
- matches: []
665
- };
666
- const fn = requireFn;
667
- const matches = [];
668
- for (const id of allIds) {
669
- if (matches.length >= opts.maxResults) break;
670
- try {
671
- const mod = fn(id);
672
- if (mod === void 0 || mod === null) continue;
673
- let str;
674
- try {
675
- str = JSON.stringify(mod);
676
- } catch {
677
- str = String(mod);
678
- }
679
- if (!opts.searchKeyword || str.toLowerCase().includes(opts.searchKeyword.toLowerCase())) matches.push({
680
- id,
681
- preview: str.slice(0, 600)
682
- });
683
- } catch {}
684
- }
685
- return {
686
- total: allIds.length,
687
- requireFound: true,
688
- chunkKeys,
689
- moduleIds: allIds.slice(0, 200),
690
- matches
691
- };
692
- }, {
693
- searchKeyword,
694
- forceRequireAll,
695
- maxResults
696
- });
697
- logger.info(`webpack_enumerate: found ${result.total} modules, ${result.matches.length} matches`);
698
- return asJsonResponse(result);
699
- } catch (error) {
700
- return asErrorResponse(error);
701
- }
702
- }
703
- //#endregion
704
- //#region src/server/domains/analysis/handlers.impl.ts
705
- const SMART_MODES = new Set([
706
- "summary",
707
- "priority",
708
- "incremental",
709
- "full"
710
- ]);
711
- const FOCUS_MODES = new Set([
712
- "structure",
713
- "business",
714
- "security",
715
- "all"
716
- ]);
717
- const HOOK_TYPES = new Set([
718
- "function",
719
- "xhr",
720
- "fetch",
721
- "websocket",
722
- "localstorage",
723
- "cookie"
724
- ]);
725
- const HOOK_ACTIONS = new Set([
726
- "log",
727
- "block",
728
- "modify"
729
- ]);
730
- var CoreAnalysisHandlers = class {
731
- collector;
732
- scriptManager;
733
- deobfuscator;
734
- advancedDeobfuscator;
735
- obfuscationDetector;
736
- analyzer;
737
- cryptoDetector;
738
- hookManager;
739
- jsvmpDeobfuscator;
740
- constructor(deps) {
741
- this.collector = deps.collector;
742
- this.scriptManager = deps.scriptManager;
743
- this.deobfuscator = deps.deobfuscator;
744
- this.advancedDeobfuscator = deps.advancedDeobfuscator;
745
- this.obfuscationDetector = deps.obfuscationDetector;
746
- this.analyzer = deps.analyzer;
747
- this.cryptoDetector = deps.cryptoDetector;
748
- this.hookManager = deps.hookManager;
749
- this.jsvmpDeobfuscator = new JSVMPDeobfuscator();
750
- }
751
- requireCodeArg(args, toolName) {
752
- const code = args.code;
753
- if (typeof code !== "string" || code.trim().length === 0) {
754
- logger.warn(`${toolName} called without valid code argument`);
755
- return null;
756
- }
757
- return code;
758
- }
759
- extractWebcrackArgs(args) {
760
- const extracted = {};
761
- const unpack = argBool(args, "unpack");
762
- const unminify = argBool(args, "unminify");
763
- const jsx = argBool(args, "jsx");
764
- const mangle = argBool(args, "mangle");
765
- const forceOutput = argBool(args, "forceOutput");
766
- const includeModuleCode = argBool(args, "includeModuleCode");
767
- const outputDir = argString(args, "outputDir");
768
- const maxBundleModules = argNumber(args, "maxBundleModules");
769
- if (unpack !== void 0) extracted.unpack = unpack;
770
- if (unminify !== void 0) extracted.unminify = unminify;
771
- if (jsx !== void 0) extracted.jsx = jsx;
772
- if (mangle !== void 0) extracted.mangle = mangle;
773
- if (forceOutput !== void 0) extracted.forceOutput = forceOutput;
774
- if (includeModuleCode !== void 0) extracted.includeModuleCode = includeModuleCode;
775
- if (outputDir?.trim()) extracted.outputDir = outputDir;
776
- if (maxBundleModules !== void 0) extracted.maxBundleModules = maxBundleModules;
777
- if (Array.isArray(args.mappings)) extracted.mappings = args.mappings.filter((item) => typeof item === "object" && item !== null && typeof item.path === "string" && typeof item.pattern === "string");
778
- return extracted;
779
- }
780
- async handleCollectCode(args) {
781
- const returnSummaryOnly = argBool(args, "returnSummaryOnly", false);
782
- let smartMode = argEnum(args, "smartMode", SMART_MODES);
783
- const maxSummaryFiles = ANALYSIS_MAX_SUMMARY_FILES;
784
- const summarizeFiles = (files) => files.slice(0, maxSummaryFiles).map((file) => ({
785
- url: file.url,
786
- type: file.type,
787
- size: file.size,
788
- sizeKB: (file.size / 1024).toFixed(2),
789
- truncated: file.metadata?.truncated || false,
790
- preview: `${file.content.substring(0, 200)}...`
791
- }));
792
- const summarizeResult = (result) => {
793
- const entries = (Array.isArray(result.summaries) && result.summaries.length > 0 ? result.summaries : summarizeFiles(result.files)).slice(0, maxSummaryFiles);
794
- const filesCount = Array.isArray(result.summaries) ? result.summaries.length : result.files.length;
795
- const totalSize = result.totalSize > 0 ? result.totalSize : Array.isArray(result.summaries) ? result.summaries.reduce((sum, entry) => sum + (typeof entry.size === "number" ? entry.size : 0), 0) : result.files.reduce((sum, file) => sum + file.size, 0);
796
- return {
797
- totalSize,
798
- totalSizeKB: (totalSize / 1024).toFixed(2),
799
- filesCount,
800
- summarizedFiles: entries.length,
801
- omittedFiles: Math.max(0, filesCount - entries.length),
802
- collectTime: result.collectTime,
803
- summary: entries
804
- };
805
- };
806
- if (!smartMode) smartMode = returnSummaryOnly ? "summary" : "summary";
807
- const result = await this.collector.collect({
808
- url: argStringRequired(args, "url"),
809
- includeInline: argBool(args, "includeInline"),
810
- includeExternal: argBool(args, "includeExternal"),
811
- includeDynamic: argBool(args, "includeDynamic"),
812
- smartMode,
813
- compress: argBool(args, "compress"),
814
- maxTotalSize: argNumber(args, "maxTotalSize"),
815
- maxFileSize: args.maxFileSize ? argNumber(args, "maxFileSize", 0) * 1024 : void 0,
816
- priorities: args.priorities
817
- });
818
- if (returnSummaryOnly) return asJsonResponse({
819
- mode: "summary",
820
- ...summarizeResult(result),
821
- hint: "Use get_script_source for specific files."
822
- });
823
- const maxSafeCollectedSize = ANALYSIS_MAX_SAFE_COLLECTED_BYTES;
824
- const maxSafeResponseSize = ANALYSIS_MAX_SAFE_RESPONSE_BYTES;
825
- const estimatedResponseSize = Buffer.byteLength(JSON.stringify(result), "utf8");
826
- if (result.totalSize > maxSafeCollectedSize || estimatedResponseSize > maxSafeResponseSize) {
827
- logger.warn(`Collected code is too large (collected=${(result.totalSize / 1024).toFixed(2)}KB, response=${(estimatedResponseSize / 1024).toFixed(2)}KB), returning summary mode.`);
828
- return asJsonResponse({
829
- warning: "Code size exceeds safe response threshold; summary returned.",
830
- ...summarizeResult(result),
831
- estimatedResponseSize,
832
- estimatedResponseSizeKB: (estimatedResponseSize / 1024).toFixed(2),
833
- recommendations: [
834
- "Use get_script_source for targeted files.",
835
- "Use more specific priority filters.",
836
- "Use smartMode=summary for initial reconnaissance."
837
- ]
838
- });
839
- }
840
- return asJsonResponse(result);
841
- }
842
- async handleSearchInScripts(args) {
843
- await this.scriptManager.init();
844
- const keyword = argString(args, "keyword");
845
- if (!keyword) return asJsonResponse({
846
- success: false,
847
- error: "keyword is required"
848
- });
849
- const maxMatches = argNumber(args, "maxMatches", 100);
850
- const returnSummary = argBool(args, "returnSummary", false);
851
- const maxContextSize = argNumber(args, "maxContextSize", 5e4);
852
- const result = await this.scriptManager.searchInScripts(keyword, {
853
- isRegex: argBool(args, "isRegex"),
854
- caseSensitive: argBool(args, "caseSensitive"),
855
- contextLines: argNumber(args, "contextLines"),
856
- maxMatches
857
- });
858
- const resultSize = JSON.stringify(result).length;
859
- if (returnSummary || resultSize > maxContextSize) {
860
- const matches = result.matches ?? [];
861
- return asJsonResponse({
862
- success: true,
863
- keyword: args.keyword,
864
- totalMatches: matches.length,
865
- resultSize,
866
- resultSizeKB: (resultSize / 1024).toFixed(2),
867
- truncated: resultSize > maxContextSize,
868
- reason: resultSize > maxContextSize ? `Result too large (${(resultSize / 1024).toFixed(2)}KB > ${(maxContextSize / 1024).toFixed(2)}KB)` : "Summary mode enabled",
869
- matchesSummary: matches.slice(0, 10).map((match) => ({
870
- scriptId: match.scriptId,
871
- url: match.url,
872
- line: match.line,
873
- preview: `${(match.context ?? "").substring(0, 100)}...`
874
- })),
875
- recommendations: [
876
- "Use more specific keywords.",
877
- `Reduce maxMatches (current: ${maxMatches}).`,
878
- "Use get_script_source for targeted file retrieval."
879
- ]
880
- });
881
- }
882
- return asJsonResponse(result);
883
- }
884
- async handleExtractFunctionTree(args) {
885
- const scriptId = argString(args, "scriptId");
886
- const functionName = argString(args, "functionName");
887
- if (!scriptId) return asJsonResponse({
888
- success: false,
889
- error: "scriptId is required",
890
- hint: "Use get_all_scripts() to list available scripts and their scriptIds"
891
- });
892
- if (!functionName) return asJsonResponse({
893
- success: false,
894
- error: "functionName is required",
895
- hint: "Specify the name of the function to extract"
896
- });
897
- await this.scriptManager.init();
898
- const scripts = await this.scriptManager.getAllScripts();
899
- if (!scripts.some((s) => String(s.scriptId) === String(scriptId))) {
900
- const availableScripts = scripts.slice(0, 10).map((s) => ({
901
- scriptId: s.scriptId,
902
- url: s.url?.substring(0, 80)
903
- }));
904
- return asJsonResponse({
905
- success: false,
906
- error: `Script not found: ${scriptId}`,
907
- hint: "The specified scriptId does not exist. Use get_all_scripts() to list available scripts.",
908
- availableScripts: availableScripts.length > 0 ? availableScripts : "No scripts loaded. Navigate to a page first.",
909
- totalScripts: scripts.length
910
- });
911
- }
912
- try {
913
- return asJsonResponse({
914
- success: true,
915
- ...await this.scriptManager.extractFunctionTree(scriptId, functionName, {
916
- maxDepth: argNumber(args, "maxDepth"),
917
- maxSize: argNumber(args, "maxSize"),
918
- includeComments: argBool(args, "includeComments")
919
- })
920
- });
921
- } catch (error) {
922
- return asJsonResponse({
923
- success: false,
924
- error: error instanceof Error ? error.message : String(error),
925
- hint: "Make sure the function name exists in the specified script"
926
- });
927
- }
928
- }
929
- async handleDeobfuscate(args) {
930
- const code = this.requireCodeArg(args, "deobfuscate");
931
- if (!code) return asJsonResponse({
932
- success: false,
933
- error: "code is required and must be a non-empty string"
934
- });
935
- if (argEnum(args, "engine", new Set(["auto", "webcrack"]), "auto") === "webcrack") return asJsonResponse(await this.advancedDeobfuscator.deobfuscate({
936
- code,
937
- ...this.extractWebcrackArgs(args),
938
- ...typeof args.detectOnly === "boolean" ? { detectOnly: args.detectOnly } : {},
939
- ...typeof args.aggressiveVM === "boolean" ? { aggressiveVM: args.aggressiveVM } : {},
940
- ...typeof args.useASTOptimization === "boolean" ? { useASTOptimization: args.useASTOptimization } : {},
941
- ...typeof args.timeout === "number" ? { timeout: args.timeout } : {}
942
- }));
943
- const result = await this.deobfuscator.deobfuscate({
944
- code,
945
- aggressive: argBool(args, "aggressive"),
946
- ...this.extractWebcrackArgs(args)
947
- });
948
- if (result && typeof result === "object" && "success" in result && result.success === false && !("error" in result)) return asJsonResponse({
949
- ...result,
950
- error: result.reason || "deobfuscation failed"
951
- });
952
- return asJsonResponse(result);
953
- }
954
- async handleUnderstandCode(args) {
955
- const code = this.requireCodeArg(args, "understand_code");
956
- if (!code) return asJsonResponse({
957
- success: false,
958
- error: "code is required and must be a non-empty string"
959
- });
960
- return asJsonResponse(await this.analyzer.understand({
961
- code,
962
- context: argObject(args, "context"),
963
- focus: argEnum(args, "focus", FOCUS_MODES, "all")
964
- }));
965
- }
966
- async handleDetectCrypto(args) {
967
- const code = this.requireCodeArg(args, "detect_crypto");
968
- if (!code) return asJsonResponse({
969
- success: false,
970
- error: "code is required and must be a non-empty string"
971
- });
972
- return asJsonResponse(await this.cryptoDetector.detect({ code }));
973
- }
974
- async handleManageHooks(args) {
975
- const action = argStringRequired(args, "action");
976
- switch (action) {
977
- case "create": return asJsonResponse(await this.hookManager.createHook({
978
- target: argStringRequired(args, "target"),
979
- type: argEnum(args, "type", HOOK_TYPES) ?? "function",
980
- action: argEnum(args, "hookAction", HOOK_ACTIONS, "log"),
981
- customCode: argString(args, "customCode")
982
- }));
983
- case "list": return asJsonResponse({ hooks: this.hookManager.getAllHooks() });
984
- case "records": return asJsonResponse({ records: this.hookManager.getHookRecords(argStringRequired(args, "hookId")) });
985
- case "clear":
986
- this.hookManager.clearHookRecords(argString(args, "hookId"));
987
- return asJsonResponse({
988
- success: true,
989
- message: "Hook records cleared"
990
- });
991
- default: return asJsonResponse({
992
- success: false,
993
- message: `Unknown hook action: ${action}. Valid actions: create, list, records, clear`
994
- });
995
- }
996
- }
997
- async handleDetectObfuscation(args) {
998
- const code = this.requireCodeArg(args, "detect_obfuscation");
999
- if (!code) return asJsonResponse({
1000
- success: false,
1001
- error: "code is required and must be a non-empty string"
1002
- });
1003
- const generateReport = argBool(args, "generateReport", true);
1004
- const result = this.obfuscationDetector.detect(code);
1005
- if (!generateReport) return asJsonResponse(result);
1006
- const report = this.obfuscationDetector.generateReport(result);
1007
- return asTextResponse(`${JSON.stringify(result, null, 2)}\n\n${report}`);
1008
- }
1009
- async handleWebcrackUnpack(args) {
1010
- const code = this.requireCodeArg(args, "webcrack_unpack");
1011
- if (!code) return asJsonResponse({
1012
- success: false,
1013
- error: "code is required and must be a non-empty string"
1014
- });
1015
- const result = await runWebcrack(code, {
1016
- unpack: argBool(args, "unpack", true),
1017
- unminify: argBool(args, "unminify", true),
1018
- jsx: argBool(args, "jsx", true),
1019
- mangle: argBool(args, "mangle", false),
1020
- ...this.extractWebcrackArgs(args)
1021
- });
1022
- if (!result.applied) return asJsonResponse({
1023
- success: false,
1024
- error: result.reason || "webcrack execution failed",
1025
- optionsUsed: result.optionsUsed,
1026
- engine: "webcrack"
1027
- });
1028
- return asJsonResponse({
1029
- success: true,
1030
- code: result.code,
1031
- bundle: result.bundle,
1032
- savedTo: result.savedTo,
1033
- savedArtifacts: result.savedArtifacts,
1034
- optionsUsed: result.optionsUsed,
1035
- engine: "webcrack"
1036
- });
1037
- }
1038
- async handleWebpackEnumerate(args) {
1039
- return runWebpackEnumerate(this.collector, args);
1040
- }
1041
- async handleClearCollectedData() {
1042
- try {
1043
- await this.collector.clearAllData();
1044
- this.scriptManager.clear();
1045
- return asJsonResponse({
1046
- success: true,
1047
- message: "All collected data cleared.",
1048
- cleared: {
1049
- fileCache: true,
1050
- compressionCache: true,
1051
- collectedUrls: true,
1052
- scriptManager: true
1053
- }
1054
- });
1055
- } catch (error) {
1056
- logger.error("Failed to clear collected data:", error);
1057
- return asJsonResponse(serializeError(error));
1058
- }
1059
- }
1060
- async handleGetCollectionStats() {
1061
- try {
1062
- const stats = await this.collector.getAllStats();
1063
- return asJsonResponse({
1064
- success: true,
1065
- stats,
1066
- summary: {
1067
- totalCachedFiles: stats.cache.memoryEntries + stats.cache.diskEntries,
1068
- totalCacheSize: `${(stats.cache.totalSize / 1024).toFixed(2)} KB`,
1069
- compressionRatio: `${stats.compression.averageRatio.toFixed(1)}%`,
1070
- cacheHitRate: stats.compression.cacheHits > 0 ? `${(stats.compression.cacheHits / (stats.compression.cacheHits + stats.compression.cacheMisses) * 100).toFixed(1)}%` : "0%",
1071
- collectedUrls: stats.collector.collectedUrls
1072
- }
1073
- });
1074
- } catch (error) {
1075
- logger.error("Failed to get collection stats:", error);
1076
- return asJsonResponse(serializeError(error));
1077
- }
1078
- }
1079
- async handleJsDeobfuscateJsvmp(args) {
1080
- const code = this.requireCodeArg(args, "js_deobfuscate_jsvmp");
1081
- if (!code) return asJsonResponse({
1082
- success: false,
1083
- error: "code is required and must be a non-empty string"
1084
- });
1085
- const detectOnly = argBool(args, "detectOnly", false);
1086
- const result = await this.jsvmpDeobfuscator.deobfuscate({
1087
- code,
1088
- aggressive: argBool(args, "aggressive", false),
1089
- extractInstructions: argBool(args, "extractInstructions", true),
1090
- timeout: argNumber(args, "timeout", 3e4)
1091
- });
1092
- if (detectOnly) return asJsonResponse({
1093
- success: true,
1094
- isJSVMP: result.isJSVMP,
1095
- vmType: result.vmType,
1096
- vmFeatures: result.vmFeatures,
1097
- confidence: result.confidence,
1098
- instructionCount: result.instructions?.length
1099
- });
1100
- return asJsonResponse({
1101
- success: result.isJSVMP,
1102
- isJSVMP: result.isJSVMP,
1103
- vmType: result.vmType,
1104
- vmFeatures: result.vmFeatures,
1105
- instructions: result.instructions,
1106
- deobfuscatedCode: result.deobfuscatedCode,
1107
- confidence: result.confidence,
1108
- warnings: result.warnings,
1109
- unresolvedParts: result.unresolvedParts,
1110
- stats: result.stats
1111
- });
1112
- }
1113
- async handleJsDeobfuscatePipeline(args) {
1114
- const code = this.requireCodeArg(args, "js_deobfuscate_pipeline");
1115
- if (!code) return asJsonResponse({
1116
- success: false,
1117
- error: "code is required"
1118
- });
1119
- const useWebcrack = argBool(args, "useWebcrack", true);
1120
- const aggressive = argBool(args, "aggressive", false);
1121
- const humanize = argBool(args, "humanize", true);
1122
- const returnStageDetails = argBool(args, "returnStageDetails", false);
1123
- const startTime = Date.now();
1124
- let preprocessed = code;
1125
- const ppTransforms = [];
1126
- const afterFold = applyConstantFold(preprocessed);
1127
- if (afterFold !== preprocessed) {
1128
- preprocessed = afterFold;
1129
- ppTransforms.push("constant_fold");
1130
- }
1131
- const afterDeadCode = applyDeadCodeRemove(preprocessed);
1132
- if (afterDeadCode !== preprocessed) {
1133
- preprocessed = afterDeadCode;
1134
- ppTransforms.push("dead_code_remove");
1135
- }
1136
- let deobfuscated = preprocessed;
1137
- let webcrackApplied = false;
1138
- let webcrackWarning;
1139
- let webcrackError;
1140
- if (useWebcrack) try {
1141
- const result = await runWebcrack(preprocessed, {
1142
- unminify: true,
1143
- unpack: true
1144
- });
1145
- if (result.applied) {
1146
- deobfuscated = result.code;
1147
- webcrackApplied = true;
1148
- } else webcrackWarning = result.reason ? `webcrack stage did not apply: ${result.reason}` : "webcrack stage did not apply any transformation.";
1149
- } catch (error) {
1150
- webcrackError = error instanceof Error ? error.message : String(error);
1151
- }
1152
- if (aggressive) {
1153
- const afterCFF = applyControlFlowFlatten(deobfuscated);
1154
- if (afterCFF !== deobfuscated) deobfuscated = afterCFF;
1155
- }
1156
- let humanized = deobfuscated;
1157
- let renameCount = 0;
1158
- if (humanize) {
1159
- const result = applyRenameVars(humanized);
1160
- if (result.code !== humanized) {
1161
- humanized = result.code;
1162
- renameCount = result.count;
1163
- }
1164
- }
1165
- const totalMs = Date.now() - startTime;
1166
- const reductionRate = code.length > 0 ? 1 - humanized.length / code.length : 0;
1167
- const response = {
1168
- success: !webcrackWarning && !webcrackError,
1169
- deobfuscatedCode: humanized,
1170
- ...webcrackWarning ? { warning: webcrackWarning } : {},
1171
- ...webcrackError ? { error: `webcrack stage failed: ${webcrackError}` } : {},
1172
- stats: {
1173
- originalSize: code.length,
1174
- finalSize: humanized.length,
1175
- reductionRate: Math.round(reductionRate * 1e3) / 10,
1176
- processingTimeMs: totalMs,
1177
- stages: {
1178
- preprocessor: {
1179
- transforms: ppTransforms,
1180
- sizeAfter: preprocessed.length
1181
- },
1182
- deobfuscator: {
1183
- webcrackApplied,
1184
- sizeAfter: deobfuscated.length,
1185
- ...webcrackWarning ? { warning: webcrackWarning } : {},
1186
- ...webcrackError ? { error: webcrackError } : {}
1187
- },
1188
- humanizer: {
1189
- renameCount,
1190
- sizeAfter: humanized.length
1191
- }
1192
- }
1193
- }
1194
- };
1195
- if (returnStageDetails) response.stageDetails = {
1196
- preprocessed: preprocessed.substring(0, 5e3),
1197
- deobfuscated: deobfuscated.substring(0, 5e3)
1198
- };
1199
- return asJsonResponse(response);
1200
- }
1201
- async handleJsAnalyzeVm(args) {
1202
- const code = this.requireCodeArg(args, "js_analyze_vm");
1203
- if (!code) return asJsonResponse({
1204
- success: false,
1205
- error: "code is required"
1206
- });
1207
- const extractBytecode = argBool(args, "extractBytecode", true);
1208
- return asJsonResponse(buildVmAnalysisResponse({
1209
- code,
1210
- extractBytecode,
1211
- mapOpcodes: argBool(args, "mapOpcodes", true),
1212
- vmResult: await this.jsvmpDeobfuscator.deobfuscate({
1213
- code,
1214
- aggressive: false,
1215
- extractInstructions: extractBytecode,
1216
- timeout: 15e3
1217
- })
1218
- }));
1219
- }
1220
- async handleJsSolveConstraints(args) {
1221
- const code = this.requireCodeArg(args, "js_solve_constraints");
1222
- if (!code) return asJsonResponse({
1223
- success: false,
1224
- error: "code is required"
1225
- });
1226
- return asJsonResponse(solveConstraints({
1227
- code,
1228
- replaceInPlace: argBool(args, "replaceInPlace", true),
1229
- maxIterations: argNumber(args, "maxIterations", 100)
1230
- }));
1231
- }
1232
- };
1233
- //#endregion
1234
- export { CoreAnalysisHandlers };