NationalSecurityAgency/ghidra · error · IOException

Could not get MD5 on file:

Error message

Could not get MD5 on file: 

What it means

GenerateSignatures GhidraScript checks currentProgram.getExecutableMD5(); if null or shorter than 10 characters it throws IOException because signature generation requires a valid MD5 to name and key the output. Without the MD5 the BSim signature file cannot be reliably associated with the program.

Source

Thrown at Ghidra/Features/BSim/ghidra_scripts/GenerateSignatures.java:38

import java.io.*;
import java.util.Iterator;

import generic.lsh.vector.LSHVectorFactory;
import ghidra.app.script.GhidraScript;
import ghidra.features.bsim.query.FunctionDatabase;
import ghidra.features.bsim.query.GenSignatures;
import ghidra.features.bsim.query.client.Configuration;
import ghidra.features.bsim.query.description.DescriptionManager;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.FunctionManager;

public class GenerateSignatures extends GhidraScript {

	@Override
	public void run() throws Exception {
		final String md5string = currentProgram.getExecutableMD5();
		if ((md5string == null) || (md5string.length() < 10)) {
			throw new IOException("Could not get MD5 on file: " + currentProgram.getName());
		}
		final String basename = "sigs_" + md5string;
		System.setProperty("ghidra.output", basename); // Inform parallel controller of output name
		File file = null;
		// This form of askString will work for both standalone execution or for parallel
		final File workingdir = askDirectory("GenerateSignatures:", "Working directory");
		if (!workingdir.isDirectory()) {
			popup("Must select a working directory!");
			return;
		}
		file = new File(workingdir, basename);

		final LSHVectorFactory vectorFactory = FunctionDatabase.generateLSHVectorFactory();
		final GenSignatures gensig = new GenSignatures(true);
		try {
			final String templatename =
				askString("GenerateSignatures:", "Database template", "medium_nosize");
			final Configuration config = FunctionDatabase.loadConfigurationTemplate(templatename);

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Run auto-analysis on the program first (Analysis > Auto Analyze) so the MD5 and other metadata are computed and stored.
  2. Re-import the original binary file so the importer computes the MD5 during import.
  3. Verify the program is backed by a real binary and not a synthetic/empty program created in the listing editor.
  4. If the binary is legitimately hash-less, populate the MD5 programmatically via program.setExecutableMD5() before running the script.

Example fix

// before
String md5string = currentProgram.getExecutableMD5();
if ((md5string == null) || (md5string.length() < 10)) {
    throw new IOException("Could not get MD5 on file: " + currentProgram.getName());
}
//
// after — ensure MD5 exists before running the script
String md5string = currentProgram.getExecutableMD5();
if (md5string == null || md5string.length() < 10) {
    popup("Program has no MD5. Run auto-analysis or re-import the binary first.");
    return;
}
Defensive patterns

Strategy: validation

Validate before calling

String md5 = currentProgram.getExecutableMD5();
if (md5 == null || md5.length() < 10) {
    popup("This program has no MD5 hash. Run auto-analysis or re-import the binary before generating signatures.");
    return;
}

Prevention

When it happens

Trigger: Running GenerateSignatures.run() where currentProgram.getExecutableMD5() returns null or a string with length < 10. This happens before any signature generation or file I/O.

Common situations: The program was imported but never analyzed (MD5 computed during import/analysis); the program file was created from a synthetic/empty binary that has no meaningful hash; the program database is corrupted and the MD5 field is missing; the program was imported from a format that doesn't populate the MD5 metadata.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/e34a4401519ca693. Report an issue: GitHub.