@jshookmcp/jshook 0.2.5 → 0.2.6
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 +5 -5
- package/README.zh.md +5 -5
- package/dist/packages/extension-sdk/src/workflow.d.ts +17 -2
- package/dist/packages/extension-sdk/src/workflow.js +36 -0
- package/dist/src/modules/browser/BrowserPool.d.ts +49 -0
- package/dist/src/modules/browser/BrowserPool.js +288 -0
- package/dist/src/modules/deobfuscator/AdvancedDeobfuscator.d.ts +5 -0
- package/dist/src/modules/deobfuscator/AdvancedDeobfuscator.js +43 -2
- package/dist/src/modules/deobfuscator/Deobfuscator.js +5 -0
- package/dist/src/modules/external/ExternalToolRunner.js +1 -1
- package/dist/src/server/MCPServer.context.d.ts +1 -0
- package/dist/src/server/domains/browser/handlers/stealth-injection.d.ts +1 -0
- package/dist/src/server/domains/browser/handlers/stealth-injection.js +3 -0
- package/dist/src/server/domains/shared-state-board/definitions.d.ts +2 -0
- package/dist/src/server/domains/shared-state-board/definitions.js +78 -0
- package/dist/src/server/domains/shared-state-board/handlers.impl.d.ts +58 -0
- package/dist/src/server/domains/shared-state-board/handlers.impl.js +419 -0
- package/dist/src/server/domains/shared-state-board/index.d.ts +2 -0
- package/dist/src/server/domains/shared-state-board/index.js +2 -0
- package/dist/src/server/domains/shared-state-board/manifest.d.ts +57 -0
- package/dist/src/server/domains/shared-state-board/manifest.js +74 -0
- package/dist/src/server/http/SseStream.d.ts +21 -0
- package/dist/src/server/http/SseStream.js +129 -0
- package/dist/src/server/teams/TeamManager.d.ts +43 -0
- package/dist/src/server/teams/TeamManager.js +238 -0
- package/dist/src/server/teams/index.d.ts +1 -0
- package/dist/src/server/teams/index.js +1 -0
- package/dist/src/server/workflows/WorkflowContract.d.ts +20 -4
- package/dist/src/server/workflows/WorkflowContract.js +40 -0
- package/dist/src/server/workflows/WorkflowEngine.js +190 -13
- package/dist/src/types/deobfuscator.d.ts +1 -0
- package/dist/src/utils/cache/CachedDecorator.d.ts +8 -0
- package/dist/src/utils/cache/CachedDecorator.js +55 -0
- package/dist/src/utils/cache/PersistentCache.d.ts +33 -0
- package/dist/src/utils/cache/PersistentCache.js +246 -0
- package/dist/src/utils/cache/index.d.ts +2 -0
- package/dist/src/utils/cache/index.js +2 -0
- package/package.json +11 -12
- package/scripts/postinstall.cjs +54 -27
- package/workflows/anti-bot-diagnoser/.jshook-install.json +14 -0
- package/workflows/anti-bot-diagnoser/LICENSE +21 -0
- package/workflows/anti-bot-diagnoser/README.md +105 -0
- package/workflows/anti-bot-diagnoser/docs/agent-recipes.md +44 -0
- package/workflows/anti-bot-diagnoser/meta.yaml +6 -0
- package/workflows/anti-bot-diagnoser/package.json +22 -0
- package/workflows/anti-bot-diagnoser/tsconfig.json +15 -0
- package/workflows/anti-bot-diagnoser/workflow.ts +224 -0
- package/workflows/api-openapi-probe/.jshook-install.json +14 -0
- package/workflows/api-openapi-probe/meta.yaml +6 -0
- package/workflows/api-openapi-probe/package.json +22 -0
- package/workflows/api-openapi-probe/pnpm-lock.yaml +819 -0
- package/workflows/api-openapi-probe/tsconfig.json +15 -0
- package/workflows/api-openapi-probe/workflow.ts +40 -0
- package/workflows/api-probe-batch/.jshook-install.json +14 -0
- package/workflows/api-probe-batch/LICENSE +21 -0
- package/workflows/api-probe-batch/README.md +45 -0
- package/workflows/api-probe-batch/meta.yaml +4 -0
- package/workflows/api-probe-batch/package.json +23 -0
- package/workflows/api-probe-batch/tsconfig.json +16 -0
- package/workflows/api-probe-batch/workflow.ts +111 -0
- package/workflows/auth-bootstrap/.jshook-install.json +14 -0
- package/workflows/auth-bootstrap/LICENSE +21 -0
- package/workflows/auth-bootstrap/README.md +74 -0
- package/workflows/auth-bootstrap/meta.yaml +4 -0
- package/workflows/auth-bootstrap/package.json +23 -0
- package/workflows/auth-bootstrap/tsconfig.json +16 -0
- package/workflows/auth-bootstrap/workflow.ts +141 -0
- package/workflows/auth-extract/.jshook-install.json +14 -0
- package/workflows/auth-extract/meta.yaml +6 -0
- package/workflows/auth-extract/package.json +22 -0
- package/workflows/auth-extract/pnpm-lock.yaml +819 -0
- package/workflows/auth-extract/tsconfig.json +15 -0
- package/workflows/auth-extract/workflow.ts +36 -0
- package/workflows/auth-surface-mapper/.jshook-install.json +14 -0
- package/workflows/auth-surface-mapper/meta.yaml +6 -0
- package/workflows/auth-surface-mapper/package.json +22 -0
- package/workflows/auth-surface-mapper/pnpm-lock.yaml +819 -0
- package/workflows/auth-surface-mapper/tsconfig.json +15 -0
- package/workflows/auth-surface-mapper/workflow.ts +104 -0
- package/workflows/batch-register/.jshook-install.json +14 -0
- package/workflows/batch-register/LICENSE +21 -0
- package/workflows/batch-register/README.md +39 -0
- package/workflows/batch-register/meta.yaml +4 -0
- package/workflows/batch-register/package.json +23 -0
- package/workflows/batch-register/tsconfig.json +16 -0
- package/workflows/batch-register/workflow.ts +67 -0
- package/workflows/bundle-recovery/.jshook-install.json +14 -0
- package/workflows/bundle-recovery/LICENSE +21 -0
- package/workflows/bundle-recovery/README.md +105 -0
- package/workflows/bundle-recovery/docs/agent-recipes.md +44 -0
- package/workflows/bundle-recovery/meta.yaml +6 -0
- package/workflows/bundle-recovery/package.json +22 -0
- package/workflows/bundle-recovery/tsconfig.json +15 -0
- package/workflows/bundle-recovery/workflow.ts +179 -0
- package/workflows/challenge-detector/.jshook-install.json +14 -0
- package/workflows/challenge-detector/meta.yaml +14 -0
- package/workflows/challenge-detector/package.json +22 -0
- package/workflows/challenge-detector/pnpm-lock.yaml +819 -0
- package/workflows/challenge-detector/tsconfig.json +15 -0
- package/workflows/challenge-detector/workflow.ts +298 -0
- package/workflows/deobfuscation-pipeline/.jshook-install.json +14 -0
- package/workflows/deobfuscation-pipeline/meta.yaml +6 -0
- package/workflows/deobfuscation-pipeline/package.json +22 -0
- package/workflows/deobfuscation-pipeline/pnpm-lock.yaml +819 -0
- package/workflows/deobfuscation-pipeline/tsconfig.json +15 -0
- package/workflows/deobfuscation-pipeline/workflow.ts +119 -0
- package/workflows/electron-bridge-mapper/.jshook-install.json +14 -0
- package/workflows/electron-bridge-mapper/meta.yaml +6 -0
- package/workflows/electron-bridge-mapper/package.json +22 -0
- package/workflows/electron-bridge-mapper/pnpm-lock.yaml +819 -0
- package/workflows/electron-bridge-mapper/tsconfig.json +15 -0
- package/workflows/electron-bridge-mapper/workflow.ts +125 -0
- package/workflows/evidence-pack/.jshook-install.json +14 -0
- package/workflows/evidence-pack/LICENSE +21 -0
- package/workflows/evidence-pack/README.md +105 -0
- package/workflows/evidence-pack/docs/agent-recipes.md +44 -0
- package/workflows/evidence-pack/meta.yaml +6 -0
- package/workflows/evidence-pack/package.json +22 -0
- package/workflows/evidence-pack/tsconfig.json +15 -0
- package/workflows/evidence-pack/workflow.ts +154 -0
- package/workflows/js-bundle-search/.jshook-install.json +14 -0
- package/workflows/js-bundle-search/LICENSE +21 -0
- package/workflows/js-bundle-search/README.md +46 -0
- package/workflows/js-bundle-search/meta.yaml +4 -0
- package/workflows/js-bundle-search/package.json +23 -0
- package/workflows/js-bundle-search/tsconfig.json +16 -0
- package/workflows/js-bundle-search/workflow.ts +118 -0
- package/workflows/protocol-registry/.jshook-install.json +14 -0
- package/workflows/protocol-registry/meta.yaml +6 -0
- package/workflows/protocol-registry/package.json +22 -0
- package/workflows/protocol-registry/pnpm-lock.yaml +819 -0
- package/workflows/protocol-registry/tsconfig.json +15 -0
- package/workflows/protocol-registry/workflow.ts +107 -0
- package/workflows/qwen-mail-open-latest/meta.yaml +7 -0
- package/workflows/qwen-mail-open-latest/package.json +22 -0
- package/workflows/qwen-mail-open-latest/pnpm-lock.yaml +819 -0
- package/workflows/qwen-mail-open-latest/tsconfig.json +15 -0
- package/workflows/qwen-mail-open-latest/workflow.ts +77 -0
- package/workflows/register-account-flow/.jshook-install.json +14 -0
- package/workflows/register-account-flow/LICENSE +21 -0
- package/workflows/register-account-flow/README.md +64 -0
- package/workflows/register-account-flow/meta.yaml +4 -0
- package/workflows/register-account-flow/package.json +23 -0
- package/workflows/register-account-flow/tsconfig.json +16 -0
- package/workflows/register-account-flow/workflow.ts +127 -0
- package/workflows/replay-lab/.jshook-install.json +14 -0
- package/workflows/replay-lab/meta.yaml +6 -0
- package/workflows/replay-lab/package.json +22 -0
- package/workflows/replay-lab/pnpm-lock.yaml +819 -0
- package/workflows/replay-lab/tsconfig.json +15 -0
- package/workflows/replay-lab/workflow.ts +106 -0
- package/workflows/script-evidence-scan/.jshook-install.json +14 -0
- package/workflows/script-evidence-scan/LICENSE +21 -0
- package/workflows/script-evidence-scan/README.md +61 -0
- package/workflows/script-evidence-scan/meta.yaml +4 -0
- package/workflows/script-evidence-scan/package.json +23 -0
- package/workflows/script-evidence-scan/tsconfig.json +16 -0
- package/workflows/script-evidence-scan/workflow.ts +89 -0
- package/workflows/signature-hunter/.jshook-install.json +14 -0
- package/workflows/signature-hunter/LICENSE +21 -0
- package/workflows/signature-hunter/README.md +105 -0
- package/workflows/signature-hunter/docs/agent-recipes.md +44 -0
- package/workflows/signature-hunter/meta.yaml +6 -0
- package/workflows/signature-hunter/package.json +22 -0
- package/workflows/signature-hunter/tsconfig.json +15 -0
- package/workflows/signature-hunter/workflow.ts +170 -0
- package/workflows/signing-lineage/.jshook-install.json +14 -0
- package/workflows/signing-lineage/meta.yaml +6 -0
- package/workflows/signing-lineage/package.json +22 -0
- package/workflows/signing-lineage/pnpm-lock.yaml +819 -0
- package/workflows/signing-lineage/tsconfig.json +15 -0
- package/workflows/signing-lineage/workflow.ts +120 -0
- package/workflows/temp-mail-extract-link/.jshook-install.json +14 -0
- package/workflows/temp-mail-extract-link/LICENSE +21 -0
- package/workflows/temp-mail-extract-link/README.md +71 -0
- package/workflows/temp-mail-extract-link/meta.yaml +4 -0
- package/workflows/temp-mail-extract-link/package.json +23 -0
- package/workflows/temp-mail-extract-link/tsconfig.json +16 -0
- package/workflows/temp-mail-extract-link/workflow.ts +221 -0
- package/workflows/temp-mail-open-latest/.jshook-install.json +14 -0
- package/workflows/temp-mail-open-latest/LICENSE +21 -0
- package/workflows/temp-mail-open-latest/README.md +61 -0
- package/workflows/temp-mail-open-latest/meta.yaml +4 -0
- package/workflows/temp-mail-open-latest/package.json +23 -0
- package/workflows/temp-mail-open-latest/tsconfig.json +16 -0
- package/workflows/temp-mail-open-latest/workflow.ts +136 -0
- package/workflows/template/.jshook-install.json +14 -0
- package/workflows/template/LICENSE +21 -0
- package/workflows/template/README.md +45 -0
- package/workflows/template/docs/SKILL.md +111 -0
- package/workflows/template/meta.yaml +6 -0
- package/workflows/template/package.json +22 -0
- package/workflows/template/pnpm-lock.yaml +819 -0
- package/workflows/template/tsconfig.json +15 -0
- package/workflows/template/workflow.ts +73 -0
- package/workflows/web-api-capture-session/.jshook-install.json +14 -0
- package/workflows/web-api-capture-session/LICENSE +21 -0
- package/workflows/web-api-capture-session/README.md +64 -0
- package/workflows/web-api-capture-session/meta.yaml +4 -0
- package/workflows/web-api-capture-session/package.json +23 -0
- package/workflows/web-api-capture-session/tsconfig.json +16 -0
- package/workflows/web-api-capture-session/workflow.ts +124 -0
- package/workflows/ws-protocol-lifter/.jshook-install.json +14 -0
- package/workflows/ws-protocol-lifter/LICENSE +21 -0
- package/workflows/ws-protocol-lifter/README.md +105 -0
- package/workflows/ws-protocol-lifter/docs/agent-recipes.md +44 -0
- package/workflows/ws-protocol-lifter/meta.yaml +6 -0
- package/workflows/ws-protocol-lifter/package.json +22 -0
- package/workflows/ws-protocol-lifter/tsconfig.json +15 -0
- package/workflows/ws-protocol-lifter/workflow.ts +163 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createWorkflow,
|
|
3
|
+
type WorkflowExecutionContext,
|
|
4
|
+
SequenceNodeBuilder,
|
|
5
|
+
} from '@jshookmcp/extension-sdk/workflow';
|
|
6
|
+
|
|
7
|
+
const workflowId = 'workflow.ws-protocol-lifter.v1';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* WebSocket Protocol Lifter — Reverse Mission Workflow
|
|
11
|
+
*
|
|
12
|
+
* Automatically analyses WebSocket traffic on a target page:
|
|
13
|
+
* 1. Enables WS monitoring and navigates to the page
|
|
14
|
+
* 2. Waits for connections to establish
|
|
15
|
+
* 3. Captures and clusters messages by structure/type
|
|
16
|
+
* 4. Attempts auto-decode (JSON, base64, msgpack, protobuf heuristics)
|
|
17
|
+
* 5. Searches scripts for handler functions (onmessage, addEventListener)
|
|
18
|
+
* 6. Links message patterns to handler call sites
|
|
19
|
+
* 7. Records evidence and emits a protocol summary
|
|
20
|
+
*/
|
|
21
|
+
export default createWorkflow(workflowId, 'WebSocket Protocol Lifter')
|
|
22
|
+
.description(
|
|
23
|
+
'Captures WebSocket messages, clusters by structure, auto-decodes payloads (JSON/base64/msgpack/protobuf), locates handlers, and produces a protocol summary with evidence links.',
|
|
24
|
+
)
|
|
25
|
+
.tags([
|
|
26
|
+
'reverse',
|
|
27
|
+
'websocket',
|
|
28
|
+
'protocol',
|
|
29
|
+
'handler',
|
|
30
|
+
'decode',
|
|
31
|
+
'mission',
|
|
32
|
+
])
|
|
33
|
+
.timeoutMs(10 * 60_000)
|
|
34
|
+
.defaultMaxConcurrency(4)
|
|
35
|
+
.buildGraph((ctx: WorkflowExecutionContext) => {
|
|
36
|
+
const prefix = 'workflows.wsProtocolLifter';
|
|
37
|
+
|
|
38
|
+
// ── Config ──────────────────────────────────────────────────────
|
|
39
|
+
const url = String(ctx.getConfig(`${prefix}.url`, 'https://example.com'));
|
|
40
|
+
const waitUntil = String(ctx.getConfig(`${prefix}.waitUntil`, 'networkidle0'));
|
|
41
|
+
const captureDelay = Number(ctx.getConfig(`${prefix}.captureDelayMs`, 5000));
|
|
42
|
+
const maxFrames = Number(ctx.getConfig(`${prefix}.maxFrames`, 200));
|
|
43
|
+
const handlerSearchKeywords = String(
|
|
44
|
+
ctx.getConfig(`${prefix}.handlerKeywords`, 'onmessage,addEventListener,socket,WebSocket'),
|
|
45
|
+
);
|
|
46
|
+
const maxConcurrency = Number(ctx.getConfig(`${prefix}.parallel.maxConcurrency`, 4));
|
|
47
|
+
const decodeAttempts = String(
|
|
48
|
+
ctx.getConfig(`${prefix}.decodeAttempts`, 'json,base64,msgpack,protobuf'),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const root = new SequenceNodeBuilder('ws-protocol-lifter-root');
|
|
52
|
+
|
|
53
|
+
root
|
|
54
|
+
// ── Phase 1: Enable WS Monitoring & Navigate ──────────────────
|
|
55
|
+
.tool('enable-ws-monitor', 'ws_monitor_enable', {
|
|
56
|
+
input: {},
|
|
57
|
+
})
|
|
58
|
+
.tool('enable-network', 'network_enable', {
|
|
59
|
+
input: { enableExceptions: true },
|
|
60
|
+
})
|
|
61
|
+
.tool('navigate', 'page_navigate', {
|
|
62
|
+
input: { url, waitUntil },
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
// ── Phase 2: Wait for WS Activity ─────────────────────────────
|
|
66
|
+
.tool('wait-ws-activity', 'page_wait_for_timeout', {
|
|
67
|
+
input: { timeout: captureDelay },
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// ── Phase 3: Capture Connections & Frames ─────────────────────
|
|
71
|
+
.tool('get-ws-connections', 'ws_get_connections', {
|
|
72
|
+
input: {},
|
|
73
|
+
})
|
|
74
|
+
.tool('get-ws-frames', 'ws_get_frames', {
|
|
75
|
+
input: { limit: maxFrames },
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// ── Phase 4: Parallel Analysis ────────────────────────────────
|
|
79
|
+
.parallel('analyse-ws', (p) => {
|
|
80
|
+
p.maxConcurrency(maxConcurrency)
|
|
81
|
+
.failFast(false)
|
|
82
|
+
// Cluster messages by structure
|
|
83
|
+
.tool('cluster-messages', 'ws_cluster_messages', {
|
|
84
|
+
input: {},
|
|
85
|
+
})
|
|
86
|
+
// Attempt decode
|
|
87
|
+
.tool('decode-payloads', 'ws_decode_payloads', {
|
|
88
|
+
input: { attempts: decodeAttempts },
|
|
89
|
+
})
|
|
90
|
+
// Search for handler functions
|
|
91
|
+
.tool('search-handlers', 'search_in_scripts', {
|
|
92
|
+
input: {
|
|
93
|
+
query: handlerSearchKeywords,
|
|
94
|
+
matchType: 'any',
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
// Get protocol stats
|
|
98
|
+
.tool('get-ws-stats', 'ws_get_stats', {
|
|
99
|
+
input: {},
|
|
100
|
+
});
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
// ── Phase 5: Handler Association ──────────────────────────────
|
|
104
|
+
.tool('locate-handlers', 'extract_function_tree', {
|
|
105
|
+
input: {
|
|
106
|
+
targetParam: 'onmessage',
|
|
107
|
+
depth: 2,
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
// ── Phase 6: Evidence Recording ───────────────────────────────
|
|
112
|
+
.tool('create-evidence-session', 'instrumentation_session_create', {
|
|
113
|
+
input: {
|
|
114
|
+
name: `ws-protocol-${new Date().toISOString().slice(0, 10)}`,
|
|
115
|
+
metadata: { url, workflowId },
|
|
116
|
+
},
|
|
117
|
+
})
|
|
118
|
+
.tool('record-artifact', 'instrumentation_artifact_record', {
|
|
119
|
+
input: {
|
|
120
|
+
type: 'ws_protocol_summary',
|
|
121
|
+
label: `WS protocol analysis for ${url}`,
|
|
122
|
+
metadata: { url, maxFrames, decodeAttempts },
|
|
123
|
+
},
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
// ── Phase 7: Session Insight ──────────────────────────────────
|
|
127
|
+
.tool('emit-insight', 'append_session_insight', {
|
|
128
|
+
input: {
|
|
129
|
+
insight: JSON.stringify({
|
|
130
|
+
status: 'ws_protocol_lifter_complete',
|
|
131
|
+
workflowId,
|
|
132
|
+
url,
|
|
133
|
+
maxFrames,
|
|
134
|
+
captureDelay,
|
|
135
|
+
}),
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return root;
|
|
140
|
+
})
|
|
141
|
+
.onStart((ctx) => {
|
|
142
|
+
ctx.emitMetric('workflow_runs_total', 1, 'counter', {
|
|
143
|
+
workflowId,
|
|
144
|
+
mission: 'ws_protocol_lifter',
|
|
145
|
+
stage: 'start',
|
|
146
|
+
});
|
|
147
|
+
})
|
|
148
|
+
.onFinish((ctx) => {
|
|
149
|
+
ctx.emitMetric('workflow_runs_total', 1, 'counter', {
|
|
150
|
+
workflowId,
|
|
151
|
+
mission: 'ws_protocol_lifter',
|
|
152
|
+
stage: 'finish',
|
|
153
|
+
});
|
|
154
|
+
})
|
|
155
|
+
.onError((ctx, error) => {
|
|
156
|
+
ctx.emitMetric('workflow_errors_total', 1, 'counter', {
|
|
157
|
+
workflowId,
|
|
158
|
+
mission: 'ws_protocol_lifter',
|
|
159
|
+
stage: 'error',
|
|
160
|
+
error: error.name,
|
|
161
|
+
});
|
|
162
|
+
})
|
|
163
|
+
.build();
|