← 返回列表

Ghostrings is a collection of Ghidra scripts for recovering string definitions i

聚合站 SecWiki技术 入库 2026-11-18T14:42:37

Scripts for recovering string definitions in Go binaries with P-Code analysis. Tested with x86, x86-64, ARM, and ARM64.

These can be found in the Golang category in the Script Manager.

There are also a couple of special variations of the dynamic string analysis script:

This can be found in the PCode category in the Script Manager.

Here’s the general flow for using these scripts to recover string definitions in a Go binary:

  1. Clear all incorrect or automatically defined strings in the read-only data memory block.
    - In the "Defined Strings" window, enable the "Mem Block" column and filter by memory block to select all strings in .rodata, .rdata, or __rodata. Then right-click in the code listing and choose "Clear Code Bytes".
  2. (Optional) Run GoKnownStrings.java to detect some standard strings.
  3. Run GoStaticStrings.java.
  4. Run GoFuncCallStrings.java (if the Golang binary version is supported by Ghidra's built-in Golang features).
  5. Run GoDynamicStrings.java.
  6. Run GoStringFiller.java.
    - If it detects a violation of the ascending length order of string data, clear any false positive string definitions in that area and re-run the script. There is an option to do this automatically.
    - If the binary is stripped, locate the area of one byte strings found by the dynamic strings script.
    Ensure it's the start of the grouped together non-null-terminated strings (more strings should be defined after with length in ascending order).
    Create the label go.string.* at the first one byte string.
  7. Check for remaining gaps in go.string.*, and define any strings with obvious start and end points.
    - To make the most use of GoStringFiller.java, identify where the string lengths are changing over in undefined string data and define the strings closest to that boundary. Then re-run GoStringFiller.java to automatically fill in spots where it can correctly determine the length of remaining undefined strings.
  8. (Optional) Re-run Ghidra's built-in ASCII String analysis tool.
    - Disable overwriting existing strings. Run with and then without the null terminator requirement.

In Ghidra:

  1. File -> Install Extensions -> Add extension
  2. Select the extension ZIP file

For Eclipse with GhidraDev plugin:

  1. Clone repo
  2. File -> Import -> Projects from Folder or Archive
  3. Select repo directory
  4. GhidraDev -> Link Ghidra...
  5. Select imported project

Build with Eclipse:

Build directly with Gradle:

$ cd Ghostrings
$ gradle -PGHIDRA_INSTALL_DIR=<ghidra_install_dir>

A well-known issue with reverse engineering Go programs is that the lack of null terminators in Go strings makes recovering string definitions from compiled binaries difficult. Many of a Go program's constant string values are stored together in one giant blob in the compiled build, without any terminator characters built into the string data to mark where one string ends and another begins. Even a simple program that just prints "Hello world!" has over 1,500 strings in it related to the Go runtime system and other standard libraries. This can cause typical ASCII string discovery implementations, such as the one provided by Ghidra, to create false positive string definitions that are tens of thousands of characters long.

Instead of null terminated strings, Go uses a string structure that consists of a pointer and length value. Many of these string structures are created on the program’s stack at runtime, so recovering individual string start locations and length values requires analyzing the compiled machine code. There are a few existing scripts that perform this analysis by checking for certain patterns of x86-64 instructions, but they miss structures created with unhandled variations of instructions that ultimately have the same effect on the stack, and they're also restricted to a specific ISA.

Ghostrings avoids both these problems by working with the simplified, architecture independent P-Code operations produced by Ghidra’s decompiler analysis.

Copyright 2022 NCC Group. Released under the GPLv3 license (see LICENSE).

Main project author: James Chambers james.chambers@nccgroup.com

原文链接:https://github.com/nccgroup/ghostrings