Skip to content

How to reverse a stack trace of a executable file that was built with -seed=random? #696

@nghia-nguyen-ts

Description

@nghia-nguyen-ts

What version of Garble and Go are you using?

$ garble version
mvdan.cc/garble v0.9.3

Build settings:
      -buildmode exe
       -compiler gc
     CGO_ENABLED 1
          GOARCH arm64
            GOOS darwin
$ go version
go version go1.20.1 darwin/arm64

What environment are you running Garble on?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/nghianguyen/Library/Caches/go-build"
GOENV="/Users/nghianguyen/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/nghianguyen/go/pkg/mod"
GONOPROXY="github.com/tsocial/*"
GONOSUMDB="github.com/tsocial/*"
GOOS="darwin"
GOPATH="/Users/nghianguyen/go"
GOPRIVATE="github.com/tsocial/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/nghianguyen/Desktop/playground/garble/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/26/qs1y2gzs5xl1sslkyxvbzv_80000gr/T/go-build2983500078=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Build an executable file by: garble build -seed=random main.go, the main.go has some panic inside and prints stack trace.
  2. Run main executable file and copy output to stack.txt.
  3. garble reverse main.go stack.txt.
  4. garble -seed=random reverse main.go stack.txt.

What did you expect to see?

Step 3 and 4 print the un-obfuscated stack trace.

What did you see instead?

Step 3. nor 4. prints the un-obfuscated stack trace.

Question

garble -seed=X reverse main.go stack.txt would prints the un-obfuscated stack trace if X is the value of the random seed used by step 1, right? So can we print the random seed upon garble -seed=random build for later reverse usage?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions