Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct name not obfuscated on struct bound methods #405

Open
rodjunger opened this issue Oct 18, 2021 · 6 comments
Open

Struct name not obfuscated on struct bound methods #405

rodjunger opened this issue Oct 18, 2021 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@rodjunger
Copy link

rodjunger commented Oct 18, 2021

What version of Garble and Go are you using?

$ garble version
v0.4.1-0.20210929123233-e7320ec9c034
$ go version
go version go1.17.2 linux/amd64

What environment are you running Garble on?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/redacted/.cache/go-build"
GOENV="/home/redacted/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/redacted/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/redacted/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/redacted/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build143792801=/tmp/go-build -gno-record-gcc-switches"

What did you do?

GOPRIVATE=* garble -literals -seed=random -tiny build

What did you expect to see?

main.(*jjf9Sh9s).iW1puRey.func8
maybe even
83hd8as.(*jjf9Sh9s).iW1puRey.func8

What did you see instead?

main.(*Task).iW1puRey.func8

Hey, not sure if this is a limitation of the obfuscator or a bug, but although the function names are obfuscated, the name of the struct the function is bound to is not obfusacated, which can facilitate reverse engineering.

I can simply do a search and replace before building to some randomized string and it works, but I do understand that there might be some technical reason to why it can't be done automatically.

Hiding "main" would also be helpful but not as much I guess, since the entry point is easy to find anyway.

Thanks for the package by the way, gives me some peace of mind while distributing my code.

@lu4p
Copy link
Member

lu4p commented Oct 18, 2021

Can you provide some sample code so we can understand your suggestions better?

@rodjunger
Copy link
Author

rodjunger commented Oct 18, 2021

Sure!

type Task struct {
    Anything int
}

func (task *Task) do_something() {
    fmt.Println(task.Anything)
}

func main(){
    test := Task{Anything: 1}
    test.do_something()
}

If you build this and run strings binary | grep Task you should get something like main.(*Task).iW1puRey.func8 in the results instead of nothing (which would be the ideal I guess).

The "bug" (if it is a bug) is struct names not being obfuscated on main

@capnspacehook
Copy link
Contributor

I believe this behavior is due to this logic which I think is outdated, as garble doesn't support plugins anymore: https://github.com/burrowers/garble/blob/master/main.go#L1354

@lu4p
Copy link
Member

lu4p commented Oct 18, 2021

I think we still eventually want to support plugins as per #87, so the fix here is probably to only do this when -buildmode=plugin

@mvdan
Copy link
Member

mvdan commented Oct 18, 2021

Their assessment is right; that's why that bit of code has a TODO. Right now it's too conservative.

I think it would be reasonable to comment out or disable that bit of code entirely, for now. We simply don't support nor test any alternative build modes just yet.

@mvdan mvdan added the good first issue Good for newcomers label Oct 22, 2021
@lu4p lu4p added the enhancement New feature or request label Dec 6, 2023
@mvdan
Copy link
Member

mvdan commented Dec 6, 2023

Was this not fixed by 474a919? As far as I can tell, we have no other logic currently to attempt to support plugins in any way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Development

No branches or pull requests

4 participants