goretk / redress

Redress - A tool for analyzing stripped Go binaries
GNU Affero General Public License v3.0
907 stars 58 forks source link

failed to get types data section: section does not exist. #23

Open sigg3net opened 2 years ago

sigg3net commented 2 years ago

Can't extract types (tested both main and develop branches):

$ ./redress t all my_app -m
Error when enumerating types: failed to get types data section: section does not exist.

May or not be related (I was not able to reproduce this):

 $ ./redress types interface my_app
panic: runtime error: slice bounds out of range [31829935:9837384]

goroutine 1 [running]:
github.com/goretk/gore.glob..func30(0x40e3e7?, 0xf0?)
    /home/user/go/src/github.com/redress/gore/type2.go:992 +0xd7
github.com/goretk/gore.(*typeParser).resolveName(0xc000124210, 0x1e5afae, 0x0)
    /home/user/go/src/github.com/redress/gore/type2.go:151 +0x39
github.com/goretk/gore.(*typeParser).parseType(0xc000124210, 0x2118ec0)
    /home/user/go/src/github.com/redress/gore/type2.go:237 +0x1e5
github.com/goretk/gore.(*typeParser).parseType(0xc000124210, 0x1989600)
    /home/user/go/src/github.com/redress/gore/type2.go:480 +0xf25
github.com/goretk/gore.getTypes(0xc000012280, {0x709da0, 0xc00006eab0})
    /home/user/go/src/github.com/redress/gore/type.go:81 +0x38f
github.com/goretk/gore.(*GoFile).GetTypes(0xc000188000)
    /home/user/go/src/github.com/redress/gore/file.go:319 +0x71
main.listTypes({0x7ffcc6ef11cb?, 0xc00014fd98?}, {0x0, 0x1, 0x0, 0x0, 0x0, 0x0, {0x6a2ab8, 0x6}})
    /home/user/go/src/github.com/redress/type.go:134 +0x165
main.init.7.func1(0xc000176780?, {0xc000078300, 0x2, 0x2?})
    /home/user/go/src/github.com/redress/type.go:76 +0x1c5
github.com/spf13/cobra.(*Command).execute(0xc000176780, {0xc0000782c0, 0x2, 0x2})
    /home/user/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:860 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0x8758c0)
    /home/user/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
    /home/user/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902
main.main()
    /home/user/go/src/github.com/redress/main.go:25 +0x25
sigg3net commented 2 years ago

Please note, running go build did not work:

$ go build
info.go:14:2: github.com/goretk/gore@v0.10.0 (replaced by ./gore): reading gore/go.mod: open /home/user/go/src/github.com/redress/gore/go.mod: no such file or directory

so I did:

$ rmdir gore
$ ln -s ~/go/src/github.com/gore gore

and it fails with:

./redress t interface my_app --version go1.18
Error when enumerating types: failed to parse type at offset 0xae420: failed to parse resolved type for 0x198a6c0: method name for type at 0x1ce7a60 has an invalid address (0x6e616765).
sigg3net commented 2 years ago

Also tried with pygore, using this methodology: https://go-re.tk/pygore/

Running: types = f.get_types() yields ValueError: NULL pointer access

In [11]: f.get_unknown_packages()                                               
Out[11]: []

In [12]: f.get_packages()                                                       
Out[12]: []

So this might very well be a problem with gore and not redress.

sigg3net commented 2 years ago

Here is what I tried now:

git clone https://github.com/goretk/redress.git
git clone https://github.com/goretk/gore.git
cd gore
git reset --hard 141f38f24c76dffd798c5cbad48d05129ce9b9b5
cd ../redress
rm -rf gore
ln -s ../gore gore
go build

but when I try to extract types:

$ ./redress types struct my_app
panic: runtime error: slice bounds out of range [31829935:9837384]

and the rest of the panic is in my post above.

TcM1911 commented 2 years ago

Which version of redress are you using? The error in the first comment is that the data section could not be found. What kind of binary is it? Does it have a data section?

The dev branch of redress uses the dev branch of gore. So to compile that branch you need to checkout the submodule.