NationalSecurityAgency/ghidra · error · IOException

Could not get MD5 on file:

Error message

Could not get MD5 on file: 

What it means

The Jython/Python variant of GenerateSignatures performs the same MD5 check: if currentProgram.getExecutableMD5() is None or has length < 10, it raises IOException. The logic is identical to the Java version but expressed in Jython. This is the Python-script entry point for BSim signature generation.

Source

Thrown at Ghidra/Features/BSim/ghidra_scripts/GenerateSignatures.py:29

# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##
#Generate signatures for every function in the current program and write them to an XML file in a user-specified directory
#@category BSim.Python
#@runtime Jython

import java.lang.System as System
import java.io.File as File
import ghidra.features.bsim.query.FunctionDatabase as FunctionDatabase
import ghidra.features.bsim.query.GenSignatures as GenSignatures
import java.io.FileWriter as FileWriter

def run():
    md5String = currentProgram.getExecutableMD5()
    if (md5String is None) or (len(md5String) < 10):
        raise IOException("Could not get MD5 on file: " + currentProgram.getName())
    basename = "sigs_" + md5String
    System.setProperty("ghidra.output",basename)
    workingDir = askDirectory("GenerateSignatures:", "Working Directory")
    if not workingDir.isDirectory():
        popup("Must select a working directory")
        return
    outfile = File(workingDir,basename)
    vectorFactory = FunctionDatabase.generateLSHVectorFactory()
    gensig = GenSignatures(True)
    templateName = askString("GenerateSignatures:", "Database template", "medium_nosize")
    config = FunctionDatabase.loadConfigurationTemplate(templateName)
    vectorFactory.set(config.weightfactory, config.idflookup, config.info.settings)
    gensig.setVectorFactory(vectorFactory)
    gensig.addExecutableCategories(config.info.execats)
    gensig.addFunctionTags(config.info.functionTags)
    gensig.addDateColumnName(config.info.dateColumnName)
    repo = "ghidra://localhost/" + state.getProject().getName()
    path = GenSignatures.getPathFromDomainFile(currentProgram)

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Run auto-analysis on the current program so the MD5 is computed.
  2. Re-import the original binary to populate the MD5 during import.
  3. Prefer the Java GenerateSignatures.java script if Jython interop issues are suspected.
  4. Check the program metadata via the Ghidra GUI (Program > Program Information) to confirm the MD5 field is populated.

Example fix

# before
if (md5String is None) or (len(md5String) < 10):
    raise IOException("Could not get MD5 on file: " + currentProgram.getName())
#
# after — guard with a user-friendly popup
if (md5String is None) or (len(md5String) < 10):
    popup("Program has no MD5. Run auto-analysis or re-import first.")
    return
Defensive patterns

Strategy: validation

Validate before calling

md5String = currentProgram.getExecutableMD5()
if md5String is None or len(md5String) < 10:
    popup("Program has no MD5. Run auto-analysis or re-import the binary first.")
    return

Prevention

When it happens

Trigger: Running GenerateSignatures.py in the Ghidra Jython script engine where currentProgram.getExecutableMD5() returns None or a string shorter than 10 characters.

Common situations: Same as the Java variant: unanalyzed program, synthetic program, corrupted program database, or re-imported listing without MD5 metadata. Python users may additionally hit this if they run the script on a program object that hasn't been fully loaded into the current Ghidra tool context.

Related errors


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