feat(ghidra): support native PE DLLs on Windows
This commit is contained in:
@@ -34,6 +34,12 @@ export const resolveGhidraAnalysisProfile = (
|
||||
profile: createAnalysisProfile(provider, {
|
||||
target_kind: target.kind,
|
||||
target_format: target.format,
|
||||
...(target.format === "pe"
|
||||
? {
|
||||
executable_role: target.executableRole ?? null,
|
||||
managed: target.managed ?? null,
|
||||
}
|
||||
: {}),
|
||||
architecture: target.architecture ?? null,
|
||||
available_architectures: [
|
||||
...(target.availableArchitectures ?? []),
|
||||
|
||||
@@ -270,7 +270,7 @@ describe("Ghidra platform support", () => {
|
||||
expect(
|
||||
ghidra.inspectTargetSupport({
|
||||
...nativeApplication,
|
||||
executableRole: "shared-library",
|
||||
executableRole: "non-executable",
|
||||
}),
|
||||
).toMatchObject({
|
||||
status: "unsupported",
|
||||
@@ -295,45 +295,59 @@ describe("Ghidra platform support", () => {
|
||||
code: "architecture_unsupported",
|
||||
});
|
||||
});
|
||||
it("admits generated PE32 applications while rejecting unsupported x86 roles", async () => {
|
||||
});
|
||||
|
||||
describe("Ghidra Windows PE fixture admission", () => {
|
||||
it("admits generated PE32 and PE32+ DLLs and applications while preserving native-only Windows admission", async () => {
|
||||
const root = fileURLToPath(new URL("../../", import.meta.url));
|
||||
await promisify(execFile)(process.execPath, [
|
||||
join(root, "scripts/create-ghidra-windows-fixture.mjs"),
|
||||
]);
|
||||
const path = join(root, "build/fixtures/rea-ghidra-windows-x86.exe");
|
||||
const bytes = await readFile(path);
|
||||
const metadata = parseExecutableHeader(bytes, "x64");
|
||||
expect(metadata).toMatchObject({
|
||||
ok: true,
|
||||
value: {
|
||||
format: "pe",
|
||||
architecture: "x86",
|
||||
executableRole: "application",
|
||||
managed: false,
|
||||
},
|
||||
});
|
||||
if (!metadata.ok) throw new Error(metadata.error);
|
||||
if (metadata.value.format !== "pe")
|
||||
throw new Error("Expected a PE fixture");
|
||||
const target: BinaryTarget = {
|
||||
path,
|
||||
sha256: createHash("sha256").update(bytes).digest("hex"),
|
||||
kind: "executable",
|
||||
...metadata.value,
|
||||
};
|
||||
const ghidra = provider({ ...installationHost(), platform: "win32" });
|
||||
expect(ghidra.inspectTargetSupport(target).status).toBe("supported");
|
||||
for (const [candidate, code] of [
|
||||
[
|
||||
{ ...target, executableRole: "shared-library" },
|
||||
"target_role_unsupported",
|
||||
],
|
||||
[{ ...target, managed: true }, "managed_target_unsupported"],
|
||||
] as const)
|
||||
expect(ghidra.inspectTargetSupport(candidate)).toMatchObject({
|
||||
status: "unsupported",
|
||||
code,
|
||||
});
|
||||
for (const architecture of ["x86", "x86_64"] as const) {
|
||||
for (const dll of [false, true]) {
|
||||
const path = join(
|
||||
root,
|
||||
"build/fixtures",
|
||||
`rea-ghidra-windows${architecture === "x86" ? "-x86" : ""}.${dll ? "dll" : "exe"}`,
|
||||
);
|
||||
const bytes = await readFile(path);
|
||||
const metadata = parseExecutableHeader(bytes, "x64");
|
||||
const role = dll ? "shared-library" : "application";
|
||||
expect(metadata).toMatchObject({
|
||||
ok: true,
|
||||
value: {
|
||||
format: "pe",
|
||||
architecture,
|
||||
executableRole: role,
|
||||
managed: false,
|
||||
},
|
||||
});
|
||||
if (!metadata.ok) throw new Error(metadata.error);
|
||||
if (metadata.value.format !== "pe")
|
||||
throw new Error("Expected a PE fixture");
|
||||
const target: BinaryTarget = {
|
||||
path,
|
||||
sha256: createHash("sha256").update(bytes).digest("hex"),
|
||||
kind: "executable",
|
||||
...metadata.value,
|
||||
};
|
||||
expect(ghidra.inspectTargetSupport(target).status).toBe("supported");
|
||||
for (const [candidate, code] of [
|
||||
[
|
||||
{ ...target, executableRole: "non-executable" },
|
||||
"target_role_unsupported",
|
||||
],
|
||||
[{ ...target, managed: true }, "managed_target_unsupported"],
|
||||
[{ ...target, architecture: "arm64" }, "architecture_unsupported"],
|
||||
] as const) {
|
||||
expect(ghidra.inspectTargetSupport(candidate)).toMatchObject({
|
||||
status: "unsupported",
|
||||
code,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -247,12 +247,15 @@ const inspectWindowsP0TargetSupport = (
|
||||
reason: "Windows Ghidra P0 accepts x86 and x86-64 PE targets only.",
|
||||
diagnostics,
|
||||
};
|
||||
if (target.executableRole !== "application")
|
||||
if (
|
||||
target.executableRole !== "application" &&
|
||||
target.executableRole !== "shared-library"
|
||||
)
|
||||
return {
|
||||
status: "unsupported",
|
||||
code: "target_role_unsupported",
|
||||
reason:
|
||||
"Windows Ghidra P0 accepts PE applications, not DLL or non-executable images.",
|
||||
"Windows Ghidra P0 accepts PE applications and DLLs, not non-executable or unclassified images.",
|
||||
diagnostics,
|
||||
};
|
||||
if (target.managed !== false)
|
||||
@@ -260,7 +263,7 @@ const inspectWindowsP0TargetSupport = (
|
||||
status: "unsupported",
|
||||
code: "managed_target_unsupported",
|
||||
reason:
|
||||
"Windows Ghidra P0 accepts native PE applications; managed or unclassified PE targets are unsupported.",
|
||||
"Windows Ghidra P0 accepts native PE applications and DLLs; managed or unclassified PE targets are unsupported.",
|
||||
diagnostics,
|
||||
};
|
||||
return {
|
||||
|
||||
@@ -31,7 +31,7 @@ export const healthLimitations = Object.freeze([
|
||||
|
||||
/** Additional limitations applied to the experimental Windows x64 P0 boundary. */
|
||||
export const windowsP0Limitations = Object.freeze([
|
||||
"Windows Ghidra P0 accepts approved native x86 and x86-64 PE applications only; DLL, managed, hostile, sensitive, and mutable-path targets are unsupported.",
|
||||
"Windows Ghidra P0 accepts approved native x86 and x86-64 PE applications and DLLs; managed, hostile, sensitive, and mutable-path targets are unsupported.",
|
||||
"The Windows bridge uses authenticated IPv4 loopback because Node path-based IPC does not expose Java AF_UNIX sockets; the endpoint file contains no bearer token.",
|
||||
"Windows sessions require the matching packaged Windows x64 native addon, local NTFS targets and runtimes, and Windows 10 or later. Native handles enforce path admission, private DACLs, and Job Object ownership automatically.",
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user