deepspider 0.2.12 → 0.3.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/README.md +53 -27
- package/bin/cli.js +45 -0
- package/package.json +10 -4
- package/src/agent/run.js +54 -63
- package/src/agent/setup.js +14 -14
- package/src/cli/commands/config.js +94 -0
- package/src/cli/commands/help.js +34 -0
- package/src/cli/commands/update.js +78 -0
- package/src/cli/commands/version.js +9 -0
- package/src/cli/config.js +15 -0
- package/src/config/settings.js +102 -0
- package/.claude/agents/check.md +0 -122
- package/.claude/agents/debug.md +0 -106
- package/.claude/agents/dispatch.md +0 -214
- package/.claude/agents/implement.md +0 -96
- package/.claude/agents/plan.md +0 -396
- package/.claude/agents/research.md +0 -120
- package/.claude/commands/evolve/merge.md +0 -80
- package/.claude/commands/trellis/before-backend-dev.md +0 -13
- package/.claude/commands/trellis/before-frontend-dev.md +0 -13
- package/.claude/commands/trellis/break-loop.md +0 -107
- package/.claude/commands/trellis/check-backend.md +0 -13
- package/.claude/commands/trellis/check-cross-layer.md +0 -153
- package/.claude/commands/trellis/check-frontend.md +0 -13
- package/.claude/commands/trellis/create-command.md +0 -154
- package/.claude/commands/trellis/finish-work.md +0 -129
- package/.claude/commands/trellis/integrate-skill.md +0 -219
- package/.claude/commands/trellis/onboard.md +0 -358
- package/.claude/commands/trellis/parallel.md +0 -193
- package/.claude/commands/trellis/record-session.md +0 -62
- package/.claude/commands/trellis/start.md +0 -280
- package/.claude/commands/trellis/update-spec.md +0 -213
- package/.claude/hooks/inject-subagent-context.py +0 -758
- package/.claude/hooks/ralph-loop.py +0 -374
- package/.claude/hooks/session-start.py +0 -126
- package/.claude/settings.json +0 -41
- package/.claude/skills/deepagents-guide/SKILL.md +0 -428
- package/.cursor/commands/trellis-before-backend-dev.md +0 -13
- package/.cursor/commands/trellis-before-frontend-dev.md +0 -13
- package/.cursor/commands/trellis-break-loop.md +0 -107
- package/.cursor/commands/trellis-check-backend.md +0 -13
- package/.cursor/commands/trellis-check-cross-layer.md +0 -153
- package/.cursor/commands/trellis-check-frontend.md +0 -13
- package/.cursor/commands/trellis-create-command.md +0 -154
- package/.cursor/commands/trellis-finish-work.md +0 -129
- package/.cursor/commands/trellis-integrate-skill.md +0 -219
- package/.cursor/commands/trellis-onboard.md +0 -358
- package/.cursor/commands/trellis-record-session.md +0 -62
- package/.cursor/commands/trellis-start.md +0 -156
- package/.cursor/commands/trellis-update-spec.md +0 -213
- package/.github/workflows/publish.yml +0 -63
- package/.husky/pre-commit +0 -1
- package/.mcp.json +0 -8
- package/.trellis/.template-hashes.json +0 -65
- package/.trellis/.version +0 -1
- package/.trellis/scripts/add-session.sh +0 -384
- package/.trellis/scripts/common/developer.sh +0 -129
- package/.trellis/scripts/common/git-context.sh +0 -263
- package/.trellis/scripts/common/paths.sh +0 -208
- package/.trellis/scripts/common/phase.sh +0 -150
- package/.trellis/scripts/common/registry.sh +0 -247
- package/.trellis/scripts/common/task-queue.sh +0 -142
- package/.trellis/scripts/common/task-utils.sh +0 -151
- package/.trellis/scripts/common/worktree.sh +0 -128
- package/.trellis/scripts/create-bootstrap.sh +0 -299
- package/.trellis/scripts/get-context.sh +0 -7
- package/.trellis/scripts/get-developer.sh +0 -15
- package/.trellis/scripts/init-developer.sh +0 -34
- package/.trellis/scripts/multi-agent/cleanup.sh +0 -396
- package/.trellis/scripts/multi-agent/create-pr.sh +0 -241
- package/.trellis/scripts/multi-agent/plan.sh +0 -207
- package/.trellis/scripts/multi-agent/start.sh +0 -310
- package/.trellis/scripts/multi-agent/status.sh +0 -828
- package/.trellis/scripts/task.sh +0 -1118
- package/.trellis/spec/backend/ci-cd-guidelines.md +0 -73
- package/.trellis/spec/backend/deepagents-guide.md +0 -380
- package/.trellis/spec/backend/directory-structure.md +0 -145
- package/.trellis/spec/backend/examples/skills/deepagents-guide/README.md +0 -11
- package/.trellis/spec/backend/examples/skills/deepagents-guide/agent.js.template +0 -20
- package/.trellis/spec/backend/examples/skills/deepagents-guide/skills-config.js.template +0 -13
- package/.trellis/spec/backend/examples/skills/deepagents-guide/subagent.js.template +0 -19
- package/.trellis/spec/backend/hook-guidelines.md +0 -218
- package/.trellis/spec/backend/index.md +0 -37
- package/.trellis/spec/backend/quality-guidelines.md +0 -377
- package/.trellis/spec/backend/state-management.md +0 -76
- package/.trellis/spec/backend/tool-guidelines.md +0 -144
- package/.trellis/spec/backend/type-safety.md +0 -71
- package/.trellis/spec/guides/code-reuse-thinking-guide.md +0 -92
- package/.trellis/spec/guides/cross-layer-thinking-guide.md +0 -94
- package/.trellis/spec/guides/index.md +0 -79
- package/.trellis/tasks/archive/02-02-evolving-skills/prd.md +0 -61
- package/.trellis/tasks/archive/02-02-evolving-skills/task.json +0 -29
- package/.trellis/tasks/archive/2026-02/00-bootstrap-guidelines/prd.md +0 -86
- package/.trellis/tasks/archive/2026-02/00-bootstrap-guidelines/task.json +0 -27
- package/.trellis/tasks/archive/2026-02/02-02-skills-system/check.jsonl +0 -3
- package/.trellis/tasks/archive/2026-02/02-02-skills-system/debug.jsonl +0 -2
- package/.trellis/tasks/archive/2026-02/02-02-skills-system/implement.jsonl +0 -5
- package/.trellis/tasks/archive/2026-02/02-02-skills-system/prd.md +0 -33
- package/.trellis/tasks/archive/2026-02/02-02-skills-system/task.json +0 -41
- package/.trellis/workflow.md +0 -407
- package/.trellis/workspace/index.md +0 -123
- package/.trellis/workspace/pony/index.md +0 -42
- package/.trellis/workspace/pony/journal-1.md +0 -125
- package/.trellis/worktree.yaml +0 -47
- package/AGENTS.md +0 -18
- package/CLAUDE.md +0 -315
- package/agents/deepspider.md +0 -142
- package/docs/DEBUG.md +0 -42
- package/docs/GUIDE.md +0 -338
- package/docs/PROMPT.md +0 -59
- package/docs/USAGE.md +0 -230
- package/eslint.config.js +0 -51
- package/test/analyze.test.js +0 -90
- package/test/envdump.test.js +0 -74
- package/test/flow.test.js +0 -90
- package/test/hooks.test.js +0 -138
- package/test/plugin.test.js +0 -35
- package/test/refactor-full.test.js +0 -30
- package/test/refactor.test.js +0 -21
- package/test/samples/obfuscated.js +0 -61
- package/test/samples/original.js +0 -66
- package/test/samples/v10_eval_chain.js +0 -52
- package/test/samples/v11_bytecode_vm.js +0 -81
- package/test/samples/v12_polymorphic.js +0 -69
- package/test/samples/v1_ob_basic.js +0 -98
- package/test/samples/v2_ob_advanced.js +0 -99
- package/test/samples/v3_jjencode.js +0 -77
- package/test/samples/v4_aaencode.js +0 -73
- package/test/samples/v5_control_flow.js +0 -86
- package/test/samples/v6_string_encryption.js +0 -71
- package/test/samples/v7_jsvmp.js +0 -83
- package/test/samples/v8_anti_debug.js +0 -79
- package/test/samples/v9_proxy_trap.js +0 -49
- package/test/samples.test.js +0 -96
- package/test/webcrack.test.js +0 -55
package/test/analyze.test.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DeepSpider 分析能力测试
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { ASTAnalyzer } from '../src/analyzer/ASTAnalyzer.js';
|
|
6
|
-
import { CallStackAnalyzer } from '../src/analyzer/CallStackAnalyzer.js';
|
|
7
|
-
import { EncryptionAnalyzer } from '../src/analyzer/EncryptionAnalyzer.js';
|
|
8
|
-
import { Deobfuscator } from '../src/analyzer/Deobfuscator.js';
|
|
9
|
-
import { Sandbox } from '../src/core/Sandbox.js';
|
|
10
|
-
import fs from 'fs';
|
|
11
|
-
import path from 'path';
|
|
12
|
-
import { fileURLToPath } from 'url';
|
|
13
|
-
|
|
14
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
|
|
16
|
-
// 读取测试样本
|
|
17
|
-
const originalCode = fs.readFileSync(path.join(__dirname, 'samples/original.js'), 'utf-8');
|
|
18
|
-
const obfuscatedCode = fs.readFileSync(path.join(__dirname, 'samples/obfuscated.js'), 'utf-8');
|
|
19
|
-
|
|
20
|
-
console.log('=== DeepSpider 分析能力测试 ===\n');
|
|
21
|
-
|
|
22
|
-
// 测试 1: 混淆器识别
|
|
23
|
-
console.log('【测试1】混淆器识别');
|
|
24
|
-
const deob = new Deobfuscator();
|
|
25
|
-
const obfuscatorType = deob.detectObfuscator(obfuscatedCode);
|
|
26
|
-
console.log('识别结果:', obfuscatorType);
|
|
27
|
-
console.log('混淆类型:', deob._detectType(obfuscatedCode));
|
|
28
|
-
console.log('');
|
|
29
|
-
|
|
30
|
-
// 测试 2: 反混淆流水线
|
|
31
|
-
console.log('【测试2】反混淆流水线');
|
|
32
|
-
const pipelineResult = deob.runPipeline(obfuscatedCode);
|
|
33
|
-
console.log('应用的步骤:', pipelineResult.applied);
|
|
34
|
-
console.log('代码长度变化:', obfuscatedCode.length, '->', pipelineResult.code.length);
|
|
35
|
-
console.log('');
|
|
36
|
-
|
|
37
|
-
// 测试 3: AST 分析
|
|
38
|
-
console.log('【测试3】AST 分析');
|
|
39
|
-
const astAnalyzer = new ASTAnalyzer();
|
|
40
|
-
const functions = astAnalyzer.extractFunctions(obfuscatedCode);
|
|
41
|
-
console.log('提取到函数数量:', functions.length);
|
|
42
|
-
functions.forEach(f => console.log(' -', f.name, `(${f.params.join(', ')})`));
|
|
43
|
-
console.log('');
|
|
44
|
-
|
|
45
|
-
// 测试 4: 调用链分析
|
|
46
|
-
console.log('【测试4】调用链分析');
|
|
47
|
-
const callAnalyzer = new CallStackAnalyzer();
|
|
48
|
-
const entryPoints = callAnalyzer.findEntryPoints(obfuscatedCode);
|
|
49
|
-
console.log('入口点:', entryPoints.length);
|
|
50
|
-
entryPoints.forEach(e => console.log(' -', e.type, e.name || ''));
|
|
51
|
-
|
|
52
|
-
const callGraph = callAnalyzer.buildCallGraph(obfuscatedCode);
|
|
53
|
-
console.log('调用图节点数:', callGraph.size);
|
|
54
|
-
console.log('');
|
|
55
|
-
|
|
56
|
-
// 测试 5: 加密分析
|
|
57
|
-
console.log('【测试5】加密分析');
|
|
58
|
-
const encAnalyzer = new EncryptionAnalyzer();
|
|
59
|
-
const cryptoResult = encAnalyzer.analyze(obfuscatedCode);
|
|
60
|
-
console.log('检测到算法:', cryptoResult.detectedAlgorithms.map(a => a.name));
|
|
61
|
-
console.log('可疑函数:', cryptoResult.suspiciousFunctions.length);
|
|
62
|
-
console.log('');
|
|
63
|
-
|
|
64
|
-
// 测试 6: 字符串提取
|
|
65
|
-
console.log('【测试6】字符串提取');
|
|
66
|
-
const strings = astAnalyzer.extractStrings(obfuscatedCode);
|
|
67
|
-
console.log('字符串数量:', strings.length);
|
|
68
|
-
const keyStrings = strings.filter(s =>
|
|
69
|
-
s.value.includes('key') ||
|
|
70
|
-
s.value.includes('sign') ||
|
|
71
|
-
s.value.includes('app')
|
|
72
|
-
);
|
|
73
|
-
console.log('关键字符串:', keyStrings.map(s => s.value));
|
|
74
|
-
console.log('');
|
|
75
|
-
|
|
76
|
-
// 测试 7: 沙箱执行
|
|
77
|
-
console.log('【测试7】沙箱执行');
|
|
78
|
-
const sandbox = new Sandbox();
|
|
79
|
-
|
|
80
|
-
const execResult = await sandbox.execute(obfuscatedCode);
|
|
81
|
-
console.log('执行成功:', execResult.success);
|
|
82
|
-
if (execResult.success) {
|
|
83
|
-
console.log('执行结果:', execResult.result);
|
|
84
|
-
} else {
|
|
85
|
-
console.log('错误:', execResult.error);
|
|
86
|
-
console.log('错误类型:', execResult.errorType);
|
|
87
|
-
console.log('缺失环境:', execResult.missingEnv);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log('\n=== 测试完成 ===');
|
package/test/envdump.test.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 环境自吐功能测试
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { generateEnvDumpCode, generateBaseEnvCode } from '../src/agent/tools/envdump.js';
|
|
6
|
-
import { sandboxExecute, sandboxInject, sandboxReset } from '../src/agent/tools/sandbox.js';
|
|
7
|
-
|
|
8
|
-
async function test() {
|
|
9
|
-
console.log('=== 环境自吐测试 ===\n');
|
|
10
|
-
|
|
11
|
-
// 1. 生成基础环境代码
|
|
12
|
-
console.log('【Step 1】生成基础环境');
|
|
13
|
-
const baseResult = JSON.parse(await generateBaseEnvCode.invoke({}));
|
|
14
|
-
console.log('基础环境代码长度:', baseResult.code.length, '字符\n');
|
|
15
|
-
|
|
16
|
-
// 2. 生成环境自吐代码
|
|
17
|
-
console.log('【Step 2】生成环境自吐代码');
|
|
18
|
-
const dumpResult = JSON.parse(await generateEnvDumpCode.invoke({
|
|
19
|
-
targets: ['window', 'document', 'navigator'],
|
|
20
|
-
enableCallStack: false,
|
|
21
|
-
maxValueLength: 50,
|
|
22
|
-
}));
|
|
23
|
-
console.log('自吐代码长度:', dumpResult.code.length, '字符\n');
|
|
24
|
-
|
|
25
|
-
// 3. 注入基础环境
|
|
26
|
-
console.log('【Step 3】注入基础环境');
|
|
27
|
-
await sandboxReset.invoke({});
|
|
28
|
-
const injectBase = JSON.parse(await sandboxInject.invoke({ code: baseResult.code }));
|
|
29
|
-
console.log('注入结果:', injectBase.success ? '✅' : '❌', '\n');
|
|
30
|
-
|
|
31
|
-
// 4. 注入自吐代码
|
|
32
|
-
console.log('【Step 4】注入自吐代码');
|
|
33
|
-
const injectDump = JSON.parse(await sandboxInject.invoke({ code: dumpResult.code }));
|
|
34
|
-
console.log('注入结果:', injectDump.success ? '✅' : '❌', '\n');
|
|
35
|
-
|
|
36
|
-
// 5. 执行测试代码
|
|
37
|
-
console.log('【Step 5】执行测试代码');
|
|
38
|
-
const testCode = `
|
|
39
|
-
// 模拟目标代码访问环境
|
|
40
|
-
var ua = navigator.userAgent;
|
|
41
|
-
var platform = navigator.platform;
|
|
42
|
-
var cookie = document.cookie;
|
|
43
|
-
document.createElement('div');
|
|
44
|
-
window.innerWidth;
|
|
45
|
-
|
|
46
|
-
// 获取日志
|
|
47
|
-
__deepspider__.getLogs('env');
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
const execResult = JSON.parse(await sandboxExecute.invoke({ code: testCode, timeout: 3000 }));
|
|
51
|
-
console.log('执行结果:', execResult.success ? '✅' : '❌');
|
|
52
|
-
|
|
53
|
-
if (execResult.success && execResult.result) {
|
|
54
|
-
console.log('\n【环境访问日志】');
|
|
55
|
-
try {
|
|
56
|
-
const logs = JSON.parse(execResult.result);
|
|
57
|
-
console.log('记录条数:', logs.length);
|
|
58
|
-
logs.slice(0, 10).forEach((log, i) => {
|
|
59
|
-
console.log(` ${i + 1}. [${log.type}] ${log.path}`);
|
|
60
|
-
});
|
|
61
|
-
if (logs.length > 10) {
|
|
62
|
-
console.log(` ... 还有 ${logs.length - 10} 条`);
|
|
63
|
-
}
|
|
64
|
-
} catch (e) {
|
|
65
|
-
console.log('日志解析失败:', e.message);
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
console.log('错误:', execResult.error);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
console.log('\n=== 测试完成 ===');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
test().catch(console.error);
|
package/test/flow.test.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DeepSpider 完整流程测试 - 单样本深度分析
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { ASTAnalyzer } from '../src/analyzer/ASTAnalyzer.js';
|
|
6
|
-
import { CallStackAnalyzer } from '../src/analyzer/CallStackAnalyzer.js';
|
|
7
|
-
import { EncryptionAnalyzer } from '../src/analyzer/EncryptionAnalyzer.js';
|
|
8
|
-
import { Deobfuscator } from '../src/analyzer/Deobfuscator.js';
|
|
9
|
-
import { Sandbox } from '../src/core/Sandbox.js';
|
|
10
|
-
import { Store } from '../src/store/Store.js';
|
|
11
|
-
import fs from 'fs';
|
|
12
|
-
import path from 'path';
|
|
13
|
-
import { fileURLToPath } from 'url';
|
|
14
|
-
|
|
15
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
-
|
|
17
|
-
// 选择 v2_ob_advanced.js 进行深度分析
|
|
18
|
-
const code = fs.readFileSync(
|
|
19
|
-
path.join(__dirname, 'samples/v2_ob_advanced.js'),
|
|
20
|
-
'utf-8'
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
console.log('=== DeepSpider 完整流程测试 ===\n');
|
|
24
|
-
console.log('目标: v2_ob_advanced.js\n');
|
|
25
|
-
|
|
26
|
-
// Step 1: 混淆识别
|
|
27
|
-
console.log('【Step 1】混淆识别');
|
|
28
|
-
const deob = new Deobfuscator();
|
|
29
|
-
console.log(' 混淆器:', deob.detectObfuscator(code));
|
|
30
|
-
console.log(' 类型:', deob._detectType(code));
|
|
31
|
-
|
|
32
|
-
// Step 2: 反混淆
|
|
33
|
-
console.log('\n【Step 2】反混淆流水线');
|
|
34
|
-
const deobResult = deob.runPipeline(code);
|
|
35
|
-
console.log(' 应用步骤:', deobResult.applied.join(' → '));
|
|
36
|
-
console.log(' 代码压缩:', code.length, '→', deobResult.code.length);
|
|
37
|
-
|
|
38
|
-
// Step 3: AST 分析
|
|
39
|
-
console.log('\n【Step 3】AST 分析');
|
|
40
|
-
const ast = new ASTAnalyzer();
|
|
41
|
-
const funcs = ast.extractFunctions(code);
|
|
42
|
-
console.log(' 函数列表:');
|
|
43
|
-
funcs.forEach(f => console.log(` - ${f.name}(${f.params.join(', ')})`));
|
|
44
|
-
|
|
45
|
-
// Step 4: 调用链分析
|
|
46
|
-
console.log('\n【Step 4】调用链分析');
|
|
47
|
-
const call = new CallStackAnalyzer();
|
|
48
|
-
const graph = call.buildCallGraph(code);
|
|
49
|
-
console.log(' 调用图:');
|
|
50
|
-
for (const [func, calls] of graph) {
|
|
51
|
-
if (calls.length > 0) {
|
|
52
|
-
console.log(` ${func} → ${calls.map(c => c.callee).join(', ')}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Step 5: 加密分析
|
|
57
|
-
console.log('\n【Step 5】加密分析');
|
|
58
|
-
const enc = new EncryptionAnalyzer();
|
|
59
|
-
const crypto = enc.analyze(code);
|
|
60
|
-
console.log(' 检测算法:', crypto.detectedAlgorithms.map(a => a.name).join(', ') || '无');
|
|
61
|
-
console.log(' 可疑函数:', crypto.suspiciousFunctions.length);
|
|
62
|
-
|
|
63
|
-
// Step 6: 字符串提取
|
|
64
|
-
console.log('\n【Step 6】字符串提取');
|
|
65
|
-
const strings = ast.extractStrings(code);
|
|
66
|
-
const keywords = strings.filter(s =>
|
|
67
|
-
/sign|key|secret|app|encrypt/i.test(s.value)
|
|
68
|
-
);
|
|
69
|
-
console.log(' 总字符串:', strings.length);
|
|
70
|
-
console.log(' 关键字符串:', keywords.map(s => `"${s.value}"`).join(', '));
|
|
71
|
-
|
|
72
|
-
// Step 7: 沙箱执行
|
|
73
|
-
console.log('\n【Step 7】沙箱执行');
|
|
74
|
-
const sandbox = new Sandbox();
|
|
75
|
-
const result = await sandbox.execute(code, { timeout: 5000 });
|
|
76
|
-
console.log(' 执行状态:', result.success ? '✅ 成功' : '❌ 失败');
|
|
77
|
-
console.log(' 结果:', result.result);
|
|
78
|
-
|
|
79
|
-
// Step 8: 存储结果
|
|
80
|
-
console.log('\n【Step 8】存储分析结果');
|
|
81
|
-
const store = new Store();
|
|
82
|
-
store.save('analysis', 'v2_ob_advanced', {
|
|
83
|
-
obfuscator: deob.detectObfuscator(code),
|
|
84
|
-
functions: funcs.length,
|
|
85
|
-
crypto: crypto.detectedAlgorithms.map(a => a.name),
|
|
86
|
-
executed: result.success
|
|
87
|
-
});
|
|
88
|
-
console.log(' 已保存到 Store');
|
|
89
|
-
|
|
90
|
-
console.log('\n=== 流程测试完成 ===');
|
package/test/hooks.test.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DeepSpider Hook 系统测试
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { HookBase } from '../src/env/HookBase.js';
|
|
6
|
-
import { getDefaultHookScript } from '../src/browser/defaultHooks.js';
|
|
7
|
-
|
|
8
|
-
console.log('=== DeepSpider Hook 系统测试 ===\n');
|
|
9
|
-
|
|
10
|
-
// 测试 1: HookBase 代码生成
|
|
11
|
-
console.log('【测试1】HookBase 代码生成');
|
|
12
|
-
const baseCode = HookBase.getBaseCode();
|
|
13
|
-
console.log('基础代码长度:', baseCode.length);
|
|
14
|
-
console.log('包含 __deepspider__:', baseCode.includes('window.__deepspider__'));
|
|
15
|
-
console.log('包含日志限制:', baseCode.includes('LOG_LIMIT'));
|
|
16
|
-
console.log('包含配置管理:', baseCode.includes('getConfig'));
|
|
17
|
-
console.log('');
|
|
18
|
-
|
|
19
|
-
// 测试 2: 完整 Hook 脚本生成
|
|
20
|
-
console.log('【测试2】完整 Hook 脚本生成');
|
|
21
|
-
const fullScript = getDefaultHookScript();
|
|
22
|
-
console.log('完整脚本长度:', fullScript.length);
|
|
23
|
-
console.log('包含 XHR Hook:', fullScript.includes('XHR Hook'));
|
|
24
|
-
console.log('包含 Fetch Hook:', fullScript.includes('Fetch Hook'));
|
|
25
|
-
console.log('包含 Cookie Hook:', fullScript.includes('Cookie Hook'));
|
|
26
|
-
console.log('包含 JSON Hook:', fullScript.includes('JSON Hook'));
|
|
27
|
-
console.log('包含 Eval Hook:', fullScript.includes('Eval/Function Hook'));
|
|
28
|
-
console.log('包含 Crypto Hook:', fullScript.includes('Crypto Hook'));
|
|
29
|
-
console.log('包含 DOM Hook:', fullScript.includes('DOM Hook'));
|
|
30
|
-
console.log('包含 Debugger Bypass:', fullScript.includes('debugger bypassed'));
|
|
31
|
-
console.log('包含 Encoding Hook:', fullScript.includes('Encoding Hook'));
|
|
32
|
-
console.log('包含 Storage Hook:', fullScript.includes('Storage Hook'));
|
|
33
|
-
console.log('包含 WebSocket Hook:', fullScript.includes('WebSocket Hook'));
|
|
34
|
-
console.log('包含 Web Crypto API:', fullScript.includes('WebCrypto'));
|
|
35
|
-
console.log('包含 Canvas Hook:', fullScript.includes('Canvas Hook'));
|
|
36
|
-
console.log('包含 Navigator Hook:', fullScript.includes('Navigator Hook'));
|
|
37
|
-
console.log('包含 Webpack Hook:', fullScript.includes('Webpack Hook'));
|
|
38
|
-
console.log('包含 Forge Hook:', fullScript.includes('Forge Hook'));
|
|
39
|
-
console.log('包含 jsrsasign Hook:', fullScript.includes('jsrsasign Hook'));
|
|
40
|
-
console.log('包含 Proxy Hook:', fullScript.includes('Proxy Hook'));
|
|
41
|
-
console.log('包含 Error Stack Hook:', fullScript.includes('Error Stack Hook'));
|
|
42
|
-
console.log('');
|
|
43
|
-
|
|
44
|
-
// 测试 6: 验证新增 API
|
|
45
|
-
console.log('【测试6】验证新增 API');
|
|
46
|
-
const newAPIs = [
|
|
47
|
-
'searchLogs',
|
|
48
|
-
'traceValue',
|
|
49
|
-
'correlateParams',
|
|
50
|
-
'getRecentCrypto',
|
|
51
|
-
'getRecentRequests',
|
|
52
|
-
'exportLogs',
|
|
53
|
-
'recordPerf',
|
|
54
|
-
'getPerf',
|
|
55
|
-
'getCaller'
|
|
56
|
-
];
|
|
57
|
-
newAPIs.forEach(api => {
|
|
58
|
-
const found = fullScript.includes(api);
|
|
59
|
-
console.log(` ${found ? '✓' : '✗'} ${api}`);
|
|
60
|
-
});
|
|
61
|
-
console.log('');
|
|
62
|
-
|
|
63
|
-
// 测试 3: 验证 Hook 代码语法
|
|
64
|
-
console.log('【测试3】验证 Hook 代码语法');
|
|
65
|
-
try {
|
|
66
|
-
new Function(fullScript);
|
|
67
|
-
console.log('语法检查: 通过');
|
|
68
|
-
} catch (e) {
|
|
69
|
-
console.error('语法检查: 失败 -', e.message);
|
|
70
|
-
}
|
|
71
|
-
console.log('');
|
|
72
|
-
|
|
73
|
-
// 测试 4: 验证关键功能存在
|
|
74
|
-
console.log('【测试4】验证关键功能');
|
|
75
|
-
const features = [
|
|
76
|
-
{ name: 'JSON.parse Hook', pattern: /JSON\.parse\s*=\s*deepspider\.native/ },
|
|
77
|
-
{ name: 'JSON.stringify Hook', pattern: /JSON\.stringify\s*=\s*deepspider\.native/ },
|
|
78
|
-
{ name: 'eval Hook', pattern: /window\.eval\s*=\s*deepspider\.native/ },
|
|
79
|
-
{ name: 'Function Hook', pattern: /window\.Function\s*=\s*deepspider\.native/ },
|
|
80
|
-
{ name: 'setTimeout 字符串检测', pattern: /typeof handler === 'string'/ },
|
|
81
|
-
{ name: 'CryptoJS 即时 Hook', pattern: /watchGlobal\('CryptoJS'/ },
|
|
82
|
-
{ name: 'DOM querySelector Hook', pattern: /m\.obj\[m\.name\]\s*=\s*deepspider\.native/ },
|
|
83
|
-
{ name: 'debugger 绕过', pattern: /debugger bypassed/ },
|
|
84
|
-
{ name: '日志限制', pattern: /logCounts\[countKey\].*config\.logLimit/ },
|
|
85
|
-
];
|
|
86
|
-
|
|
87
|
-
features.forEach(f => {
|
|
88
|
-
const found = f.pattern.test(fullScript);
|
|
89
|
-
console.log(` ${found ? '✓' : '✗'} ${f.name}`);
|
|
90
|
-
});
|
|
91
|
-
console.log('');
|
|
92
|
-
|
|
93
|
-
// 测试 5: 验证配置项
|
|
94
|
-
console.log('【测试5】验证配置项');
|
|
95
|
-
const configItems = [
|
|
96
|
-
'json', 'eval', 'crypto', 'cookie', 'xhr', 'fetch', 'dom', 'logLimit',
|
|
97
|
-
'captureStack', 'stackDepth', 'protectDescriptor', 'protectKeys',
|
|
98
|
-
'silent', 'logToConsole'
|
|
99
|
-
];
|
|
100
|
-
configItems.forEach(item => {
|
|
101
|
-
const found = fullScript.includes(`${item}:`);
|
|
102
|
-
console.log(` ${found ? '✓' : '✗'} config.${item}`);
|
|
103
|
-
});
|
|
104
|
-
console.log('');
|
|
105
|
-
|
|
106
|
-
// 测试 7: 验证反检测功能
|
|
107
|
-
console.log('【测试7】验证反检测功能');
|
|
108
|
-
const antiDetectFeatures = [
|
|
109
|
-
{ name: 'toString 伪装', pattern: /hookedFns\.has\(this\)/ },
|
|
110
|
-
{ name: 'getOwnPropertyDescriptor 保护', pattern: /Object\.getOwnPropertyDescriptor\s*=\s*function/ },
|
|
111
|
-
{ name: 'Object.keys 保护', pattern: /Object\.keys\s*=\s*function/ },
|
|
112
|
-
{ name: 'getOwnPropertyNames 保护', pattern: /Object\.getOwnPropertyNames\s*=\s*function/ },
|
|
113
|
-
{ name: 'Error.stack 过滤', pattern: /__deepspider__|DeepSpider|deepspider\\.native/ },
|
|
114
|
-
{ name: 'Proxy 监控', pattern: /Proxy\.create/ },
|
|
115
|
-
];
|
|
116
|
-
antiDetectFeatures.forEach(f => {
|
|
117
|
-
const found = f.pattern.test(fullScript);
|
|
118
|
-
console.log(` ${found ? '✓' : '✗'} ${f.name}`);
|
|
119
|
-
});
|
|
120
|
-
console.log('');
|
|
121
|
-
|
|
122
|
-
// 测试 8: 验证 Hook 管理 API
|
|
123
|
-
console.log('【测试8】验证 Hook 管理 API');
|
|
124
|
-
const hookMgmtAPIs = [
|
|
125
|
-
'registerHook',
|
|
126
|
-
'enableHook',
|
|
127
|
-
'disableHook',
|
|
128
|
-
'listHooks',
|
|
129
|
-
'injectHook',
|
|
130
|
-
'setHooks'
|
|
131
|
-
];
|
|
132
|
-
hookMgmtAPIs.forEach(api => {
|
|
133
|
-
const found = fullScript.includes(api);
|
|
134
|
-
console.log(` ${found ? '✓' : '✗'} ${api}`);
|
|
135
|
-
});
|
|
136
|
-
console.log('');
|
|
137
|
-
|
|
138
|
-
console.log('=== Hook 系统测试完成 ===');
|
package/test/plugin.test.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin 可用性测试
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { allTools } from '../src/agent/tools/index.js';
|
|
6
|
-
|
|
7
|
-
console.log('=== Plugin 工具验证 ===\n');
|
|
8
|
-
|
|
9
|
-
console.log('【工具数量】', allTools.length, '个\n');
|
|
10
|
-
|
|
11
|
-
// 验证每个工具
|
|
12
|
-
let valid = 0;
|
|
13
|
-
let invalid = 0;
|
|
14
|
-
|
|
15
|
-
for (const tool of allTools) {
|
|
16
|
-
const hasName = !!tool.name;
|
|
17
|
-
const hasDesc = !!tool.description;
|
|
18
|
-
const hasSchema = !!tool.schema;
|
|
19
|
-
|
|
20
|
-
if (hasName && hasDesc && hasSchema) {
|
|
21
|
-
valid++;
|
|
22
|
-
} else {
|
|
23
|
-
invalid++;
|
|
24
|
-
console.log('❌', tool.name || 'unknown', '- 缺少必要属性');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
console.log(`\n验证结果: ${valid} 个有效, ${invalid} 个无效`);
|
|
29
|
-
|
|
30
|
-
if (invalid === 0) {
|
|
31
|
-
console.log('\n✅ 所有工具验证通过!');
|
|
32
|
-
} else {
|
|
33
|
-
console.log('\n❌ 存在无效工具');
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DeepSpider 完整重构测试
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { allTools } from '../src/agent/tools/index.js';
|
|
6
|
-
import { allSubagents } from '../src/agent/subagents/index.js';
|
|
7
|
-
|
|
8
|
-
async function testTools() {
|
|
9
|
-
console.log('=== 测试工具导入 ===');
|
|
10
|
-
console.log('工具数量:', allTools.length);
|
|
11
|
-
console.log('工具列表:', allTools.map(t => t.name).join(', '));
|
|
12
|
-
console.log('');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function testSubagents() {
|
|
16
|
-
console.log('=== 测试子代理 ===');
|
|
17
|
-
console.log('子代理数量:', allSubagents.length);
|
|
18
|
-
allSubagents.forEach(s => {
|
|
19
|
-
console.log(`- ${s.name}: ${s.tools?.length || 0} 个工具`);
|
|
20
|
-
});
|
|
21
|
-
console.log('');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function main() {
|
|
25
|
-
await testTools();
|
|
26
|
-
await testSubagents();
|
|
27
|
-
console.log('完整重构测试通过!');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
main().catch(console.error);
|
package/test/refactor.test.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DeepSpider 重构测试
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Store } from '../src/store/Store.js';
|
|
6
|
-
|
|
7
|
-
async function testStore() {
|
|
8
|
-
console.log('=== 测试知识库 ===');
|
|
9
|
-
const store = new Store();
|
|
10
|
-
store.save('env', 'navigator', { code: 'test' });
|
|
11
|
-
const result = store.get('env', 'navigator');
|
|
12
|
-
console.log('存储成功:', result !== undefined);
|
|
13
|
-
console.log('知识库测试通过!\n');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function main() {
|
|
17
|
-
await testStore();
|
|
18
|
-
console.log('重构基础测试通过!');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
main().catch(console.error);
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 模拟 obfuscator.io 混淆后的代码
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
var _0x3a8f = ['deepspider_test_2024', 'app_12345', 'charCodeAt', 'length', 'toString', 'floor', 'random', 'charAt', 'stringify', 'log', 'Result:', 'user', 'test', 'action', 'login', 'sign', 'timestamp', 'nonce', 'app_id', 'encrypted', 'abcdef0123456789'];
|
|
6
|
-
|
|
7
|
-
var _0x5c2d = function(_0x2a1b, _0x3c4e) {
|
|
8
|
-
return _0x3a8f[_0x2a1b - 0x100];
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
var _0x1a2b = _0x5c2d(0x100);
|
|
12
|
-
var _0x2b3c = _0x5c2d(0x101);
|
|
13
|
-
|
|
14
|
-
function _0x4d5e(_0x6f7a) {
|
|
15
|
-
var _0x8b9c = 0x0;
|
|
16
|
-
for (var _0xad0e = 0x0; _0xad0e < _0x6f7a[_0x5c2d(0x103)]; _0xad0e++) {
|
|
17
|
-
var _0xcf1a = _0x6f7a[_0x5c2d(0x102)](_0xad0e);
|
|
18
|
-
_0x8b9c = ((_0x8b9c << 0x5) - _0x8b9c) + _0xcf1a;
|
|
19
|
-
_0x8b9c = _0x8b9c & _0x8b9c;
|
|
20
|
-
}
|
|
21
|
-
return Math['abs'](_0x8b9c)[_0x5c2d(0x104)](0x10);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function _0xe1f2() {
|
|
25
|
-
return Math[_0x5c2d(0x105)](Date['now']() / 0x3e8);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _0x2345(_0x6789) {
|
|
29
|
-
var _0xabcd = _0x5c2d(0x114);
|
|
30
|
-
var _0xef01 = '';
|
|
31
|
-
for (var _0x2345 = 0x0; _0x2345 < _0x6789; _0x2345++) {
|
|
32
|
-
_0xef01 += _0xabcd[_0x5c2d(0x107)](Math[_0x5c2d(0x105)](Math[_0x5c2d(0x106)]() * _0xabcd[_0x5c2d(0x103)]));
|
|
33
|
-
}
|
|
34
|
-
return _0xef01;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function _0x5678(_0x9abc) {
|
|
38
|
-
var _0xdef0 = _0xe1f2();
|
|
39
|
-
var _0x1234 = _0x2345(0x8);
|
|
40
|
-
var _0x5678 = _0x2b3c + _0xdef0 + _0x1234 + _0x1a2b;
|
|
41
|
-
var _0x9abc = _0x4d5e(_0x5678);
|
|
42
|
-
var _0xdef1 = {};
|
|
43
|
-
_0xdef1[_0x5c2d(0x10f)] = _0x9abc;
|
|
44
|
-
_0xdef1[_0x5c2d(0x110)] = _0xdef0;
|
|
45
|
-
_0xdef1[_0x5c2d(0x111)] = _0x1234;
|
|
46
|
-
_0xdef1[_0x5c2d(0x112)] = _0x2b3c;
|
|
47
|
-
return _0xdef1;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _0xbcde(_0xf012) {
|
|
51
|
-
var _0x3456 = _0x5678(_0xf012);
|
|
52
|
-
var _0x789a = {};
|
|
53
|
-
for (var _0xkey in _0xf012) { _0x789a[_0xkey] = _0xf012[_0xkey]; }
|
|
54
|
-
for (var _0xkey in _0x3456) { _0x789a[_0xkey] = _0x3456[_0xkey]; }
|
|
55
|
-
_0x789a[_0x5c2d(0x113)] = btoa(JSON[_0x5c2d(0x108)](_0xf012));
|
|
56
|
-
return _0x789a;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
var _0xresult = _0xbcde({ '\x75\x73\x65\x72': '\x74\x65\x73\x74', '\x61\x63\x74\x69\x6f\x6e': '\x6c\x6f\x67\x69\x6e' });
|
|
60
|
-
console[_0x5c2d(0x109)](_0x5c2d(0x10a), _0xresult);
|
|
61
|
-
_0xresult;
|
package/test/samples/original.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 模拟一个签名生成函数
|
|
3
|
-
* 常见于网站反爬虫场景
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// 密钥配置
|
|
7
|
-
const SECRET_KEY = 'deepspider_test_2024';
|
|
8
|
-
const APP_ID = 'app_12345';
|
|
9
|
-
|
|
10
|
-
// 简单的哈希函数
|
|
11
|
-
function simpleHash(str) {
|
|
12
|
-
let hash = 0;
|
|
13
|
-
for (let i = 0; i < str.length; i++) {
|
|
14
|
-
const char = str.charCodeAt(i);
|
|
15
|
-
hash = ((hash << 5) - hash) + char;
|
|
16
|
-
hash = hash & hash;
|
|
17
|
-
}
|
|
18
|
-
return Math.abs(hash).toString(16);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// 时间戳生成
|
|
22
|
-
function getTimestamp() {
|
|
23
|
-
return Math.floor(Date.now() / 1000);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// 随机数生成
|
|
27
|
-
function randomString(len) {
|
|
28
|
-
const chars = 'abcdef0123456789';
|
|
29
|
-
let result = '';
|
|
30
|
-
for (let i = 0; i < len; i++) {
|
|
31
|
-
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// 签名生成核心函数
|
|
37
|
-
function generateSign(params) {
|
|
38
|
-
const timestamp = getTimestamp();
|
|
39
|
-
const nonce = randomString(8);
|
|
40
|
-
|
|
41
|
-
// 拼接签名字符串
|
|
42
|
-
const signStr = APP_ID + timestamp + nonce + SECRET_KEY;
|
|
43
|
-
const sign = simpleHash(signStr);
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
sign: sign,
|
|
47
|
-
timestamp: timestamp,
|
|
48
|
-
nonce: nonce,
|
|
49
|
-
app_id: APP_ID
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// 加密请求参数
|
|
54
|
-
function encryptParams(data) {
|
|
55
|
-
const signData = generateSign(data);
|
|
56
|
-
return {
|
|
57
|
-
...data,
|
|
58
|
-
...signData,
|
|
59
|
-
encrypted: btoa(JSON.stringify(data))
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// 导出
|
|
64
|
-
const result = encryptParams({ user: 'test', action: 'login' });
|
|
65
|
-
console.log('Result:', result);
|
|
66
|
-
result;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* v10: 多层eval嵌套加密
|
|
3
|
-
* 技术: 多层Base64/Hex编码 + eval执行
|
|
4
|
-
* 特点: 需要多次解码才能获取原始代码
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
(function() {
|
|
8
|
-
var _d = function(s) { return atob(s); };
|
|
9
|
-
var _h = function(s) {
|
|
10
|
-
var r = '';
|
|
11
|
-
for (var i = 0; i < s.length; i += 2) {
|
|
12
|
-
r += String.fromCharCode(parseInt(s.substr(i, 2), 16));
|
|
13
|
-
}
|
|
14
|
-
return r;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// 第一层: Base64编码的代码
|
|
18
|
-
var _l1 = 'dmFyIFNFQ1JFVCA9ICdqc2ZvcmdlX3Rlc3RfMjAyNCc7';
|
|
19
|
-
var _l2 = 'dmFyIEFQUElEID0gJ2FwcF8xMjM0NSc7';
|
|
20
|
-
|
|
21
|
-
// 解码并执行
|
|
22
|
-
eval(_d(_l1));
|
|
23
|
-
eval(_d(_l2));
|
|
24
|
-
|
|
25
|
-
// 核心函数
|
|
26
|
-
var hash = function(s) {
|
|
27
|
-
var h = 0;
|
|
28
|
-
for (var i = 0; i < s.length; i++) {
|
|
29
|
-
h = ((h << 5) - h) + s.charCodeAt(i);
|
|
30
|
-
h = h & h;
|
|
31
|
-
}
|
|
32
|
-
return Math.abs(h).toString(16);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var ts = Math.floor(Date.now() / 1000);
|
|
36
|
-
var c = 'abcdef0123456789', nonce = '';
|
|
37
|
-
for (var i = 0; i < 8; i++) nonce += c.charAt(Math.floor(Math.random() * c.length));
|
|
38
|
-
|
|
39
|
-
var signStr = APPID + ts + nonce + SECRET;
|
|
40
|
-
var data = { user: 'test', action: 'login' };
|
|
41
|
-
|
|
42
|
-
var result = Object.assign({}, data, {
|
|
43
|
-
sign: hash(signStr),
|
|
44
|
-
timestamp: ts,
|
|
45
|
-
nonce: nonce,
|
|
46
|
-
app_id: APPID,
|
|
47
|
-
encrypted: btoa(JSON.stringify(data))
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
console.log('Result:', result);
|
|
51
|
-
return result;
|
|
52
|
-
})();
|