吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1242|回复: 1
收起左侧

[Other] GoReSym

[复制链接]
风吹屁屁凉 发表于 2026-10-12 17:44

GoReSym

GoReSym Logo

GoReSym is a Go symbol parser that extracts program metadata (such as CPU architecture, OS, endianness, compiler version, etc), function metadata (start & end addresses, names, sources), filename and line number metadata, and embedded structures and types. This cross platform program is based directly on the open source Go compiler and runtime code.

The upstream Go runtime code is extended to handle:

  • stripped binaries
  • malformed unpacked binaries, such as from UPX
  • binaries that split single data ranges across multiple sections
  • the location of the moduledata structure

Usage

Refer to https://www.mandiant.com/resources/blog/golang-internals-symbol-recovery for reverse engineering details and example usage.

You can download pre-built linux, macos, and windows GoReSym binaries from the Releases tab.

To build from source with a recent Go compiler, invoke the Go compiler:

go build

Once built invoke GoReSym like this:

GoReSym.exe -t -d -p /path/to/input.exe

In this example, we ask GoReSym to recover type names (-t), user package names, standard Go package names (-d), and input file paths (-p) embedded within the file /path/to/input.exe. The output looks like this:

{
    "Version": "1.14.15",
    "BuildId": "Zb9QmokKTiOUgHKmaIwz/wd2rtE3W9PN-um1Ocdzh/qTdqcTY_jVajHy_-TtYv/Z_kJu9M77OjfijEiHMcF",
    "Arch": "amd64",
    "TabMeta": {
        "VA": 5174784,
        "Version": "1.2",
        "Endianess": "LittleEndian",
        "CpuQuantum": 1,
        "CpuQuantumStr": "x86/x64",
        "PointerSize": 8
    },
    "ModuleMeta": {
        "VA": 5678816,
        "Types": 4845568,
        "ETypes": 5171904,
        "Typelinks": {
            "Data": 5171904,
            "Len": 695,
            "Capacity": 695
        },
        "ITablinks": {
            "Data": 5174688,
            "Len": 11,
            "Capacity": 11
        },
        "LegacyTypes": {
            "Data": 0,
            "Len": 0,
            "Capacity": 0
        }
    },
    "Types": [ ... ],
    "Files": [ ... ],
    "Strings": [ ... ],
    "UserFunctions": [ ... ],
    "StdFunctions": [ ... ]
}

Here are all the available flags:

  • -d ("default", optional) flag will print standard Go packages in addition to user packages.
  • -p ("paths", optional) flag will print any file paths embedded in the pclntab.
  • -t ("types", optional) flag will print Go type names.
  • -strings (optional) flag will extract embedded Go strings from the binary by analyzing the string internment table.
  • -m <virtual address> ("manual", optional) flag will dump the RTYPE structure recursively at the given virtual address
  • -v <version string> ("version", optional) flag will override automated version detection and use the provided version. This is needed for some stripped binaries. Type parsing will fail if the version is not accurate.
  • -human (optional) flag will print a flat text listing instead of JSON. Especially useful when printing structure and interface types.
  • -about (optional) flag with print out license information

To import this information into IDA Pro you can run the script found in https://github.com/mandiant/GoReSym/blob/master/IDAPython/goresym_rename.py. It will read a json file produced by GoReSym and set symbols/labels in IDA.

Version Support

As the Go compiler and runtime have changed, so have the embedded metadata structures. GoReSym supports the following combinations of Go releases & metadata:

  • all combinations of ARM64  𝒙  Intel x86/x64  𝒙  MACH-O/ELF/PE  𝒙  big/little endian
  • pclntab parsing: >= Go 1.2
  • moduledata location: >= Go 1.2
  • moduledata type parsing: >= Go 1.5

The moduledata table used to extract types doesn't exist prior to Go 1.5, so this library will never support extracting types from very old Go versions.

This library current handles the pclntab layouts pre 1.2, 1.2, 1.16, 1.18, and 1.20. Note that the pclntab version is always <= the Go runtime version (ex: Go runtime 1.19 uses the 1.18 pclntab layout), we aim to always support the latest runtime versions.

Contributions

Much of the source code from GoReSym is copied from the upstream Go compiler source directory  /internal. To make this work, we've had to massage the source a bit. If you want to contribute to GoReSym, read on so we can explain this import process.

Due to the way Go packages work, we needed to remove the /internal path from the source file tree. This resulted in a lot of copying of internal Go files, where the directory tree is mostly intact but with small changes to many files' imports: references to /internal paths were replaced with github.com/mandiant/GoReSym/.

We also modified many internal structures to export fields and methods. These are not exported by Go upstream because users should not rely upon them. However, the purpose of this tool is to extract internal information, so we're taking on the task of maintaining these structures. It's not a great situation, but it's not easily avoidable. If you update this repository, you must take care to keep these modifications intact. It's probably better to manually merge in commits from upstream rather than copying upstream files wholesale.

I am open to suggestions on how to better structure this project to avoid these issues while still compiling with the typical go build. There is a previous discussion involving Go maintainers here.

Ignoring some trivial changes, most new logic exists in /objfile. For example, the file objfile/internals defines the reversed internal Go structures that GoReSym parses.

References

Changes

  • Added parsing support for Go 1.24 binaries while retaining compatibility with older 1.2 layouts.
  • GoReSym will now also attempt to find the pclntab based on a signature of the runtime_modulesinit initialization method and attempt to repair the pclntab magic (in cases where the pclntab magic has been modified).
  • Extended pcln() functions in objfile/<fileformat> to support byte scanning the pclntab magic
  • Added routines such as DataAfterSection to support signature scan in file format parsers in /debug/<fileformat>
  • Added check to debug/gosym/symtab.go's walksymtab to bail early when the optional symtab section is empty
  • Exported many members and internal structs (changes are too many to enumerate)
  • Removed goobj liner support in objfile/objfile.go's PCLineTable()
  • Added extra sanity checks around loadPeTable (and other format variants) to avoid panic when symbols are present but maliciously modified to be invalid (ref: golang/go#47981)
  • Modified the signatures of some internal functions to provide lower level access to information such as section addresses and offsets
  • Implemented read_memory routines for supported file formats to read file data by virtual address
  • Introduced moduledata scan routines to help locate moduledata in support of scanning for types and interfaces (via typelinks)
  • Added size guards to readStringTable for invalid symbol tables. Parsing failures are ignored as well.

License

MIT

https://github.com/mandiant/GoReSym/releases

免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
xuhao4577062311 + 1 + 1 我很赞同!

查看全部评分

发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

那些年打的飞机 发表于 2026-10-12 20:46
GoReSym 是一款 Go 语言符号解析器,主要用于提取程序的各类元数据,包括:
程序基础信息:如 CPU 架构、操作系统、字节序、编译器版本等;
函数元数据:函数的起始与结束地址、名称及源码位置;
代码定位信息:文件名和行号;
类型信息:内嵌的结构体和类型定义。
这款跨平台工具直接基于开源的 Go 编译器和运行时(runtime)代码构建。在原有上游 Go 运行时代码的基础上,它进行了扩展,以支持处理以下特殊情况:
被 strip(剥离符号表)的二进制文件;
解包后格式损坏的二进制文件(例如经过 UPX 压缩的);
将单个数据范围拆分到多个段(sections)中的二进制文件;
准确定位 moduledata 结构体。
使用说明
关于逆向工程的详细细节和使用示例,请参考:Mandiant 博客:Golang Internals & Symbol Recovery
你可以直接在 Releases 页面下载预编译好的 Linux、macOS 和 Windows 版本。
如果需要从源码构建,只需使用较新版本的 Go 编译器执行构建命令即可:
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-10-16 19:49

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表