windows-exe-decompiler-mcp-server 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/CODEX_INSTALLATION.md +69 -0
- package/COPILOT_INSTALLATION.md +77 -0
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/bin/windows-exe-decompiler-mcp-server.js +3 -0
- package/dist/analysis-provenance.d.ts +184 -0
- package/dist/analysis-provenance.js +74 -0
- package/dist/analysis-task-runner.d.ts +31 -0
- package/dist/analysis-task-runner.js +160 -0
- package/dist/artifact-inventory.d.ts +23 -0
- package/dist/artifact-inventory.js +175 -0
- package/dist/cache-manager.d.ts +128 -0
- package/dist/cache-manager.js +454 -0
- package/dist/confidence-semantics.d.ts +66 -0
- package/dist/confidence-semantics.js +122 -0
- package/dist/config.d.ts +335 -0
- package/dist/config.js +193 -0
- package/dist/database.d.ts +227 -0
- package/dist/database.js +601 -0
- package/dist/decompiler-worker.d.ts +441 -0
- package/dist/decompiler-worker.js +1962 -0
- package/dist/dynamic-trace.d.ts +95 -0
- package/dist/dynamic-trace.js +629 -0
- package/dist/env-validator.d.ts +15 -0
- package/dist/env-validator.js +249 -0
- package/dist/error-handler.d.ts +28 -0
- package/dist/error-handler.example.d.ts +22 -0
- package/dist/error-handler.example.js +141 -0
- package/dist/error-handler.js +139 -0
- package/dist/ghidra-analysis-status.d.ts +49 -0
- package/dist/ghidra-analysis-status.js +178 -0
- package/dist/ghidra-config.d.ts +134 -0
- package/dist/ghidra-config.js +464 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +200 -0
- package/dist/job-queue.d.ts +169 -0
- package/dist/job-queue.js +407 -0
- package/dist/logger.d.ts +106 -0
- package/dist/logger.js +176 -0
- package/dist/policy-guard.d.ts +115 -0
- package/dist/policy-guard.js +243 -0
- package/dist/process-output.d.ts +15 -0
- package/dist/process-output.js +90 -0
- package/dist/prompts/function-explanation-review.d.ts +5 -0
- package/dist/prompts/function-explanation-review.js +64 -0
- package/dist/prompts/semantic-name-review.d.ts +5 -0
- package/dist/prompts/semantic-name-review.js +63 -0
- package/dist/runtime-correlation.d.ts +34 -0
- package/dist/runtime-correlation.js +279 -0
- package/dist/runtime-paths.d.ts +3 -0
- package/dist/runtime-paths.js +11 -0
- package/dist/selection-diff.d.ts +667 -0
- package/dist/selection-diff.js +53 -0
- package/dist/semantic-name-suggestion-artifacts.d.ts +116 -0
- package/dist/semantic-name-suggestion-artifacts.js +314 -0
- package/dist/server.d.ts +129 -0
- package/dist/server.js +578 -0
- package/dist/tools/artifact-read.d.ts +235 -0
- package/dist/tools/artifact-read.js +317 -0
- package/dist/tools/artifacts-diff.d.ts +728 -0
- package/dist/tools/artifacts-diff.js +304 -0
- package/dist/tools/artifacts-list.d.ts +515 -0
- package/dist/tools/artifacts-list.js +389 -0
- package/dist/tools/attack-map.d.ts +290 -0
- package/dist/tools/attack-map.js +519 -0
- package/dist/tools/cache-observability.d.ts +4 -0
- package/dist/tools/cache-observability.js +36 -0
- package/dist/tools/code-function-cfg.d.ts +50 -0
- package/dist/tools/code-function-cfg.js +102 -0
- package/dist/tools/code-function-decompile.d.ts +55 -0
- package/dist/tools/code-function-decompile.js +103 -0
- package/dist/tools/code-function-disassemble.d.ts +43 -0
- package/dist/tools/code-function-disassemble.js +185 -0
- package/dist/tools/code-function-explain-apply.d.ts +255 -0
- package/dist/tools/code-function-explain-apply.js +225 -0
- package/dist/tools/code-function-explain-prepare.d.ts +535 -0
- package/dist/tools/code-function-explain-prepare.js +276 -0
- package/dist/tools/code-function-explain-review.d.ts +397 -0
- package/dist/tools/code-function-explain-review.js +589 -0
- package/dist/tools/code-function-rename-apply.d.ts +248 -0
- package/dist/tools/code-function-rename-apply.js +220 -0
- package/dist/tools/code-function-rename-prepare.d.ts +506 -0
- package/dist/tools/code-function-rename-prepare.js +279 -0
- package/dist/tools/code-function-rename-review.d.ts +574 -0
- package/dist/tools/code-function-rename-review.js +761 -0
- package/dist/tools/code-functions-list.d.ts +37 -0
- package/dist/tools/code-functions-list.js +91 -0
- package/dist/tools/code-functions-rank.d.ts +34 -0
- package/dist/tools/code-functions-rank.js +90 -0
- package/dist/tools/code-functions-reconstruct.d.ts +2725 -0
- package/dist/tools/code-functions-reconstruct.js +2807 -0
- package/dist/tools/code-functions-search.d.ts +39 -0
- package/dist/tools/code-functions-search.js +90 -0
- package/dist/tools/code-reconstruct-export.d.ts +1212 -0
- package/dist/tools/code-reconstruct-export.js +4002 -0
- package/dist/tools/code-reconstruct-plan.d.ts +274 -0
- package/dist/tools/code-reconstruct-plan.js +342 -0
- package/dist/tools/dotnet-metadata-extract.d.ts +541 -0
- package/dist/tools/dotnet-metadata-extract.js +355 -0
- package/dist/tools/dotnet-reconstruct-export.d.ts +567 -0
- package/dist/tools/dotnet-reconstruct-export.js +1151 -0
- package/dist/tools/dotnet-types-list.d.ts +325 -0
- package/dist/tools/dotnet-types-list.js +201 -0
- package/dist/tools/dynamic-dependencies.d.ts +115 -0
- package/dist/tools/dynamic-dependencies.js +213 -0
- package/dist/tools/dynamic-memory-import.d.ts +10 -0
- package/dist/tools/dynamic-memory-import.js +567 -0
- package/dist/tools/dynamic-trace-import.d.ts +10 -0
- package/dist/tools/dynamic-trace-import.js +235 -0
- package/dist/tools/entrypoint-fallback-disasm.d.ts +30 -0
- package/dist/tools/entrypoint-fallback-disasm.js +89 -0
- package/dist/tools/ghidra-analyze.d.ts +88 -0
- package/dist/tools/ghidra-analyze.js +208 -0
- package/dist/tools/ghidra-health.d.ts +37 -0
- package/dist/tools/ghidra-health.js +212 -0
- package/dist/tools/ioc-export.d.ts +209 -0
- package/dist/tools/ioc-export.js +542 -0
- package/dist/tools/packer-detect.d.ts +165 -0
- package/dist/tools/packer-detect.js +284 -0
- package/dist/tools/pe-exports-extract.d.ts +175 -0
- package/dist/tools/pe-exports-extract.js +253 -0
- package/dist/tools/pe-fingerprint.d.ts +234 -0
- package/dist/tools/pe-fingerprint.js +269 -0
- package/dist/tools/pe-imports-extract.d.ts +105 -0
- package/dist/tools/pe-imports-extract.js +245 -0
- package/dist/tools/report-generate.d.ts +157 -0
- package/dist/tools/report-generate.js +457 -0
- package/dist/tools/report-summarize.d.ts +2131 -0
- package/dist/tools/report-summarize.js +596 -0
- package/dist/tools/runtime-detect.d.ts +135 -0
- package/dist/tools/runtime-detect.js +247 -0
- package/dist/tools/sample-ingest.d.ts +94 -0
- package/dist/tools/sample-ingest.js +327 -0
- package/dist/tools/sample-profile-get.d.ts +183 -0
- package/dist/tools/sample-profile-get.js +121 -0
- package/dist/tools/sandbox-execute.d.ts +441 -0
- package/dist/tools/sandbox-execute.js +392 -0
- package/dist/tools/strings-extract.d.ts +375 -0
- package/dist/tools/strings-extract.js +314 -0
- package/dist/tools/strings-floss-decode.d.ts +143 -0
- package/dist/tools/strings-floss-decode.js +259 -0
- package/dist/tools/system-health.d.ts +434 -0
- package/dist/tools/system-health.js +446 -0
- package/dist/tools/task-cancel.d.ts +21 -0
- package/dist/tools/task-cancel.js +70 -0
- package/dist/tools/task-status.d.ts +27 -0
- package/dist/tools/task-status.js +106 -0
- package/dist/tools/task-sweep.d.ts +22 -0
- package/dist/tools/task-sweep.js +77 -0
- package/dist/tools/tool-help.d.ts +340 -0
- package/dist/tools/tool-help.js +261 -0
- package/dist/tools/yara-scan.d.ts +554 -0
- package/dist/tools/yara-scan.js +313 -0
- package/dist/types.d.ts +266 -0
- package/dist/types.js +41 -0
- package/dist/worker-pool.d.ts +204 -0
- package/dist/worker-pool.js +650 -0
- package/dist/workflows/deep-static.d.ts +104 -0
- package/dist/workflows/deep-static.js +276 -0
- package/dist/workflows/function-explanation-review.d.ts +655 -0
- package/dist/workflows/function-explanation-review.js +440 -0
- package/dist/workflows/reconstruct.d.ts +2053 -0
- package/dist/workflows/reconstruct.js +666 -0
- package/dist/workflows/semantic-name-review.d.ts +2418 -0
- package/dist/workflows/semantic-name-review.js +521 -0
- package/dist/workflows/triage.d.ts +659 -0
- package/dist/workflows/triage.js +1374 -0
- package/dist/workspace-manager.d.ts +150 -0
- package/dist/workspace-manager.js +411 -0
- package/ghidra_scripts/DecompileFunction.java +487 -0
- package/ghidra_scripts/DecompileFunction.py +150 -0
- package/ghidra_scripts/ExtractCFG.java +256 -0
- package/ghidra_scripts/ExtractCFG.py +233 -0
- package/ghidra_scripts/ExtractFunctions.java +442 -0
- package/ghidra_scripts/ExtractFunctions.py +101 -0
- package/ghidra_scripts/README.md +125 -0
- package/ghidra_scripts/SearchFunctionReferences.java +380 -0
- package/helpers/DotNetMetadataProbe/DotNetMetadataProbe.csproj +9 -0
- package/helpers/DotNetMetadataProbe/Program.cs +566 -0
- package/install-to-codex.ps1 +178 -0
- package/install-to-copilot.ps1 +303 -0
- package/package.json +101 -0
- package/requirements.txt +9 -0
- package/workers/requirements-dynamic.txt +11 -0
- package/workers/requirements.txt +8 -0
- package/workers/speakeasy_compat.py +175 -0
- package/workers/static_worker.py +5183 -0
- package/workers/yara_rules/default.yar +33 -0
- package/workers/yara_rules/malware_families.yar +93 -0
- package/workers/yara_rules/packers.yar +80 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packer.detect tool implementation
|
|
3
|
+
* Detects if a PE file is packed and identifies the packer used
|
|
4
|
+
* Requirements: 7.1, 7.2, 7.3
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { spawn } from 'child_process';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
10
|
+
import { generateCacheKey } from '../cache-manager.js';
|
|
11
|
+
import { resolvePackagePath } from '../runtime-paths.js';
|
|
12
|
+
import { lookupCachedResult, formatCacheWarning } from './cache-observability.js';
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Constants
|
|
15
|
+
// ============================================================================
|
|
16
|
+
/**
|
|
17
|
+
* Get the correct Python command for the current platform
|
|
18
|
+
*/
|
|
19
|
+
function getPythonCommand() {
|
|
20
|
+
return process.platform === 'win32' ? 'python' : 'python3';
|
|
21
|
+
}
|
|
22
|
+
const TOOL_NAME = 'packer.detect';
|
|
23
|
+
const TOOL_VERSION = '1.0.0';
|
|
24
|
+
const CACHE_TTL_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
|
|
25
|
+
const DEFAULT_ENGINES = ['yara', 'entropy', 'entrypoint'];
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Input/Output Schemas
|
|
28
|
+
// ============================================================================
|
|
29
|
+
/**
|
|
30
|
+
* Input schema for packer.detect tool
|
|
31
|
+
* Requirements: 7.1
|
|
32
|
+
*/
|
|
33
|
+
export const PackerDetectInputSchema = z.object({
|
|
34
|
+
sample_id: z.string().describe('Sample ID (format: sha256:<hex>)'),
|
|
35
|
+
engines: z.array(z.enum(['yara', 'entropy', 'entrypoint']))
|
|
36
|
+
.optional()
|
|
37
|
+
.default(['yara', 'entropy', 'entrypoint'])
|
|
38
|
+
.describe('Detection engines to use'),
|
|
39
|
+
force_refresh: z
|
|
40
|
+
.boolean()
|
|
41
|
+
.optional()
|
|
42
|
+
.default(false)
|
|
43
|
+
.describe('Bypass cache lookup and recompute from source sample'),
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Output schema for packer.detect tool
|
|
47
|
+
* Requirements: 7.1, 7.2, 7.3, 7.4, 7.5
|
|
48
|
+
*/
|
|
49
|
+
export const PackerDetectOutputSchema = z.object({
|
|
50
|
+
ok: z.boolean(),
|
|
51
|
+
data: z.object({
|
|
52
|
+
packed: z.boolean(),
|
|
53
|
+
confidence: z.number(),
|
|
54
|
+
detections: z.array(z.object({
|
|
55
|
+
method: z.string(),
|
|
56
|
+
name: z.string(),
|
|
57
|
+
confidence: z.number(),
|
|
58
|
+
details: z.record(z.any()),
|
|
59
|
+
})),
|
|
60
|
+
methods: z.array(z.string()),
|
|
61
|
+
confidence_breakdown: z.record(z.number()).optional(),
|
|
62
|
+
feature_fusion: z.record(z.any()).optional(),
|
|
63
|
+
evidence: z.record(z.any()).optional(),
|
|
64
|
+
inference: z.record(z.any()).optional(),
|
|
65
|
+
}).optional(),
|
|
66
|
+
warnings: z.array(z.string()).optional(),
|
|
67
|
+
errors: z.array(z.string()).optional(),
|
|
68
|
+
artifacts: z.array(z.any()).optional(),
|
|
69
|
+
metrics: z.object({
|
|
70
|
+
elapsed_ms: z.number(),
|
|
71
|
+
tool: z.string(),
|
|
72
|
+
engines_used: z.array(z.string()).optional(),
|
|
73
|
+
}).optional(),
|
|
74
|
+
});
|
|
75
|
+
function normalizeEngineList(engines, sort = true) {
|
|
76
|
+
const selected = engines && engines.length > 0 ? engines : DEFAULT_ENGINES;
|
|
77
|
+
const normalized = selected
|
|
78
|
+
.map((engine) => String(engine).toLowerCase().trim())
|
|
79
|
+
.filter((engine) => engine === 'yara' || engine === 'entropy' || engine === 'entrypoint');
|
|
80
|
+
const deduped = Array.from(new Set(normalized));
|
|
81
|
+
return sort ? deduped.sort() : deduped;
|
|
82
|
+
}
|
|
83
|
+
// ============================================================================
|
|
84
|
+
// Tool Definition
|
|
85
|
+
// ============================================================================
|
|
86
|
+
/**
|
|
87
|
+
* Tool definition for packer.detect
|
|
88
|
+
*/
|
|
89
|
+
export const packerDetectToolDefinition = {
|
|
90
|
+
name: TOOL_NAME,
|
|
91
|
+
description: '自动检测 PE 文件是否加壳,使用 YARA 规则、节区熵值分析和入口点检查来识别常见加壳器(如 UPX、Themida、VMProtect)',
|
|
92
|
+
inputSchema: PackerDetectInputSchema,
|
|
93
|
+
outputSchema: PackerDetectOutputSchema,
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Spawn Python Static Worker and communicate via stdin/stdout JSON protocol
|
|
97
|
+
*
|
|
98
|
+
* Requirements: Worker communication
|
|
99
|
+
*
|
|
100
|
+
* @param request - Worker request object
|
|
101
|
+
* @returns Worker response object
|
|
102
|
+
*/
|
|
103
|
+
async function callStaticWorker(request) {
|
|
104
|
+
return new Promise((resolve, reject) => {
|
|
105
|
+
// Get Python worker path
|
|
106
|
+
const workerPath = resolvePackagePath('workers', 'static_worker.py');
|
|
107
|
+
// Spawn Python process
|
|
108
|
+
const pythonProcess = spawn(getPythonCommand(), [workerPath], {
|
|
109
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
110
|
+
});
|
|
111
|
+
let stdout = '';
|
|
112
|
+
let stderr = '';
|
|
113
|
+
// Collect stdout
|
|
114
|
+
pythonProcess.stdout.on('data', (data) => {
|
|
115
|
+
stdout += data.toString();
|
|
116
|
+
});
|
|
117
|
+
// Collect stderr
|
|
118
|
+
pythonProcess.stderr.on('data', (data) => {
|
|
119
|
+
stderr += data.toString();
|
|
120
|
+
});
|
|
121
|
+
// Handle process exit
|
|
122
|
+
pythonProcess.on('close', (code) => {
|
|
123
|
+
if (code !== 0) {
|
|
124
|
+
reject(new Error(`Python worker exited with code ${code}. stderr: ${stderr}`));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
// Parse response from stdout
|
|
128
|
+
try {
|
|
129
|
+
const lines = stdout.trim().split('\n');
|
|
130
|
+
const lastLine = lines[lines.length - 1];
|
|
131
|
+
const response = JSON.parse(lastLine);
|
|
132
|
+
resolve(response);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
reject(new Error(`Failed to parse worker response: ${error.message}. stdout: ${stdout}`));
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
// Handle process error
|
|
139
|
+
pythonProcess.on('error', (error) => {
|
|
140
|
+
reject(new Error(`Failed to spawn Python worker: ${error.message}`));
|
|
141
|
+
});
|
|
142
|
+
// Send request to worker via stdin
|
|
143
|
+
try {
|
|
144
|
+
pythonProcess.stdin.write(JSON.stringify(request) + '\n');
|
|
145
|
+
pythonProcess.stdin.end();
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
reject(new Error(`Failed to write to worker stdin: ${error.message}`));
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// ============================================================================
|
|
153
|
+
// Tool Handler
|
|
154
|
+
// ============================================================================
|
|
155
|
+
/**
|
|
156
|
+
* Create packer.detect tool handler
|
|
157
|
+
* Requirements: 7.1, 7.2, 7.3, 7.4, 7.5
|
|
158
|
+
*/
|
|
159
|
+
export function createPackerDetectHandler(workspaceManager, database, cacheManager) {
|
|
160
|
+
return async (args) => {
|
|
161
|
+
const input = args;
|
|
162
|
+
const startTime = Date.now();
|
|
163
|
+
const requestEngines = normalizeEngineList(input.engines, false);
|
|
164
|
+
const cacheEngines = normalizeEngineList(input.engines, true);
|
|
165
|
+
try {
|
|
166
|
+
// 1. Validate sample exists
|
|
167
|
+
const sample = database.findSample(input.sample_id);
|
|
168
|
+
if (!sample) {
|
|
169
|
+
return {
|
|
170
|
+
ok: false,
|
|
171
|
+
errors: [`Sample not found: ${input.sample_id}`],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// 2. Generate cache key
|
|
175
|
+
const cacheKey = generateCacheKey({
|
|
176
|
+
sampleSha256: sample.sha256,
|
|
177
|
+
toolName: TOOL_NAME,
|
|
178
|
+
toolVersion: TOOL_VERSION,
|
|
179
|
+
args: {
|
|
180
|
+
engines: cacheEngines,
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
// 3. Check cache
|
|
184
|
+
if (!input.force_refresh) {
|
|
185
|
+
const cachedLookup = await lookupCachedResult(cacheManager, cacheKey);
|
|
186
|
+
if (cachedLookup) {
|
|
187
|
+
return {
|
|
188
|
+
ok: true,
|
|
189
|
+
data: cachedLookup.data,
|
|
190
|
+
warnings: ['Result from cache', formatCacheWarning(cachedLookup.metadata)],
|
|
191
|
+
metrics: {
|
|
192
|
+
elapsed_ms: Date.now() - startTime,
|
|
193
|
+
tool: TOOL_NAME,
|
|
194
|
+
cached: true,
|
|
195
|
+
cache_key: cachedLookup.metadata.key,
|
|
196
|
+
cache_tier: cachedLookup.metadata.tier,
|
|
197
|
+
cache_created_at: cachedLookup.metadata.createdAt,
|
|
198
|
+
cache_expires_at: cachedLookup.metadata.expiresAt,
|
|
199
|
+
cache_hit_at: cachedLookup.metadata.fetchedAt,
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// 4. Get sample path from workspace
|
|
205
|
+
const workspace = await workspaceManager.getWorkspace(input.sample_id);
|
|
206
|
+
// Find the sample file in the original directory
|
|
207
|
+
const fs = await import('fs/promises');
|
|
208
|
+
const files = await fs.readdir(workspace.original);
|
|
209
|
+
if (files.length === 0) {
|
|
210
|
+
return {
|
|
211
|
+
ok: false,
|
|
212
|
+
errors: ['Sample file not found in workspace'],
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const samplePath = path.join(workspace.original, files[0]);
|
|
216
|
+
// 5. Prepare worker request
|
|
217
|
+
const workerRequest = {
|
|
218
|
+
job_id: uuidv4(),
|
|
219
|
+
tool: TOOL_NAME,
|
|
220
|
+
sample: {
|
|
221
|
+
sample_id: input.sample_id,
|
|
222
|
+
path: samplePath,
|
|
223
|
+
},
|
|
224
|
+
args: {
|
|
225
|
+
engines: requestEngines,
|
|
226
|
+
},
|
|
227
|
+
context: {
|
|
228
|
+
request_time_utc: new Date().toISOString(),
|
|
229
|
+
policy: {
|
|
230
|
+
allow_dynamic: false,
|
|
231
|
+
allow_network: false,
|
|
232
|
+
},
|
|
233
|
+
versions: {
|
|
234
|
+
tool_version: TOOL_VERSION,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
// 6. Call Static Worker
|
|
239
|
+
// Requirements: 7.1, 7.2, 7.3, 7.4, 7.5
|
|
240
|
+
const workerResponse = await callStaticWorker(workerRequest);
|
|
241
|
+
if (!workerResponse.ok) {
|
|
242
|
+
return {
|
|
243
|
+
ok: false,
|
|
244
|
+
errors: workerResponse.errors,
|
|
245
|
+
warnings: workerResponse.warnings,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
// Extract the result from the worker response
|
|
249
|
+
const responseData = workerResponse.data;
|
|
250
|
+
const packerResult = responseData.result;
|
|
251
|
+
// 7. Cache result
|
|
252
|
+
await cacheManager.setCachedResult(cacheKey, packerResult, CACHE_TTL_MS);
|
|
253
|
+
// 8. Return result
|
|
254
|
+
return {
|
|
255
|
+
ok: true,
|
|
256
|
+
data: packerResult,
|
|
257
|
+
warnings: input.force_refresh
|
|
258
|
+
? [
|
|
259
|
+
'force_refresh=true; bypassed cache lookup',
|
|
260
|
+
...(responseData.warnings || workerResponse.warnings || []),
|
|
261
|
+
]
|
|
262
|
+
: responseData.warnings || workerResponse.warnings,
|
|
263
|
+
errors: workerResponse.errors,
|
|
264
|
+
artifacts: workerResponse.artifacts,
|
|
265
|
+
metrics: {
|
|
266
|
+
...responseData.metrics,
|
|
267
|
+
elapsed_ms: Date.now() - startTime,
|
|
268
|
+
tool: TOOL_NAME,
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
return {
|
|
274
|
+
ok: false,
|
|
275
|
+
errors: [error.message],
|
|
276
|
+
metrics: {
|
|
277
|
+
elapsed_ms: Date.now() - startTime,
|
|
278
|
+
tool: TOOL_NAME,
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=packer-detect.js.map
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pe.exports.extract tool implementation
|
|
3
|
+
* Extracts PE file export table (function names, ordinals, addresses)
|
|
4
|
+
* Requirements: 3.3
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import type { ToolDefinition, ToolArgs, WorkerResult } from '../types.js';
|
|
8
|
+
import type { WorkspaceManager } from '../workspace-manager.js';
|
|
9
|
+
import type { DatabaseManager } from '../database.js';
|
|
10
|
+
import type { CacheManager } from '../cache-manager.js';
|
|
11
|
+
/**
|
|
12
|
+
* Input schema for pe.exports.extract tool
|
|
13
|
+
* Requirements: 3.3
|
|
14
|
+
*/
|
|
15
|
+
export declare const PEExportsExtractInputSchema: z.ZodObject<{
|
|
16
|
+
sample_id: z.ZodString;
|
|
17
|
+
force_refresh: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
sample_id: string;
|
|
20
|
+
force_refresh: boolean;
|
|
21
|
+
}, {
|
|
22
|
+
sample_id: string;
|
|
23
|
+
force_refresh?: boolean | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export type PEExportsExtractInput = z.infer<typeof PEExportsExtractInputSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Output schema for pe.exports.extract tool
|
|
28
|
+
* Requirements: 3.3
|
|
29
|
+
*/
|
|
30
|
+
export declare const PEExportsExtractOutputSchema: z.ZodObject<{
|
|
31
|
+
ok: z.ZodBoolean;
|
|
32
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
exports: z.ZodArray<z.ZodObject<{
|
|
34
|
+
ordinal: z.ZodNumber;
|
|
35
|
+
address: z.ZodNumber;
|
|
36
|
+
name: z.ZodNullable<z.ZodString>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
address: number;
|
|
39
|
+
name: string | null;
|
|
40
|
+
ordinal: number;
|
|
41
|
+
}, {
|
|
42
|
+
address: number;
|
|
43
|
+
name: string | null;
|
|
44
|
+
ordinal: number;
|
|
45
|
+
}>, "many">;
|
|
46
|
+
forwarders: z.ZodArray<z.ZodObject<{
|
|
47
|
+
ordinal: z.ZodNumber;
|
|
48
|
+
address: z.ZodNumber;
|
|
49
|
+
name: z.ZodNullable<z.ZodString>;
|
|
50
|
+
forwarder: z.ZodString;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
address: number;
|
|
53
|
+
name: string | null;
|
|
54
|
+
ordinal: number;
|
|
55
|
+
forwarder: string;
|
|
56
|
+
}, {
|
|
57
|
+
address: number;
|
|
58
|
+
name: string | null;
|
|
59
|
+
ordinal: number;
|
|
60
|
+
forwarder: string;
|
|
61
|
+
}>, "many">;
|
|
62
|
+
total_exports: z.ZodNumber;
|
|
63
|
+
total_forwarders: z.ZodNumber;
|
|
64
|
+
_parser: z.ZodOptional<z.ZodString>;
|
|
65
|
+
_pefile_error: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
exports: {
|
|
68
|
+
address: number;
|
|
69
|
+
name: string | null;
|
|
70
|
+
ordinal: number;
|
|
71
|
+
}[];
|
|
72
|
+
forwarders: {
|
|
73
|
+
address: number;
|
|
74
|
+
name: string | null;
|
|
75
|
+
ordinal: number;
|
|
76
|
+
forwarder: string;
|
|
77
|
+
}[];
|
|
78
|
+
total_exports: number;
|
|
79
|
+
total_forwarders: number;
|
|
80
|
+
_parser?: string | undefined;
|
|
81
|
+
_pefile_error?: string | undefined;
|
|
82
|
+
}, {
|
|
83
|
+
exports: {
|
|
84
|
+
address: number;
|
|
85
|
+
name: string | null;
|
|
86
|
+
ordinal: number;
|
|
87
|
+
}[];
|
|
88
|
+
forwarders: {
|
|
89
|
+
address: number;
|
|
90
|
+
name: string | null;
|
|
91
|
+
ordinal: number;
|
|
92
|
+
forwarder: string;
|
|
93
|
+
}[];
|
|
94
|
+
total_exports: number;
|
|
95
|
+
total_forwarders: number;
|
|
96
|
+
_parser?: string | undefined;
|
|
97
|
+
_pefile_error?: string | undefined;
|
|
98
|
+
}>>;
|
|
99
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
100
|
+
errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
101
|
+
artifacts: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
102
|
+
metrics: z.ZodOptional<z.ZodObject<{
|
|
103
|
+
elapsed_ms: z.ZodNumber;
|
|
104
|
+
tool: z.ZodString;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
elapsed_ms: number;
|
|
107
|
+
tool: string;
|
|
108
|
+
}, {
|
|
109
|
+
elapsed_ms: number;
|
|
110
|
+
tool: string;
|
|
111
|
+
}>>;
|
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
|
113
|
+
ok: boolean;
|
|
114
|
+
metrics?: {
|
|
115
|
+
elapsed_ms: number;
|
|
116
|
+
tool: string;
|
|
117
|
+
} | undefined;
|
|
118
|
+
data?: {
|
|
119
|
+
exports: {
|
|
120
|
+
address: number;
|
|
121
|
+
name: string | null;
|
|
122
|
+
ordinal: number;
|
|
123
|
+
}[];
|
|
124
|
+
forwarders: {
|
|
125
|
+
address: number;
|
|
126
|
+
name: string | null;
|
|
127
|
+
ordinal: number;
|
|
128
|
+
forwarder: string;
|
|
129
|
+
}[];
|
|
130
|
+
total_exports: number;
|
|
131
|
+
total_forwarders: number;
|
|
132
|
+
_parser?: string | undefined;
|
|
133
|
+
_pefile_error?: string | undefined;
|
|
134
|
+
} | undefined;
|
|
135
|
+
warnings?: string[] | undefined;
|
|
136
|
+
errors?: string[] | undefined;
|
|
137
|
+
artifacts?: any[] | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
ok: boolean;
|
|
140
|
+
metrics?: {
|
|
141
|
+
elapsed_ms: number;
|
|
142
|
+
tool: string;
|
|
143
|
+
} | undefined;
|
|
144
|
+
data?: {
|
|
145
|
+
exports: {
|
|
146
|
+
address: number;
|
|
147
|
+
name: string | null;
|
|
148
|
+
ordinal: number;
|
|
149
|
+
}[];
|
|
150
|
+
forwarders: {
|
|
151
|
+
address: number;
|
|
152
|
+
name: string | null;
|
|
153
|
+
ordinal: number;
|
|
154
|
+
forwarder: string;
|
|
155
|
+
}[];
|
|
156
|
+
total_exports: number;
|
|
157
|
+
total_forwarders: number;
|
|
158
|
+
_parser?: string | undefined;
|
|
159
|
+
_pefile_error?: string | undefined;
|
|
160
|
+
} | undefined;
|
|
161
|
+
warnings?: string[] | undefined;
|
|
162
|
+
errors?: string[] | undefined;
|
|
163
|
+
artifacts?: any[] | undefined;
|
|
164
|
+
}>;
|
|
165
|
+
export type PEExportsExtractOutput = z.infer<typeof PEExportsExtractOutputSchema>;
|
|
166
|
+
/**
|
|
167
|
+
* Tool definition for pe.exports.extract
|
|
168
|
+
*/
|
|
169
|
+
export declare const peExportsExtractToolDefinition: ToolDefinition;
|
|
170
|
+
/**
|
|
171
|
+
* Create pe.exports.extract tool handler
|
|
172
|
+
* Requirements: 3.3
|
|
173
|
+
*/
|
|
174
|
+
export declare function createPEExportsExtractHandler(workspaceManager: WorkspaceManager, database: DatabaseManager, cacheManager: CacheManager): (args: ToolArgs) => Promise<WorkerResult>;
|
|
175
|
+
//# sourceMappingURL=pe-exports-extract.d.ts.map
|