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,279 @@
|
|
|
1
|
+
function dedupe(values) {
|
|
2
|
+
return Array.from(new Set(values.map((item) => item.trim()).filter((item) => item.length > 0)));
|
|
3
|
+
}
|
|
4
|
+
function clamp(value, min, max) {
|
|
5
|
+
return Math.max(min, Math.min(max, value));
|
|
6
|
+
}
|
|
7
|
+
function summarizeEvidenceSources(dynamicEvidence) {
|
|
8
|
+
const formats = dynamicEvidence.source_formats || [];
|
|
9
|
+
const kinds = dynamicEvidence.evidence_kinds || [];
|
|
10
|
+
const pairCount = Math.max(formats.length, kinds.length);
|
|
11
|
+
const pairs = [];
|
|
12
|
+
for (let index = 0; index < pairCount; index += 1) {
|
|
13
|
+
const format = formats[index] || formats[formats.length - 1] || 'runtime';
|
|
14
|
+
const kind = kinds[index] || kinds[kinds.length - 1] || 'hybrid';
|
|
15
|
+
pairs.push(`${format}:${kind}`);
|
|
16
|
+
}
|
|
17
|
+
if (pairs.length > 0) {
|
|
18
|
+
return dedupe(pairs).slice(0, 6);
|
|
19
|
+
}
|
|
20
|
+
return dynamicEvidence.executed ? ['runtime:trace'] : ['runtime:memory_snapshot'];
|
|
21
|
+
}
|
|
22
|
+
function summarizeSourceNames(dynamicEvidence) {
|
|
23
|
+
return dedupe(dynamicEvidence.source_names || []).slice(0, 6);
|
|
24
|
+
}
|
|
25
|
+
function summarizeProvenanceLayers(dynamicEvidence) {
|
|
26
|
+
return (dynamicEvidence.confidence_layers || []).map((item) => `${item.layer}(${item.artifact_count})`);
|
|
27
|
+
}
|
|
28
|
+
export function normalizeRuntimeApiName(value) {
|
|
29
|
+
return value.trim().replace(/\(.*/, '').replace(/^.*!/, '').replace(/^.*\./, '');
|
|
30
|
+
}
|
|
31
|
+
export function extractSensitiveApisFromReasons(rankReasons = []) {
|
|
32
|
+
const apis = [];
|
|
33
|
+
for (const reason of rankReasons) {
|
|
34
|
+
const match = /^calls_sensitive_api:(.+)$/i.exec(reason);
|
|
35
|
+
if (!match) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const api = normalizeRuntimeApiName(match[1]);
|
|
39
|
+
if (api.length > 0) {
|
|
40
|
+
apis.push(api);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return dedupe(apis);
|
|
44
|
+
}
|
|
45
|
+
function collectCandidateApis(input) {
|
|
46
|
+
const fromCallTargets = (input.callTargets || [])
|
|
47
|
+
.map((item) => normalizeRuntimeApiName(item))
|
|
48
|
+
.filter((item) => /^[A-Za-z_][A-Za-z0-9_]+(?:W|A)?$/.test(item));
|
|
49
|
+
return dedupe([
|
|
50
|
+
...(input.xrefApis || []).map((item) => normalizeRuntimeApiName(item)),
|
|
51
|
+
...extractSensitiveApisFromReasons(input.rankReasons || []),
|
|
52
|
+
...fromCallTargets,
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
function buildSemanticCorpus(input) {
|
|
56
|
+
return [
|
|
57
|
+
input.functionName || '',
|
|
58
|
+
input.moduleName || '',
|
|
59
|
+
input.semanticSummary || '',
|
|
60
|
+
...(input.stringHints || []),
|
|
61
|
+
...(input.callTargets || []),
|
|
62
|
+
]
|
|
63
|
+
.join('\n')
|
|
64
|
+
.toLowerCase();
|
|
65
|
+
}
|
|
66
|
+
export function deriveRuntimeStageCandidates(input) {
|
|
67
|
+
const behaviorTags = new Set((input.behaviorTags || []).map((item) => item.toLowerCase()));
|
|
68
|
+
const apis = collectCandidateApis(input);
|
|
69
|
+
const apiCorpus = apis.join(' ').toLowerCase();
|
|
70
|
+
const semanticCorpus = buildSemanticCorpus(input);
|
|
71
|
+
const stages = new Set();
|
|
72
|
+
if (/\b(getprocaddress|loadlibrary|getmodulehandle)\b/i.test(apiCorpus) ||
|
|
73
|
+
semanticCorpus.includes('dynamic api') ||
|
|
74
|
+
semanticCorpus.includes('dispatch table') ||
|
|
75
|
+
semanticCorpus.includes('resolver')) {
|
|
76
|
+
stages.add('resolve_dynamic_apis');
|
|
77
|
+
}
|
|
78
|
+
if (behaviorTags.has('process_injection') ||
|
|
79
|
+
behaviorTags.has('process_spawn') ||
|
|
80
|
+
/\b(openprocess|writeprocessmemory|readprocessmemory|setthreadcontext|resumethread|createremotethread|virtualallocex|createprocess)\b/i.test(apiCorpus) ||
|
|
81
|
+
semanticCorpus.includes('remote process') ||
|
|
82
|
+
semanticCorpus.includes('thread context')) {
|
|
83
|
+
stages.add('prepare_remote_process_access');
|
|
84
|
+
}
|
|
85
|
+
if (behaviorTags.has('anti_debug') ||
|
|
86
|
+
/\b(ntqueryinformationprocess|ntquerysysteminformation|isdebuggerpresent|checkremotedebuggerpresent)\b/i.test(apiCorpus) ||
|
|
87
|
+
semanticCorpus.includes('code integrity') ||
|
|
88
|
+
semanticCorpus.includes('execution environment') ||
|
|
89
|
+
semanticCorpus.includes('anti-analysis')) {
|
|
90
|
+
stages.add('anti_analysis_checks');
|
|
91
|
+
stages.add('check_execution_environment');
|
|
92
|
+
}
|
|
93
|
+
if (behaviorTags.has('file_io') ||
|
|
94
|
+
/\b(createfile|readfile|writefile|deletefile|copyfile|findfirstfile|findnextfile)\b/i.test(apiCorpus) ||
|
|
95
|
+
semanticCorpus.includes('file system') ||
|
|
96
|
+
semanticCorpus.includes('on-disk')) {
|
|
97
|
+
stages.add('file_operations');
|
|
98
|
+
}
|
|
99
|
+
if (behaviorTags.has('registry') ||
|
|
100
|
+
/\b(regopenkey|regcreatekey|regsetvalue|regqueryvalue|regdeletekey)\b/i.test(apiCorpus) ||
|
|
101
|
+
semanticCorpus.includes('registry')) {
|
|
102
|
+
stages.add('registry_operations');
|
|
103
|
+
stages.add('stage_registry_state');
|
|
104
|
+
}
|
|
105
|
+
if (semanticCorpus.includes('packer') ||
|
|
106
|
+
semanticCorpus.includes('entropy') ||
|
|
107
|
+
semanticCorpus.includes('section') ||
|
|
108
|
+
semanticCorpus.includes('protector') ||
|
|
109
|
+
semanticCorpus.includes('overlay')) {
|
|
110
|
+
stages.add('scan_pe_layout');
|
|
111
|
+
}
|
|
112
|
+
return Array.from(stages);
|
|
113
|
+
}
|
|
114
|
+
function regionMatchersForStage(stage) {
|
|
115
|
+
switch (stage) {
|
|
116
|
+
case 'resolve_dynamic_apis':
|
|
117
|
+
return [/resolution/i, /dispatch/i, /api/i, /loader/i];
|
|
118
|
+
case 'prepare_remote_process_access':
|
|
119
|
+
return [/process/i, /remote/i, /thread/i, /injection/i];
|
|
120
|
+
case 'anti_analysis_checks':
|
|
121
|
+
case 'check_execution_environment':
|
|
122
|
+
return [/analysis/i, /integrity/i, /environment/i, /telemetry/i];
|
|
123
|
+
case 'file_operations':
|
|
124
|
+
return [/file/i, /path/i, /filesystem/i];
|
|
125
|
+
case 'registry_operations':
|
|
126
|
+
case 'stage_registry_state':
|
|
127
|
+
return [/registry/i, /key/i];
|
|
128
|
+
case 'scan_pe_layout':
|
|
129
|
+
return [/packer/i, /entropy/i, /section/i, /layout/i];
|
|
130
|
+
default:
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function collectMatchedMemoryRegions(candidateStages, input, dynamicEvidence) {
|
|
135
|
+
const semanticCorpus = buildSemanticCorpus(input);
|
|
136
|
+
const matched = new Set();
|
|
137
|
+
const regions = dynamicEvidence.memory_regions || [];
|
|
138
|
+
for (const region of regions) {
|
|
139
|
+
const lowered = region.toLowerCase();
|
|
140
|
+
for (const stage of candidateStages) {
|
|
141
|
+
if (regionMatchersForStage(stage).some((matcher) => matcher.test(lowered))) {
|
|
142
|
+
matched.add(region);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (semanticCorpus.includes('dispatch') && /dispatch|resolution|api/i.test(lowered)) {
|
|
146
|
+
matched.add(region);
|
|
147
|
+
}
|
|
148
|
+
if (semanticCorpus.includes('process') && /process|thread|remote/i.test(lowered)) {
|
|
149
|
+
matched.add(region);
|
|
150
|
+
}
|
|
151
|
+
if (semanticCorpus.includes('registry') && /registry|key/i.test(lowered)) {
|
|
152
|
+
matched.add(region);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return Array.from(matched).slice(0, 6);
|
|
156
|
+
}
|
|
157
|
+
export function correlateFunctionWithRuntimeEvidence(input, dynamicEvidence) {
|
|
158
|
+
if (!dynamicEvidence) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
const candidateApis = collectCandidateApis(input);
|
|
162
|
+
const observedMap = new Map((dynamicEvidence.observed_apis || []).map((item) => [normalizeRuntimeApiName(item).toLowerCase(), item]));
|
|
163
|
+
const highSignalSet = new Set((dynamicEvidence.high_signal_apis || []).map((item) => normalizeRuntimeApiName(item).toLowerCase()));
|
|
164
|
+
const matchedApis = candidateApis
|
|
165
|
+
.map((item) => observedMap.get(item.toLowerCase()) || '')
|
|
166
|
+
.filter((item) => item.length > 0);
|
|
167
|
+
const candidateStages = deriveRuntimeStageCandidates(input);
|
|
168
|
+
const observedStages = new Set((dynamicEvidence.stages || []).map((item) => item.toLowerCase()));
|
|
169
|
+
const matchedStages = candidateStages.filter((item) => observedStages.has(item.toLowerCase()));
|
|
170
|
+
const matchedMemoryRegions = collectMatchedMemoryRegions(candidateStages, input, dynamicEvidence);
|
|
171
|
+
const evidenceSources = summarizeEvidenceSources(dynamicEvidence);
|
|
172
|
+
const sourceNames = summarizeSourceNames(dynamicEvidence);
|
|
173
|
+
const provenanceLayers = summarizeProvenanceLayers(dynamicEvidence);
|
|
174
|
+
const matchedBy = dedupe([
|
|
175
|
+
(input.xrefApis || []).length > 0 ? 'xref_api' : '',
|
|
176
|
+
(input.rankReasons || []).length > 0 ? 'rank_reason' : '',
|
|
177
|
+
(input.callTargets || []).length > 0 ? 'call_target' : '',
|
|
178
|
+
(input.stringHints || []).length > 0 ? 'string_hint' : '',
|
|
179
|
+
input.semanticSummary ? 'semantic_summary' : '',
|
|
180
|
+
]);
|
|
181
|
+
if (matchedApis.length === 0 && matchedStages.length === 0 && matchedMemoryRegions.length === 0) {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
const highSignalMatches = matchedApis.filter((item) => highSignalSet.has(normalizeRuntimeApiName(item).toLowerCase()));
|
|
185
|
+
const notes = [];
|
|
186
|
+
if (matchedApis.length > 0) {
|
|
187
|
+
notes.push(`Runtime-observed APIs overlap with this function: ${dedupe(matchedApis).slice(0, 6).join(', ')}`);
|
|
188
|
+
}
|
|
189
|
+
if (matchedStages.length > 0) {
|
|
190
|
+
notes.push(`Runtime stages align with this function: ${dedupe(matchedStages).slice(0, 4).join(', ')}`);
|
|
191
|
+
}
|
|
192
|
+
if (matchedMemoryRegions.length > 0) {
|
|
193
|
+
notes.push(`Runtime memory regions align with this function: ${matchedMemoryRegions.slice(0, 4).join(', ')}`);
|
|
194
|
+
}
|
|
195
|
+
if (dynamicEvidence.executed) {
|
|
196
|
+
notes.push('Correlation includes executed runtime evidence, not just static or memory-only hints.');
|
|
197
|
+
}
|
|
198
|
+
if (evidenceSources.length > 0) {
|
|
199
|
+
notes.push(`Runtime evidence sources: ${evidenceSources.join(', ')}`);
|
|
200
|
+
}
|
|
201
|
+
if (sourceNames.length > 0) {
|
|
202
|
+
notes.push(`Runtime source names: ${sourceNames.join(', ')}`);
|
|
203
|
+
}
|
|
204
|
+
if (provenanceLayers.length > 0) {
|
|
205
|
+
notes.push(`Runtime evidence layers: ${provenanceLayers.join(', ')}`);
|
|
206
|
+
}
|
|
207
|
+
if (dynamicEvidence.scope_note) {
|
|
208
|
+
notes.push(dynamicEvidence.scope_note);
|
|
209
|
+
}
|
|
210
|
+
if ((dynamicEvidence.executed_artifact_count || 0) > 0) {
|
|
211
|
+
notes.push(`Matched against ${dynamicEvidence.executed_artifact_count} executed runtime artifact(s).`);
|
|
212
|
+
}
|
|
213
|
+
const suggestedModules = dedupe([
|
|
214
|
+
...modulesSuggestedByRuntimeStages(matchedStages),
|
|
215
|
+
...(matchedMemoryRegions.some((item) => /process|thread|dispatch|resolution|command/i.test(item))
|
|
216
|
+
? ['process_ops']
|
|
217
|
+
: []),
|
|
218
|
+
...(matchedMemoryRegions.some((item) => /registry|key/i.test(item)) ? ['registry_ops'] : []),
|
|
219
|
+
...(matchedMemoryRegions.some((item) => /analysis|integrity|environment/i.test(item))
|
|
220
|
+
? ['anti_analysis']
|
|
221
|
+
: []),
|
|
222
|
+
...(matchedMemoryRegions.some((item) => /packer|entropy|section|layout/i.test(item))
|
|
223
|
+
? ['packer_analysis']
|
|
224
|
+
: []),
|
|
225
|
+
...(matchedMemoryRegions.some((item) => /network|socket|http|pipe|ipc/i.test(item))
|
|
226
|
+
? ['network_ops']
|
|
227
|
+
: []),
|
|
228
|
+
]);
|
|
229
|
+
if (suggestedModules.length > 0) {
|
|
230
|
+
notes.push(`Suggested semantic modules: ${suggestedModules.slice(0, 4).join(', ')}`);
|
|
231
|
+
}
|
|
232
|
+
const confidence = clamp(0.42 +
|
|
233
|
+
Math.min(0.24, dedupe(matchedApis).length * 0.08) +
|
|
234
|
+
Math.min(0.16, dedupe(matchedStages).length * 0.06) +
|
|
235
|
+
Math.min(0.12, highSignalMatches.length * 0.05) +
|
|
236
|
+
Math.min(0.1, matchedMemoryRegions.length * 0.04), 0.45, 0.97);
|
|
237
|
+
return {
|
|
238
|
+
corroborated_apis: dedupe(matchedApis).slice(0, 8),
|
|
239
|
+
corroborated_stages: dedupe(matchedStages).slice(0, 6),
|
|
240
|
+
notes: dedupe(notes).slice(0, 5),
|
|
241
|
+
confidence: Number(confidence.toFixed(2)),
|
|
242
|
+
executed: dynamicEvidence.executed,
|
|
243
|
+
evidence_sources: evidenceSources,
|
|
244
|
+
source_names: sourceNames,
|
|
245
|
+
artifact_count: dynamicEvidence.artifact_count,
|
|
246
|
+
executed_artifact_count: dynamicEvidence.executed_artifact_count || 0,
|
|
247
|
+
matched_memory_regions: matchedMemoryRegions,
|
|
248
|
+
suggested_modules: suggestedModules,
|
|
249
|
+
matched_by: matchedBy,
|
|
250
|
+
provenance_layers: provenanceLayers,
|
|
251
|
+
latest_artifact_at: dynamicEvidence.latest_imported_at || null,
|
|
252
|
+
scope_note: dynamicEvidence.scope_note,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
export function modulesSuggestedByRuntimeStages(stages = []) {
|
|
256
|
+
const modules = new Set();
|
|
257
|
+
for (const stage of stages.map((item) => item.toLowerCase())) {
|
|
258
|
+
if (stage === 'prepare_remote_process_access' || stage === 'launch_operator_command') {
|
|
259
|
+
modules.add('process_ops');
|
|
260
|
+
}
|
|
261
|
+
else if (stage === 'file_operations') {
|
|
262
|
+
modules.add('file_ops');
|
|
263
|
+
}
|
|
264
|
+
else if (stage === 'registry_operations' || stage === 'stage_registry_state') {
|
|
265
|
+
modules.add('registry_ops');
|
|
266
|
+
}
|
|
267
|
+
else if (stage === 'anti_analysis_checks' || stage === 'check_execution_environment') {
|
|
268
|
+
modules.add('anti_analysis');
|
|
269
|
+
}
|
|
270
|
+
else if (stage === 'scan_pe_layout') {
|
|
271
|
+
modules.add('packer_analysis');
|
|
272
|
+
}
|
|
273
|
+
else if (stage === 'resolve_dynamic_apis') {
|
|
274
|
+
modules.add('process_ops');
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return Array.from(modules);
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=runtime-correlation.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
4
|
+
const packageRoot = path.resolve(moduleDir, '..');
|
|
5
|
+
export function getPackageRoot() {
|
|
6
|
+
return packageRoot;
|
|
7
|
+
}
|
|
8
|
+
export function resolvePackagePath(...segments) {
|
|
9
|
+
return path.join(packageRoot, ...segments);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=runtime-paths.js.map
|