windows-exe-decompiler-mcp-server 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/CLAUDE_INSTALLATION.md +129 -0
  2. package/CODEX_INSTALLATION.md +25 -1
  3. package/COPILOT_INSTALLATION.md +29 -1
  4. package/LICENSE +21 -21
  5. package/README.md +232 -110
  6. package/dist/analysis-provenance.d.ts +50 -2
  7. package/dist/analysis-provenance.js +1 -0
  8. package/dist/analysis-task-runner.js +92 -0
  9. package/dist/config.d.ts +35 -16
  10. package/dist/config.js +37 -3
  11. package/dist/database.js +115 -115
  12. package/dist/decompiler-worker.d.ts +10 -5
  13. package/dist/decompiler-worker.js +240 -58
  14. package/dist/dynamic-trace.d.ts +6 -0
  15. package/dist/dynamic-trace.js +52 -1
  16. package/dist/ghidra-config.js +17 -1
  17. package/dist/index.js +38 -8
  18. package/dist/pe-runtime-functions.d.ts +90 -0
  19. package/dist/pe-runtime-functions.js +452 -0
  20. package/dist/prompts/module-reconstruction-review.d.ts +5 -0
  21. package/dist/prompts/module-reconstruction-review.js +65 -0
  22. package/dist/runtime-correlation.d.ts +5 -0
  23. package/dist/runtime-correlation.js +179 -2
  24. package/dist/sample-workspace.d.ts +28 -0
  25. package/dist/sample-workspace.js +186 -0
  26. package/dist/semantic-name-suggestion-artifacts.d.ts +56 -0
  27. package/dist/semantic-name-suggestion-artifacts.js +87 -0
  28. package/dist/server.js +1 -1
  29. package/dist/setup-guidance.d.ts +73 -0
  30. package/dist/setup-guidance.js +211 -0
  31. package/dist/tools/artifact-read.d.ts +10 -10
  32. package/dist/tools/artifacts-diff.d.ts +8 -8
  33. package/dist/tools/artifacts-list.d.ts +16 -16
  34. package/dist/tools/attack-map.d.ts +8 -8
  35. package/dist/tools/binary-role-profile.d.ts +1197 -0
  36. package/dist/tools/binary-role-profile.js +575 -0
  37. package/dist/tools/code-function-explain-apply.d.ts +12 -12
  38. package/dist/tools/code-function-explain-prepare.d.ts +12 -12
  39. package/dist/tools/code-function-explain-review.d.ts +58 -58
  40. package/dist/tools/code-function-rename-apply.d.ts +12 -12
  41. package/dist/tools/code-function-rename-prepare.d.ts +14 -14
  42. package/dist/tools/code-function-rename-review.d.ts +66 -66
  43. package/dist/tools/code-functions-define.d.ts +337 -0
  44. package/dist/tools/code-functions-define.js +337 -0
  45. package/dist/tools/code-functions-list.js +1 -1
  46. package/dist/tools/code-functions-rank.js +1 -1
  47. package/dist/tools/code-functions-reconstruct.d.ts +368 -58
  48. package/dist/tools/code-functions-reconstruct.js +130 -10
  49. package/dist/tools/code-functions-smart-recover.d.ts +352 -0
  50. package/dist/tools/code-functions-smart-recover.js +190 -0
  51. package/dist/tools/code-module-review-apply.d.ts +233 -0
  52. package/dist/tools/code-module-review-apply.js +209 -0
  53. package/dist/tools/code-module-review-prepare.d.ts +756 -0
  54. package/dist/tools/code-module-review-prepare.js +343 -0
  55. package/dist/tools/code-module-review.d.ts +474 -0
  56. package/dist/tools/code-module-review.js +566 -0
  57. package/dist/tools/code-reconstruct-export.d.ts +193 -21
  58. package/dist/tools/code-reconstruct-export.js +578 -21
  59. package/dist/tools/code-reconstruct-plan.d.ts +20 -20
  60. package/dist/tools/com-role-profile.d.ts +353 -0
  61. package/dist/tools/com-role-profile.js +186 -0
  62. package/dist/tools/dll-export-profile.d.ts +625 -0
  63. package/dist/tools/dll-export-profile.js +230 -0
  64. package/dist/tools/dotnet-metadata-extract.d.ts +122 -122
  65. package/dist/tools/dotnet-reconstruct-export.d.ts +49 -49
  66. package/dist/tools/dotnet-types-list.d.ts +66 -66
  67. package/dist/tools/dynamic-dependencies.d.ts +144 -8
  68. package/dist/tools/dynamic-dependencies.js +20 -1
  69. package/dist/tools/dynamic-memory-import.js +105 -2
  70. package/dist/tools/ghidra-analyze.d.ts +20 -0
  71. package/dist/tools/ghidra-analyze.js +10 -2
  72. package/dist/tools/ghidra-health.d.ts +177 -0
  73. package/dist/tools/ghidra-health.js +28 -0
  74. package/dist/tools/ioc-export.d.ts +8 -8
  75. package/dist/tools/packer-detect.d.ts +14 -14
  76. package/dist/tools/packer-detect.js +6 -9
  77. package/dist/tools/pe-exports-extract.d.ts +8 -8
  78. package/dist/tools/pe-exports-extract.js +6 -9
  79. package/dist/tools/pe-fingerprint.d.ts +36 -36
  80. package/dist/tools/pe-imports-extract.d.ts +8 -8
  81. package/dist/tools/pe-imports-extract.js +6 -9
  82. package/dist/tools/pe-pdata-extract.d.ts +448 -0
  83. package/dist/tools/pe-pdata-extract.js +219 -0
  84. package/dist/tools/pe-symbols-recover.d.ts +227 -0
  85. package/dist/tools/pe-symbols-recover.js +316 -0
  86. package/dist/tools/report-generate.d.ts +15 -1
  87. package/dist/tools/report-generate.js +139 -16
  88. package/dist/tools/report-summarize.d.ts +2242 -8
  89. package/dist/tools/report-summarize.js +246 -10
  90. package/dist/tools/runtime-detect.d.ts +8 -8
  91. package/dist/tools/runtime-detect.js +2 -12
  92. package/dist/tools/rust-binary-analyze.d.ts +2047 -0
  93. package/dist/tools/rust-binary-analyze.js +443 -0
  94. package/dist/tools/sample-profile-get.d.ts +135 -16
  95. package/dist/tools/sample-profile-get.js +35 -32
  96. package/dist/tools/sandbox-execute.d.ts +10 -10
  97. package/dist/tools/strings-extract.d.ts +8 -8
  98. package/dist/tools/strings-extract.js +2 -12
  99. package/dist/tools/strings-floss-decode.d.ts +8 -8
  100. package/dist/tools/system-health.d.ts +172 -36
  101. package/dist/tools/system-health.js +14 -0
  102. package/dist/tools/system-setup-guide.d.ts +179 -0
  103. package/dist/tools/system-setup-guide.js +62 -0
  104. package/dist/tools/tool-help.d.ts +16 -16
  105. package/dist/tools/tool-help.js +172 -0
  106. package/dist/tools/yara-scan.d.ts +8 -8
  107. package/dist/types.d.ts +2 -0
  108. package/dist/workflows/function-explanation-review.d.ts +3034 -76
  109. package/dist/workflows/function-explanation-review.js +172 -42
  110. package/dist/workflows/function-index-recover.d.ts +333 -0
  111. package/dist/workflows/function-index-recover.js +291 -0
  112. package/dist/workflows/module-reconstruction-review.d.ts +3537 -0
  113. package/dist/workflows/module-reconstruction-review.js +354 -0
  114. package/dist/workflows/reconstruct.d.ts +2182 -223
  115. package/dist/workflows/reconstruct.js +575 -32
  116. package/dist/workflows/semantic-name-review.d.ts +1436 -85
  117. package/dist/workflows/semantic-name-review.js +150 -58
  118. package/dist/workflows/triage.d.ts +8 -8
  119. package/ghidra_scripts/DecompileFunction.java +487 -487
  120. package/ghidra_scripts/ExtractCFG.java +256 -256
  121. package/ghidra_scripts/ExtractFunctions.java +442 -442
  122. package/ghidra_scripts/README.md +112 -112
  123. package/ghidra_scripts/SearchFunctionReferences.java +380 -380
  124. package/helpers/DotNetMetadataProbe/DotNetMetadataProbe.csproj +9 -9
  125. package/helpers/DotNetMetadataProbe/Program.cs +566 -566
  126. package/install-to-claude.ps1 +432 -0
  127. package/install-to-codex.ps1 +256 -178
  128. package/install-to-copilot.ps1 +389 -303
  129. package/package.json +4 -2
  130. package/requirements.txt +9 -9
  131. package/workers/requirements-dynamic.txt +11 -11
  132. package/workers/requirements.txt +8 -8
  133. package/workers/speakeasy_compat.py +175 -175
  134. package/workers/static_worker.py +3474 -3474
@@ -1,15 +1,10 @@
1
1
  /**
2
2
  * sample.profile.get tool implementation
3
- * Retrieves sample profile including basic information and completed analyses
4
- * Requirements: Data Model
3
+ * Retrieves sample profile including basic information, completed analyses,
4
+ * and workspace/original integrity status.
5
5
  */
6
6
  import { z } from 'zod';
7
- // ============================================================================
8
- // Input/Output Schemas
9
- // ============================================================================
10
- /**
11
- * Input schema for sample.profile.get tool
12
- */
7
+ import { inspectSampleWorkspace } from '../sample-workspace.js';
13
8
  export const SampleProfileGetInputSchema = z.object({
14
9
  sample_id: z.string().describe('Sample ID (format: sha256:<hex>)'),
15
10
  stale_running_ms: z
@@ -20,12 +15,10 @@ export const SampleProfileGetInputSchema = z.object({
20
15
  .optional()
21
16
  .describe('Optional stale-analysis reap threshold in milliseconds. Omit or null to disable auto-reaping.'),
22
17
  });
23
- /**
24
- * Output schema for sample.profile.get tool
25
- */
26
18
  export const SampleProfileGetOutputSchema = z.object({
27
19
  ok: z.boolean(),
28
- data: z.object({
20
+ data: z
21
+ .object({
29
22
  sample: z.object({
30
23
  id: z.string(),
31
24
  sha256: z.string(),
@@ -45,33 +38,41 @@ export const SampleProfileGetOutputSchema = z.object({
45
38
  output_json: z.string().optional(),
46
39
  metrics_json: z.string().optional(),
47
40
  })),
48
- }).optional(),
41
+ workspace: z
42
+ .object({
43
+ status: z.enum(['ready', 'workspace_missing', 'original_dir_missing', 'original_file_missing']),
44
+ workspace_root: z.string().nullable(),
45
+ original_dir: z.string().nullable(),
46
+ reports_dir: z.string().nullable(),
47
+ ghidra_dir: z.string().nullable(),
48
+ workspace_exists: z.boolean(),
49
+ original_dir_exists: z.boolean(),
50
+ reports_dir_exists: z.boolean(),
51
+ ghidra_dir_exists: z.boolean(),
52
+ original_present: z.boolean(),
53
+ original_file_count: z.number().int().nonnegative(),
54
+ original_files: z.array(z.string()),
55
+ alternate_workspace_root: z.string().nullable(),
56
+ alternate_original_dir: z.string().nullable(),
57
+ alternate_original_present: z.boolean(),
58
+ alternate_original_files: z.array(z.string()),
59
+ remediation: z.array(z.string()),
60
+ })
61
+ .optional(),
62
+ })
63
+ .optional(),
49
64
  errors: z.array(z.string()).optional(),
50
65
  });
51
- // ============================================================================
52
- // Tool Definition
53
- // ============================================================================
54
- /**
55
- * Tool definition for sample.profile.get
56
- */
57
66
  export const sampleProfileGetToolDefinition = {
58
67
  name: 'sample.profile.get',
59
- description: '查询样本基础信息和已完成的分析',
68
+ description: 'Query sample metadata, completed analyses, and workspace integrity including whether workspace/original still contains the original sample file.',
60
69
  inputSchema: SampleProfileGetInputSchema,
61
70
  outputSchema: SampleProfileGetOutputSchema,
62
71
  };
63
- // ============================================================================
64
- // Tool Handler
65
- // ============================================================================
66
- /**
67
- * Create sample.profile.get tool handler
68
- * Requirements: Data Model
69
- */
70
- export function createSampleProfileGetHandler(database) {
72
+ export function createSampleProfileGetHandler(database, workspaceManager) {
71
73
  return async (args) => {
72
74
  try {
73
75
  const input = SampleProfileGetInputSchema.parse(args);
74
- // 1. Query sample from database
75
76
  const sample = database.findSample(input.sample_id);
76
77
  if (!sample) {
77
78
  return {
@@ -79,12 +80,13 @@ export function createSampleProfileGetHandler(database) {
79
80
  errors: [`Sample not found: ${input.sample_id}`],
80
81
  };
81
82
  }
82
- // 2. Query analyses for this sample
83
83
  if (typeof input.stale_running_ms === 'number') {
84
84
  database.reapStaleAnalyses(input.stale_running_ms, input.sample_id);
85
85
  }
86
86
  const analyses = database.findAnalysesBySample(input.sample_id);
87
- // 3. Return profile data
87
+ const workspace = workspaceManager
88
+ ? await inspectSampleWorkspace(workspaceManager, input.sample_id)
89
+ : undefined;
88
90
  return {
89
91
  ok: true,
90
92
  data: {
@@ -97,7 +99,7 @@ export function createSampleProfileGetHandler(database) {
97
99
  created_at: sample.created_at,
98
100
  source: sample.source,
99
101
  },
100
- analyses: analyses.map(analysis => ({
102
+ analyses: analyses.map((analysis) => ({
101
103
  id: analysis.id,
102
104
  stage: analysis.stage,
103
105
  backend: analysis.backend,
@@ -107,6 +109,7 @@ export function createSampleProfileGetHandler(database) {
107
109
  output_json: analysis.output_json || undefined,
108
110
  metrics_json: analysis.metrics_json || undefined,
109
111
  })),
112
+ workspace,
110
113
  },
111
114
  };
112
115
  }
@@ -20,18 +20,18 @@ export declare const SandboxExecuteInputSchema: z.ZodObject<{
20
20
  sample_id: string;
21
21
  network: "enabled" | "fake" | "disabled";
22
22
  mode: "safe_simulation" | "memory_guided" | "speakeasy" | "live_local";
23
+ persist_artifact: boolean;
23
24
  require_user_approval: boolean;
24
25
  approved: boolean;
25
- persist_artifact: boolean;
26
26
  timeout_sec: number;
27
27
  max_scan_bytes: number;
28
28
  }, {
29
29
  sample_id: string;
30
30
  network?: "enabled" | "fake" | "disabled" | undefined;
31
31
  mode?: "safe_simulation" | "memory_guided" | "speakeasy" | "live_local" | undefined;
32
+ persist_artifact?: boolean | undefined;
32
33
  require_user_approval?: boolean | undefined;
33
34
  approved?: boolean | undefined;
34
- persist_artifact?: boolean | undefined;
35
35
  timeout_sec?: number | undefined;
36
36
  max_scan_bytes?: number | undefined;
37
37
  }>;
@@ -303,10 +303,6 @@ export declare const SandboxExecuteOutputSchema: z.ZodObject<{
303
303
  }>>;
304
304
  }, "strip", z.ZodTypeAny, {
305
305
  ok: boolean;
306
- metrics?: {
307
- elapsed_ms: number;
308
- tool: string;
309
- } | undefined;
310
306
  data?: {
311
307
  status: "timeout" | "failed" | "completed" | "denied";
312
308
  backend: string;
@@ -365,15 +361,15 @@ export declare const SandboxExecuteOutputSchema: z.ZodObject<{
365
361
  confidence: number;
366
362
  }[] | undefined;
367
363
  } | undefined;
364
+ metrics?: {
365
+ elapsed_ms: number;
366
+ tool: string;
367
+ } | undefined;
368
368
  warnings?: string[] | undefined;
369
369
  errors?: string[] | undefined;
370
370
  artifacts?: any[] | undefined;
371
371
  }, {
372
372
  ok: boolean;
373
- metrics?: {
374
- elapsed_ms: number;
375
- tool: string;
376
- } | undefined;
377
373
  data?: {
378
374
  status: "timeout" | "failed" | "completed" | "denied";
379
375
  backend: string;
@@ -432,6 +428,10 @@ export declare const SandboxExecuteOutputSchema: z.ZodObject<{
432
428
  confidence: number;
433
429
  }[] | undefined;
434
430
  } | undefined;
431
+ metrics?: {
432
+ elapsed_ms: number;
433
+ tool: string;
434
+ } | undefined;
435
435
  warnings?: string[] | undefined;
436
436
  errors?: string[] | undefined;
437
437
  artifacts?: any[] | undefined;
@@ -269,10 +269,6 @@ export declare const StringsExtractOutputSchema: z.ZodObject<{
269
269
  }>>;
270
270
  }, "strip", z.ZodTypeAny, {
271
271
  ok: boolean;
272
- metrics?: {
273
- elapsed_ms: number;
274
- tool: string;
275
- } | undefined;
276
272
  data?: {
277
273
  strings: {
278
274
  string: string;
@@ -311,15 +307,15 @@ export declare const StringsExtractOutputSchema: z.ZodObject<{
311
307
  pre_filter_count?: number | undefined;
312
308
  truncated?: boolean | undefined;
313
309
  } | undefined;
310
+ metrics?: {
311
+ elapsed_ms: number;
312
+ tool: string;
313
+ } | undefined;
314
314
  warnings?: string[] | undefined;
315
315
  errors?: string[] | undefined;
316
316
  artifacts?: any[] | undefined;
317
317
  }, {
318
318
  ok: boolean;
319
- metrics?: {
320
- elapsed_ms: number;
321
- tool: string;
322
- } | undefined;
323
319
  data?: {
324
320
  strings: {
325
321
  string: string;
@@ -358,6 +354,10 @@ export declare const StringsExtractOutputSchema: z.ZodObject<{
358
354
  pre_filter_count?: number | undefined;
359
355
  truncated?: boolean | undefined;
360
356
  } | undefined;
357
+ metrics?: {
358
+ elapsed_ms: number;
359
+ tool: string;
360
+ } | undefined;
361
361
  warnings?: string[] | undefined;
362
362
  errors?: string[] | undefined;
363
363
  artifacts?: any[] | undefined;
@@ -5,11 +5,11 @@
5
5
  */
6
6
  import { z } from 'zod';
7
7
  import { spawn } from 'child_process';
8
- import path from 'path';
9
8
  import { v4 as uuidv4 } from 'uuid';
10
9
  import { generateCacheKey } from '../cache-manager.js';
11
10
  import { resolvePackagePath } from '../runtime-paths.js';
12
11
  import { lookupCachedResult, formatCacheWarning } from './cache-observability.js';
12
+ import { resolvePrimarySamplePath } from '../sample-workspace.js';
13
13
  // ============================================================================
14
14
  // Constants
15
15
  // ============================================================================
@@ -233,17 +233,7 @@ export function createStringsExtractHandler(workspaceManager, database, cacheMan
233
233
  }
234
234
  }
235
235
  // 3. Get sample path from workspace
236
- const workspace = await workspaceManager.getWorkspace(input.sample_id);
237
- // Find the sample file in the original directory
238
- const fs = await import('fs/promises');
239
- const files = await fs.readdir(workspace.original);
240
- if (files.length === 0) {
241
- return {
242
- ok: false,
243
- errors: ['Sample file not found in workspace'],
244
- };
245
- }
246
- const samplePath = path.join(workspace.original, files[0]);
236
+ const { samplePath } = await resolvePrimarySamplePath(workspaceManager, input.sample_id);
247
237
  // 4. Prepare worker request
248
238
  const workerRequest = {
249
239
  job_id: uuidv4(),
@@ -91,10 +91,6 @@ export declare const StringsFlossDecodeOutputSchema: z.ZodObject<{
91
91
  }>>;
92
92
  }, "strip", z.ZodTypeAny, {
93
93
  ok: boolean;
94
- metrics?: {
95
- elapsed_ms: number;
96
- tool: string;
97
- } | undefined;
98
94
  data?: {
99
95
  count: number;
100
96
  decoded_strings: {
@@ -106,15 +102,15 @@ export declare const StringsFlossDecodeOutputSchema: z.ZodObject<{
106
102
  timeout_occurred: boolean;
107
103
  partial_results: boolean;
108
104
  } | undefined;
105
+ metrics?: {
106
+ elapsed_ms: number;
107
+ tool: string;
108
+ } | undefined;
109
109
  warnings?: string[] | undefined;
110
110
  errors?: string[] | undefined;
111
111
  artifacts?: any[] | undefined;
112
112
  }, {
113
113
  ok: boolean;
114
- metrics?: {
115
- elapsed_ms: number;
116
- tool: string;
117
- } | undefined;
118
114
  data?: {
119
115
  count: number;
120
116
  decoded_strings: {
@@ -126,6 +122,10 @@ export declare const StringsFlossDecodeOutputSchema: z.ZodObject<{
126
122
  timeout_occurred: boolean;
127
123
  partial_results: boolean;
128
124
  } | undefined;
125
+ metrics?: {
126
+ elapsed_ms: number;
127
+ tool: string;
128
+ } | undefined;
129
129
  warnings?: string[] | undefined;
130
130
  errors?: string[] | undefined;
131
131
  artifacts?: any[] | undefined;