deepspider 0.1.0
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/.claude/agents/check.md +122 -0
- package/.claude/agents/debug.md +106 -0
- package/.claude/agents/dispatch.md +214 -0
- package/.claude/agents/implement.md +96 -0
- package/.claude/agents/plan.md +396 -0
- package/.claude/agents/research.md +120 -0
- package/.claude/commands/evolve/merge.md +80 -0
- package/.claude/commands/trellis/before-backend-dev.md +13 -0
- package/.claude/commands/trellis/before-frontend-dev.md +13 -0
- package/.claude/commands/trellis/break-loop.md +107 -0
- package/.claude/commands/trellis/check-backend.md +13 -0
- package/.claude/commands/trellis/check-cross-layer.md +153 -0
- package/.claude/commands/trellis/check-frontend.md +13 -0
- package/.claude/commands/trellis/create-command.md +154 -0
- package/.claude/commands/trellis/finish-work.md +129 -0
- package/.claude/commands/trellis/integrate-skill.md +219 -0
- package/.claude/commands/trellis/onboard.md +358 -0
- package/.claude/commands/trellis/parallel.md +193 -0
- package/.claude/commands/trellis/record-session.md +62 -0
- package/.claude/commands/trellis/start.md +280 -0
- package/.claude/commands/trellis/update-spec.md +213 -0
- package/.claude/hooks/inject-subagent-context.py +758 -0
- package/.claude/hooks/ralph-loop.py +374 -0
- package/.claude/hooks/session-start.py +126 -0
- package/.claude/settings.json +41 -0
- package/.claude/skills/deepagents-guide/SKILL.md +428 -0
- package/.cursor/commands/trellis-before-backend-dev.md +13 -0
- package/.cursor/commands/trellis-before-frontend-dev.md +13 -0
- package/.cursor/commands/trellis-break-loop.md +107 -0
- package/.cursor/commands/trellis-check-backend.md +13 -0
- package/.cursor/commands/trellis-check-cross-layer.md +153 -0
- package/.cursor/commands/trellis-check-frontend.md +13 -0
- package/.cursor/commands/trellis-create-command.md +154 -0
- package/.cursor/commands/trellis-finish-work.md +129 -0
- package/.cursor/commands/trellis-integrate-skill.md +219 -0
- package/.cursor/commands/trellis-onboard.md +358 -0
- package/.cursor/commands/trellis-record-session.md +62 -0
- package/.cursor/commands/trellis-start.md +156 -0
- package/.cursor/commands/trellis-update-spec.md +213 -0
- package/.env.example +11 -0
- package/.husky/pre-commit +1 -0
- package/.mcp.json +8 -0
- package/.trellis/.template-hashes.json +65 -0
- package/.trellis/.version +1 -0
- package/.trellis/scripts/add-session.sh +384 -0
- package/.trellis/scripts/common/developer.sh +129 -0
- package/.trellis/scripts/common/git-context.sh +263 -0
- package/.trellis/scripts/common/paths.sh +208 -0
- package/.trellis/scripts/common/phase.sh +150 -0
- package/.trellis/scripts/common/registry.sh +247 -0
- package/.trellis/scripts/common/task-queue.sh +142 -0
- package/.trellis/scripts/common/task-utils.sh +151 -0
- package/.trellis/scripts/common/worktree.sh +128 -0
- package/.trellis/scripts/create-bootstrap.sh +299 -0
- package/.trellis/scripts/get-context.sh +7 -0
- package/.trellis/scripts/get-developer.sh +15 -0
- package/.trellis/scripts/init-developer.sh +34 -0
- package/.trellis/scripts/multi-agent/cleanup.sh +396 -0
- package/.trellis/scripts/multi-agent/create-pr.sh +241 -0
- package/.trellis/scripts/multi-agent/plan.sh +207 -0
- package/.trellis/scripts/multi-agent/start.sh +310 -0
- package/.trellis/scripts/multi-agent/status.sh +828 -0
- package/.trellis/scripts/task.sh +1118 -0
- package/.trellis/spec/backend/deepagents-guide.md +337 -0
- package/.trellis/spec/backend/directory-structure.md +126 -0
- package/.trellis/spec/backend/examples/skills/deepagents-guide/README.md +11 -0
- package/.trellis/spec/backend/examples/skills/deepagents-guide/agent.js.template +20 -0
- package/.trellis/spec/backend/examples/skills/deepagents-guide/skills-config.js.template +13 -0
- package/.trellis/spec/backend/examples/skills/deepagents-guide/subagent.js.template +19 -0
- package/.trellis/spec/backend/hook-guidelines.md +178 -0
- package/.trellis/spec/backend/index.md +36 -0
- package/.trellis/spec/backend/quality-guidelines.md +201 -0
- package/.trellis/spec/backend/state-management.md +76 -0
- package/.trellis/spec/backend/tool-guidelines.md +144 -0
- package/.trellis/spec/backend/type-safety.md +71 -0
- package/.trellis/spec/guides/code-reuse-thinking-guide.md +92 -0
- package/.trellis/spec/guides/cross-layer-thinking-guide.md +94 -0
- package/.trellis/spec/guides/index.md +79 -0
- package/.trellis/tasks/archive/02-02-evolving-skills/prd.md +61 -0
- package/.trellis/tasks/archive/02-02-evolving-skills/task.json +29 -0
- package/.trellis/tasks/archive/2026-02/00-bootstrap-guidelines/prd.md +86 -0
- package/.trellis/tasks/archive/2026-02/00-bootstrap-guidelines/task.json +27 -0
- package/.trellis/tasks/archive/2026-02/02-02-skills-system/check.jsonl +3 -0
- package/.trellis/tasks/archive/2026-02/02-02-skills-system/debug.jsonl +2 -0
- package/.trellis/tasks/archive/2026-02/02-02-skills-system/implement.jsonl +5 -0
- package/.trellis/tasks/archive/2026-02/02-02-skills-system/prd.md +33 -0
- package/.trellis/tasks/archive/2026-02/02-02-skills-system/task.json +41 -0
- package/.trellis/workflow.md +407 -0
- package/.trellis/workspace/index.md +123 -0
- package/.trellis/workspace/pony/index.md +40 -0
- package/.trellis/workspace/pony/journal-1.md +7 -0
- package/.trellis/worktree.yaml +47 -0
- package/AGENTS.md +18 -0
- package/CLAUDE.md +292 -0
- package/README.md +134 -0
- package/agents/deepspider.md +142 -0
- package/docs/DEBUG.md +42 -0
- package/docs/GUIDE.md +334 -0
- package/docs/PROMPT.md +60 -0
- package/docs/USAGE.md +226 -0
- package/eslint.config.js +51 -0
- package/package.json +78 -0
- package/requirements-crypto.txt +14 -0
- package/src/agent/index.js +97 -0
- package/src/agent/logger.js +164 -0
- package/src/agent/middleware/filterTools.js +64 -0
- package/src/agent/middleware/report.js +79 -0
- package/src/agent/prompts/system.js +315 -0
- package/src/agent/run.js +575 -0
- package/src/agent/skills/anti-detect/SKILL.md +28 -0
- package/src/agent/skills/anti-detect/evolved.md +12 -0
- package/src/agent/skills/captcha/SKILL.md +37 -0
- package/src/agent/skills/captcha/evolved.md +12 -0
- package/src/agent/skills/config.js +30 -0
- package/src/agent/skills/crawler/SKILL.md +9 -0
- package/src/agent/skills/crawler/evolved.md +16 -0
- package/src/agent/skills/dynamic-analysis/SKILL.md +91 -0
- package/src/agent/skills/dynamic-analysis/evolved.md +12 -0
- package/src/agent/skills/env/SKILL.md +72 -0
- package/src/agent/skills/env/evolved.md +12 -0
- package/src/agent/skills/evolve.js +79 -0
- package/src/agent/skills/general/SKILL.md +12 -0
- package/src/agent/skills/general/evolved.md +12 -0
- package/src/agent/skills/js2python/SKILL.md +30 -0
- package/src/agent/skills/js2python/evolved.md +13 -0
- package/src/agent/skills/report/SKILL.md +21 -0
- package/src/agent/skills/report/evolved.md +12 -0
- package/src/agent/skills/sandbox/SKILL.md +22 -0
- package/src/agent/skills/sandbox/evolved.md +16 -0
- package/src/agent/skills/static-analysis/SKILL.md +93 -0
- package/src/agent/skills/static-analysis/evolved.md +12 -0
- package/src/agent/skills/xpath/SKILL.md +119 -0
- package/src/agent/subagents/anti-detect.js +45 -0
- package/src/agent/subagents/captcha.js +51 -0
- package/src/agent/subagents/crawler.js +138 -0
- package/src/agent/subagents/dynamic.js +64 -0
- package/src/agent/subagents/env-agent.js +82 -0
- package/src/agent/subagents/index.js +37 -0
- package/src/agent/subagents/js2python.js +72 -0
- package/src/agent/subagents/sandbox.js +55 -0
- package/src/agent/subagents/static.js +66 -0
- package/src/agent/tools/analysis.js +135 -0
- package/src/agent/tools/analyzer.js +85 -0
- package/src/agent/tools/anti-detect.js +89 -0
- package/src/agent/tools/antidebug.js +64 -0
- package/src/agent/tools/async.js +43 -0
- package/src/agent/tools/browser.js +324 -0
- package/src/agent/tools/captcha.js +223 -0
- package/src/agent/tools/capture.js +179 -0
- package/src/agent/tools/correlate.js +303 -0
- package/src/agent/tools/crawler.js +116 -0
- package/src/agent/tools/cryptohook.js +80 -0
- package/src/agent/tools/debug.js +246 -0
- package/src/agent/tools/deobfuscator.js +90 -0
- package/src/agent/tools/env.js +83 -0
- package/src/agent/tools/envdump.js +92 -0
- package/src/agent/tools/evolve.js +164 -0
- package/src/agent/tools/extract.js +114 -0
- package/src/agent/tools/extractor.js +54 -0
- package/src/agent/tools/file.js +224 -0
- package/src/agent/tools/hook.js +84 -0
- package/src/agent/tools/hookManager.js +178 -0
- package/src/agent/tools/index.js +137 -0
- package/src/agent/tools/nodejs.js +101 -0
- package/src/agent/tools/patch.js +46 -0
- package/src/agent/tools/preprocess.js +71 -0
- package/src/agent/tools/profile.js +122 -0
- package/src/agent/tools/python.js +627 -0
- package/src/agent/tools/report.js +124 -0
- package/src/agent/tools/runtime.js +132 -0
- package/src/agent/tools/sandbox.js +79 -0
- package/src/agent/tools/store.js +73 -0
- package/src/agent/tools/trace.js +74 -0
- package/src/agent/tools/tracing.js +201 -0
- package/src/agent/tools/utils.js +51 -0
- package/src/agent/tools/verify.js +184 -0
- package/src/agent/tools/webcrack.js +109 -0
- package/src/analyzer/ASTAnalyzer.js +387 -0
- package/src/analyzer/CallStackAnalyzer.js +379 -0
- package/src/analyzer/Deobfuscator.js +289 -0
- package/src/analyzer/EncryptionAnalyzer.js +99 -0
- package/src/analyzer/index.js +22 -0
- package/src/browser/EnvBridge.js +186 -0
- package/src/browser/cdp.js +168 -0
- package/src/browser/client.js +197 -0
- package/src/browser/collector.js +444 -0
- package/src/browser/collectors/RequestCryptoLinker.js +109 -0
- package/src/browser/collectors/ResponseSearcher.js +107 -0
- package/src/browser/collectors/ScriptCollector.js +158 -0
- package/src/browser/collectors/index.js +26 -0
- package/src/browser/defaultHooks.js +932 -0
- package/src/browser/hooks/crypto.js +55 -0
- package/src/browser/hooks/index.js +64 -0
- package/src/browser/hooks/native.js +9 -0
- package/src/browser/hooks/network.js +33 -0
- package/src/browser/index.js +42 -0
- package/src/browser/interceptors/NetworkInterceptor.js +116 -0
- package/src/browser/interceptors/ScriptInterceptor.js +76 -0
- package/src/browser/interceptors/index.js +6 -0
- package/src/browser/ui/analysisPanel.js +1782 -0
- package/src/browser/ui/confirmDialog.js +158 -0
- package/src/browser/ui/panel.html +152 -0
- package/src/browser/ui/selector.js +170 -0
- package/src/config/index.js +5 -0
- package/src/config/paths.js +71 -0
- package/src/config/patterns/crypto.js +36 -0
- package/src/config/profiles/chrome.json +71 -0
- package/src/config/profiles/firefox.json +44 -0
- package/src/config/profiles/safari.json +38 -0
- package/src/core/EnvMonitor.js +200 -0
- package/src/core/PatchGenerator.js +278 -0
- package/src/core/Sandbox.js +181 -0
- package/src/env/AntiAntiDebug.js +111 -0
- package/src/env/AsyncHook.js +68 -0
- package/src/env/BrowserAPIList.js +265 -0
- package/src/env/CookieHook.js +48 -0
- package/src/env/CryptoHook.js +205 -0
- package/src/env/EnvCodeGenerator.js +157 -0
- package/src/env/EnvDumper.js +356 -0
- package/src/env/EnvExtractor.js +220 -0
- package/src/env/HookBase.js +618 -0
- package/src/env/NetworkHook.js +159 -0
- package/src/env/modules/bom/history.js +29 -0
- package/src/env/modules/bom/location.js +26 -0
- package/src/env/modules/bom/navigator.js +70 -0
- package/src/env/modules/bom/screen.js +26 -0
- package/src/env/modules/bom/storage.js +23 -0
- package/src/env/modules/dom/document.js +110 -0
- package/src/env/modules/dom/event.js +51 -0
- package/src/env/modules/index.js +34 -0
- package/src/env/modules/webapi/fetch.js +46 -0
- package/src/env/modules/webapi/url.js +47 -0
- package/src/env/modules/webapi/xhr.js +48 -0
- package/src/index.js +27 -0
- package/src/mcp/server.js +89 -0
- package/src/store/DataStore.js +708 -0
- package/src/store/Store.js +158 -0
- package/src/store/Validator.js +24 -0
- package/test/analyze.test.js +90 -0
- package/test/envdump.test.js +74 -0
- package/test/flow.test.js +90 -0
- package/test/hooks.test.js +138 -0
- package/test/plugin.test.js +35 -0
- package/test/refactor-full.test.js +30 -0
- package/test/refactor.test.js +21 -0
- package/test/samples/obfuscated.js +61 -0
- package/test/samples/original.js +66 -0
- package/test/samples/v10_eval_chain.js +52 -0
- package/test/samples/v11_bytecode_vm.js +81 -0
- package/test/samples/v12_polymorphic.js +69 -0
- package/test/samples/v1_ob_basic.js +98 -0
- package/test/samples/v2_ob_advanced.js +99 -0
- package/test/samples/v3_jjencode.js +77 -0
- package/test/samples/v4_aaencode.js +73 -0
- package/test/samples/v5_control_flow.js +86 -0
- package/test/samples/v6_string_encryption.js +71 -0
- package/test/samples/v7_jsvmp.js +83 -0
- package/test/samples/v8_anti_debug.js +79 -0
- package/test/samples/v9_proxy_trap.js +49 -0
- package/test/samples.test.js +96 -0
- package/test/webcrack.test.js +55 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeepSpider - 工具索引
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { sandboxTools, sandboxExecute, sandboxInject, sandboxReset, getSandbox } from './sandbox.js';
|
|
6
|
+
export { analyzerTools, analyzeAst, analyzeCallstack, analyzeEncryption } from './analyzer.js';
|
|
7
|
+
export { deobfuscatorTools, deobfuscate, deobfuscatePipeline, detectObfuscator, decodeStrings } from './deobfuscator.js';
|
|
8
|
+
export { traceTools, traceVariable, traceRequestParams, findCallPattern } from './trace.js';
|
|
9
|
+
export { storeTools, saveToStore, queryStore, listStore } from './store.js';
|
|
10
|
+
export { patchTools, generatePatch, matchModule } from './patch.js';
|
|
11
|
+
export { envTools, listEnvModules, loadEnvModule, loadAllEnvModules } from './env.js';
|
|
12
|
+
export { profileTools, listProfiles, loadProfile, generateProfileCode } from './profile.js';
|
|
13
|
+
export { runtimeTools, launchBrowser, navigateTo, browserClose, addInitScript, clearCookies } from './runtime.js';
|
|
14
|
+
export { debugTools, setBreakpoint, setXHRBreakpoint, getCallStack, getFrameVariables, evaluateAtBreakpoint, resumeExecution, stepOver } from './debug.js';
|
|
15
|
+
export { captureTools, collectEnv, collectProperty, autoFixEnv, getHookLogs } from './capture.js';
|
|
16
|
+
export { browserTools, clickElement, fillInput, waitForSelector } from './browser.js';
|
|
17
|
+
export { reportTools, saveAnalysisReport } from './report.js';
|
|
18
|
+
export { webcrackTools, unpackBundle, analyzeBundle } from './webcrack.js';
|
|
19
|
+
export { preprocessTools, preprocessCode } from './preprocess.js';
|
|
20
|
+
export { envDumpTools, generateEnvDumpCode, generateBaseEnvCode, parseEnvLogs } from './envdump.js';
|
|
21
|
+
export { extractTools, generateExtractScript, generateBatchExtractScript, convertToPatchCode, classifyPatch } from './extract.js';
|
|
22
|
+
export { hookTools, generateXHRHook, generateFetchHook, generateCookieHook } from './hook.js';
|
|
23
|
+
export { asyncTools, generatePromiseHook, generateTimerHook } from './async.js';
|
|
24
|
+
export { antiDebugTools, generateAntiDebugger, generateAntiConsoleDetect, generateAntiCDP, generateFullAntiDebug } from './antidebug.js';
|
|
25
|
+
export { verifyTools, verifyMD5, verifySHA256, verifyHMAC, verifyAES, identifyEncryption } from './verify.js';
|
|
26
|
+
export { cryptoHookTools, generateCryptoJSHook, generateRSAHook } from './cryptohook.js';
|
|
27
|
+
export { correlateTools, analyzeCorrelation, locateCryptoSource, analyzeHeaderEncryption, analyzeCookieEncryption, analyzeResponseDecryption } from './correlate.js';
|
|
28
|
+
export { extractorTools, listFunctions, getFunctionCode } from './extractor.js';
|
|
29
|
+
export { tracingTools, getSiteList, searchInResponses, getRequestDetail, getRequestList, getScriptList, getScriptSource, searchInScripts, clearSiteData, clearAllData } from './tracing.js';
|
|
30
|
+
export { analysisTools, getPendingAnalysis, getPendingChat, sendPanelMessage, startSelector } from './analysis.js';
|
|
31
|
+
export { fileTools, artifactSave, artifactLoad, artifactEdit, artifactGlob, artifactGrep } from './file.js';
|
|
32
|
+
export { evolveTools, evolveSkill } from './evolve.js';
|
|
33
|
+
export { captchaTools } from './captcha.js';
|
|
34
|
+
export { antiDetectTools } from './anti-detect.js';
|
|
35
|
+
export { crawlerTools } from './crawler.js';
|
|
36
|
+
export { nodejsTools, runNodeCode } from './nodejs.js';
|
|
37
|
+
export { hookManagerTools, listHooks, enableHook, disableHook, injectHook, setHookConfig } from './hookManager.js';
|
|
38
|
+
// pythonTools 只在 js2python 子代理中使用,不导出到主工具集
|
|
39
|
+
|
|
40
|
+
// 所有工具
|
|
41
|
+
import { sandboxTools } from './sandbox.js';
|
|
42
|
+
import { analyzerTools } from './analyzer.js';
|
|
43
|
+
import { deobfuscatorTools } from './deobfuscator.js';
|
|
44
|
+
import { traceTools } from './trace.js';
|
|
45
|
+
import { storeTools } from './store.js';
|
|
46
|
+
import { patchTools } from './patch.js';
|
|
47
|
+
import { envTools } from './env.js';
|
|
48
|
+
import { profileTools } from './profile.js';
|
|
49
|
+
import { runtimeTools } from './runtime.js';
|
|
50
|
+
import { debugTools } from './debug.js';
|
|
51
|
+
import { captureTools } from './capture.js';
|
|
52
|
+
import { browserTools } from './browser.js';
|
|
53
|
+
import { reportTools } from './report.js';
|
|
54
|
+
import { webcrackTools } from './webcrack.js';
|
|
55
|
+
import { preprocessTools } from './preprocess.js';
|
|
56
|
+
import { envDumpTools } from './envdump.js';
|
|
57
|
+
import { extractTools } from './extract.js';
|
|
58
|
+
import { hookTools } from './hook.js';
|
|
59
|
+
import { asyncTools } from './async.js';
|
|
60
|
+
import { antiDebugTools } from './antidebug.js';
|
|
61
|
+
import { verifyTools } from './verify.js';
|
|
62
|
+
import { cryptoHookTools } from './cryptohook.js';
|
|
63
|
+
import { correlateTools } from './correlate.js';
|
|
64
|
+
import { extractorTools } from './extractor.js';
|
|
65
|
+
import { tracingTools } from './tracing.js';
|
|
66
|
+
import { analysisTools } from './analysis.js';
|
|
67
|
+
import { fileTools } from './file.js';
|
|
68
|
+
import { evolveTools } from './evolve.js';
|
|
69
|
+
import { captchaTools } from './captcha.js';
|
|
70
|
+
import { antiDetectTools } from './anti-detect.js';
|
|
71
|
+
import { crawlerTools } from './crawler.js';
|
|
72
|
+
import { nodejsTools } from './nodejs.js';
|
|
73
|
+
import { hookManagerTools } from './hookManager.js';
|
|
74
|
+
|
|
75
|
+
export const allTools = [
|
|
76
|
+
...sandboxTools,
|
|
77
|
+
...analyzerTools,
|
|
78
|
+
...deobfuscatorTools,
|
|
79
|
+
...traceTools,
|
|
80
|
+
...storeTools,
|
|
81
|
+
...patchTools,
|
|
82
|
+
...envTools,
|
|
83
|
+
...profileTools,
|
|
84
|
+
...runtimeTools,
|
|
85
|
+
...debugTools,
|
|
86
|
+
...captureTools,
|
|
87
|
+
...browserTools,
|
|
88
|
+
...reportTools,
|
|
89
|
+
...webcrackTools,
|
|
90
|
+
...preprocessTools,
|
|
91
|
+
...envDumpTools,
|
|
92
|
+
...extractTools,
|
|
93
|
+
...hookTools,
|
|
94
|
+
...asyncTools,
|
|
95
|
+
...antiDebugTools,
|
|
96
|
+
...verifyTools,
|
|
97
|
+
...cryptoHookTools,
|
|
98
|
+
...correlateTools,
|
|
99
|
+
...extractorTools,
|
|
100
|
+
...tracingTools,
|
|
101
|
+
...analysisTools,
|
|
102
|
+
...fileTools,
|
|
103
|
+
...evolveTools,
|
|
104
|
+
...captchaTools,
|
|
105
|
+
...antiDetectTools,
|
|
106
|
+
...crawlerTools,
|
|
107
|
+
...nodejsTools,
|
|
108
|
+
...hookManagerTools,
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 主 Agent 核心工具
|
|
113
|
+
* 只包含必要的运行时、交互和数据查询工具
|
|
114
|
+
* pythonTools 只在 js2python 子代理中使用
|
|
115
|
+
*/
|
|
116
|
+
export const coreTools = [
|
|
117
|
+
// 浏览器运行时
|
|
118
|
+
...runtimeTools,
|
|
119
|
+
// 页面交互
|
|
120
|
+
...browserTools,
|
|
121
|
+
// 浏览器分析交互
|
|
122
|
+
...analysisTools,
|
|
123
|
+
// 数据溯源查询
|
|
124
|
+
...tracingTools,
|
|
125
|
+
// 沙箱执行(验证代码)
|
|
126
|
+
...sandboxTools,
|
|
127
|
+
// Hook 日志
|
|
128
|
+
...captureTools,
|
|
129
|
+
// 文件操作
|
|
130
|
+
...fileTools,
|
|
131
|
+
// 经验进化
|
|
132
|
+
...evolveTools,
|
|
133
|
+
// Node.js 执行(支持 require)
|
|
134
|
+
...nodejsTools,
|
|
135
|
+
// Hook 动态管理
|
|
136
|
+
...hookManagerTools,
|
|
137
|
+
];
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeepSpider - Node.js 执行工具
|
|
3
|
+
* 用于执行带有 require 依赖的 JS 代码
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { tool } from '@langchain/core/tools';
|
|
8
|
+
import { spawn } from 'child_process';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { dirname, join } from 'path';
|
|
11
|
+
|
|
12
|
+
// 项目根目录(用于 require 加密库)
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
const PROJECT_ROOT = join(__dirname, '../../..');
|
|
16
|
+
|
|
17
|
+
// 输出大小限制
|
|
18
|
+
const MAX_OUTPUT_SIZE = 100000;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 执行 Node.js 代码
|
|
22
|
+
*/
|
|
23
|
+
async function executeNode(code, timeout = 10000) {
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
const proc = spawn('node', ['-e', code], {
|
|
26
|
+
env: { ...process.env },
|
|
27
|
+
cwd: PROJECT_ROOT,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
let stdout = '';
|
|
31
|
+
let stderr = '';
|
|
32
|
+
let killed = false;
|
|
33
|
+
|
|
34
|
+
// 手动实现超时
|
|
35
|
+
const timer = setTimeout(() => {
|
|
36
|
+
killed = true;
|
|
37
|
+
proc.kill('SIGTERM');
|
|
38
|
+
}, timeout);
|
|
39
|
+
|
|
40
|
+
proc.stdout.on('data', (data) => {
|
|
41
|
+
if (stdout.length < MAX_OUTPUT_SIZE) {
|
|
42
|
+
stdout += data.toString();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
proc.stderr.on('data', (data) => {
|
|
47
|
+
if (stderr.length < MAX_OUTPUT_SIZE) {
|
|
48
|
+
stderr += data.toString();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
proc.on('close', (exitCode) => {
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
resolve({
|
|
55
|
+
success: !killed && exitCode === 0,
|
|
56
|
+
stdout: stdout.trim(),
|
|
57
|
+
stderr: killed ? 'Timeout: process killed' : stderr.trim(),
|
|
58
|
+
exitCode: killed ? -1 : exitCode,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
proc.on('error', (err) => {
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
resolve({
|
|
65
|
+
success: false,
|
|
66
|
+
stdout: '',
|
|
67
|
+
stderr: err.message,
|
|
68
|
+
exitCode: -1,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 执行 Node.js 代码
|
|
76
|
+
*/
|
|
77
|
+
export const runNodeCode = tool(
|
|
78
|
+
async ({ code, timeout }) => {
|
|
79
|
+
const result = await executeNode(code, timeout || 10000);
|
|
80
|
+
return JSON.stringify(result);
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'run_node_code',
|
|
84
|
+
description: `在 Node.js 环境中执行 JS 代码,支持 require 引入已安装的加密库。
|
|
85
|
+
|
|
86
|
+
可用的加密库:
|
|
87
|
+
- crypto-js: AES/DES/MD5/SHA 等常用加密
|
|
88
|
+
- jsencrypt: RSA 加密
|
|
89
|
+
- sm-crypto: 国密 SM2/SM3/SM4
|
|
90
|
+
- js-md5: MD5 哈希
|
|
91
|
+
- js-sha256: SHA256 哈希
|
|
92
|
+
|
|
93
|
+
示例:const CryptoJS = require('crypto-js'); console.log(CryptoJS.MD5('test').toString());`,
|
|
94
|
+
schema: z.object({
|
|
95
|
+
code: z.string().describe('要执行的 JS 代码,可使用 require 引入加密库'),
|
|
96
|
+
timeout: z.number().optional().default(10000).describe('超时时间(毫秒)'),
|
|
97
|
+
}),
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
export const nodejsTools = [runNodeCode];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeepSpider - 补丁生成工具
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { tool } from '@langchain/core/tools';
|
|
7
|
+
import { PatchGenerator } from '../../core/PatchGenerator.js';
|
|
8
|
+
|
|
9
|
+
const patchGen = new PatchGenerator();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 生成单个补丁
|
|
13
|
+
*/
|
|
14
|
+
export const generatePatch = tool(
|
|
15
|
+
async ({ property, context }) => {
|
|
16
|
+
const result = await patchGen.generate(property, context);
|
|
17
|
+
return JSON.stringify(result, null, 2);
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'generate_patch',
|
|
21
|
+
description: '为缺失的环境属性生成补丁代码。',
|
|
22
|
+
schema: z.object({
|
|
23
|
+
property: z.string().describe('缺失的属性路径,如 navigator.userAgent'),
|
|
24
|
+
context: z.record(z.string(), z.unknown()).optional().describe('上下文信息'),
|
|
25
|
+
}),
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 批量生成补丁
|
|
31
|
+
*/
|
|
32
|
+
export const matchModule = tool(
|
|
33
|
+
async ({ missingProperties }) => {
|
|
34
|
+
const result = await patchGen.generateBatch(missingProperties);
|
|
35
|
+
return JSON.stringify(result, null, 2);
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'match_module',
|
|
39
|
+
description: '批量匹配缺失属性,生成补丁集。',
|
|
40
|
+
schema: z.object({
|
|
41
|
+
missingProperties: z.array(z.string()).describe('缺失的属性路径列表'),
|
|
42
|
+
}),
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const patchTools = [generatePatch, matchModule];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeepSpider - 代码预处理工具
|
|
3
|
+
* 智能处理各种打包/混淆代码
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { tool } from '@langchain/core/tools';
|
|
8
|
+
import { webcrack } from 'webcrack';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 智能预处理代码
|
|
12
|
+
* 自动检测并处理 Webpack/Browserify 或直接反混淆
|
|
13
|
+
*/
|
|
14
|
+
export const preprocessCode = tool(
|
|
15
|
+
async ({ code, outputDir }) => {
|
|
16
|
+
try {
|
|
17
|
+
const result = await webcrack(code);
|
|
18
|
+
|
|
19
|
+
const output = {
|
|
20
|
+
success: true,
|
|
21
|
+
bundleDetected: !!result.bundle?.type,
|
|
22
|
+
bundleType: result.bundle?.type || null,
|
|
23
|
+
code: result.code,
|
|
24
|
+
modules: [],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// 如果检测到 bundle,提取模块信息
|
|
28
|
+
if (result.bundle?.modules) {
|
|
29
|
+
for (const [id, module] of result.bundle.modules) {
|
|
30
|
+
output.modules.push({
|
|
31
|
+
id,
|
|
32
|
+
path: module.path || '',
|
|
33
|
+
isEntry: module.isEntry || false,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
output.moduleCount = output.modules.length;
|
|
39
|
+
|
|
40
|
+
// 保存到目录(如果指定)
|
|
41
|
+
if (outputDir && result.bundle) {
|
|
42
|
+
await result.save(outputDir);
|
|
43
|
+
output.outputDir = outputDir;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 添加处理建议
|
|
47
|
+
if (output.bundleDetected) {
|
|
48
|
+
output.suggestion = '已解包,可继续用 deobfuscate 处理各模块';
|
|
49
|
+
} else {
|
|
50
|
+
output.suggestion = '未检测到 bundle 结构,已完成基础反混淆,可继续用 deobfuscate 深度处理';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return JSON.stringify(output);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return JSON.stringify({
|
|
56
|
+
success: false,
|
|
57
|
+
error: error.message,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'preprocess_code',
|
|
63
|
+
description: '智能预处理 JS 代码:自动检测 Webpack/Browserify 并解包,或直接反混淆 Vite/Rollup 代码',
|
|
64
|
+
schema: z.object({
|
|
65
|
+
code: z.string().describe('待处理的 JS 代码'),
|
|
66
|
+
outputDir: z.string().optional().describe('输出目录(可选,仅对 bundle 有效)'),
|
|
67
|
+
}),
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
export const preprocessTools = [preprocessCode];
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeepSpider - 浏览器 Profile 工具
|
|
3
|
+
* 提供浏览器指纹配置加载能力
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { tool } from '@langchain/core/tools';
|
|
8
|
+
import { readFileSync } from 'fs';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { dirname, join } from 'path';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
const profilesDir = join(__dirname, '../../config/profiles');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 列出可用的浏览器 Profile
|
|
18
|
+
*/
|
|
19
|
+
export const listProfiles = tool(
|
|
20
|
+
async () => {
|
|
21
|
+
return JSON.stringify({
|
|
22
|
+
profiles: ['chrome', 'firefox', 'safari'],
|
|
23
|
+
description: {
|
|
24
|
+
chrome: 'Chrome 120 Windows - 最常用的浏览器指纹',
|
|
25
|
+
firefox: 'Firefox Windows - 备选浏览器指纹',
|
|
26
|
+
safari: 'Safari macOS - Apple 设备指纹',
|
|
27
|
+
},
|
|
28
|
+
}, null, 2);
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'list_profiles',
|
|
32
|
+
description: '列出所有可用的浏览器指纹 Profile。',
|
|
33
|
+
schema: z.object({}),
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 加载指定的浏览器 Profile
|
|
39
|
+
*/
|
|
40
|
+
export const loadProfile = tool(
|
|
41
|
+
async ({ name }) => {
|
|
42
|
+
try {
|
|
43
|
+
const path = join(profilesDir, `${name}.json`);
|
|
44
|
+
const profile = JSON.parse(readFileSync(path, 'utf-8'));
|
|
45
|
+
return JSON.stringify({ success: true, name, profile }, null, 2);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
return JSON.stringify({
|
|
48
|
+
success: false,
|
|
49
|
+
error: `Profile ${name} 加载失败: ${e.message}`,
|
|
50
|
+
available: ['chrome', 'firefox', 'safari'],
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'load_profile',
|
|
56
|
+
description: '加载指定的浏览器指纹 Profile,包含 navigator、screen、window 等完整配置。',
|
|
57
|
+
schema: z.object({
|
|
58
|
+
name: z.enum(['chrome', 'firefox', 'safari']).describe('Profile 名称'),
|
|
59
|
+
}),
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 生成 Profile 注入代码
|
|
65
|
+
*/
|
|
66
|
+
export const generateProfileCode = tool(
|
|
67
|
+
async ({ name }) => {
|
|
68
|
+
try {
|
|
69
|
+
const path = join(profilesDir, `${name}.json`);
|
|
70
|
+
const profile = JSON.parse(readFileSync(path, 'utf-8'));
|
|
71
|
+
|
|
72
|
+
const lines = [];
|
|
73
|
+
|
|
74
|
+
// Navigator 属性
|
|
75
|
+
if (profile.navigator) {
|
|
76
|
+
for (const [k, v] of Object.entries(profile.navigator)) {
|
|
77
|
+
if (typeof v === 'string') {
|
|
78
|
+
lines.push(`navigator.${k} = "${v}";`);
|
|
79
|
+
} else if (Array.isArray(v)) {
|
|
80
|
+
lines.push(`navigator.${k} = ${JSON.stringify(v)};`);
|
|
81
|
+
} else if (typeof v !== 'object') {
|
|
82
|
+
lines.push(`navigator.${k} = ${v};`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Screen 属性
|
|
88
|
+
if (profile.screen) {
|
|
89
|
+
for (const [k, v] of Object.entries(profile.screen)) {
|
|
90
|
+
lines.push(`screen.${k} = ${v};`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Window 属性
|
|
95
|
+
if (profile.window) {
|
|
96
|
+
for (const [k, v] of Object.entries(profile.window)) {
|
|
97
|
+
lines.push(`window.${k} = ${v};`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return JSON.stringify({
|
|
102
|
+
success: true,
|
|
103
|
+
name,
|
|
104
|
+
code: lines.join('\n'),
|
|
105
|
+
}, null, 2);
|
|
106
|
+
} catch (e) {
|
|
107
|
+
return JSON.stringify({
|
|
108
|
+
success: false,
|
|
109
|
+
error: `生成 Profile 代码失败: ${e.message}`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'generate_profile_code',
|
|
115
|
+
description: '根据 Profile 生成可注入沙箱的 JavaScript 代码。',
|
|
116
|
+
schema: z.object({
|
|
117
|
+
name: z.enum(['chrome', 'firefox', 'safari']).describe('Profile 名称'),
|
|
118
|
+
}),
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
export const profileTools = [listProfiles, loadProfile, generateProfileCode];
|