goretk / gore Goto Github PK
View Code? Open in Web Editor NEWGoRE - Package gore is a library for analyzing Go binaries
License: GNU Affero General Public License v3.0
GoRE - Package gore is a library for analyzing Go binaries
License: GNU Affero General Public License v3.0
[gore]$ GOOS=linux go build -o test -ldflags='-s -w -buildid=' testdata/simple.go
[gore]$ file test
test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
[gore]$ redress -compiler test
2019/10/26 14:41:06 Error when opening the file: error when getting note section section does not exist
Works for Windows and macOS binaries:
[gore]$ GOOS=windows go build -o test -ldflags='-s -w -buildid=' testdata/simple.go
[gore]$ redress -compiler test
Compiler version: go1.13.1 (2019-09-25T18:48:17Z)
[gore]$ GOOS=darwin go build -o test -ldflags='-s -w -buildid=' testdata/simple.go
[gore]$ redress -compiler test
Compiler version: go1.13.1 (2019-09-25T18:48:17Z
I'm playing with some golang compiler arguments, and I found a linkmode=external buildmode=pie
bianry can work without .gopclntab
section.
The example file placed at https://github.com/Zxilly/go-testdata/releases/download/latest/bin-linux-1.21-amd64-ext-pie
, and the readelf -S -W
reported as below.
There are 48 section headers, starting at offset 0x6ec970:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 0000000000000350 000350 00001c 00 A 0 0 1
[ 2] .note.gnu.property NOTE 0000000000000370 000370 000020 00 A 0 0 8
[ 3] .note.gnu.build-id NOTE 0000000000000390 000390 000024 00 A 0 0 4
[ 4] .note.ABI-tag NOTE 00000000000003b4 0003b4 000020 00 A 0 0 4
[ 5] .note.go.buildid NOTE 00000000000003d4 0003d4 000064 00 A 0 0 4
[ 6] .gnu.hash GNU_HASH 0000000000000438 000438 000034 00 A 7 0 8
[ 7] .dynsym DYNSYM 0000000000000470 000470 000570 18 A 8 1 8
[ 8] .dynstr STRTAB 00000000000009e0 0009e0 000323 00 A 0 0 1
[ 9] .gnu.version VERSYM 0000000000000d04 000d04 000074 02 A 7 0 2
[10] .gnu.version_r VERNEED 0000000000000d78 000d78 000060 00 A 8 1 8
[11] .rela.dyn RELA 0000000000000dd8 000dd8 06cc78 18 A 7 0 8
[12] .rela.plt RELA 000000000006da50 06da50 000480 18 AI 7 26 8
[13] .init PROGBITS 000000000006e000 06e000 00001b 00 AX 0 0 4
[14] .plt PROGBITS 000000000006e020 06e020 000310 10 AX 0 0 16
[15] .plt.got PROGBITS 000000000006e330 06e330 000008 08 AX 0 0 8
[16] .text PROGBITS 000000000006e340 06e340 21efe7 00 AX 0 0 32
[17] .fini PROGBITS 000000000028d328 28d328 00000d 00 AX 0 0 4
[18] .rodata PROGBITS 000000000028e000 28e000 077370 00 A 0 0 32
[19] .eh_frame_hdr PROGBITS 0000000000305370 305370 00016c 00 A 0 0 4
[20] .eh_frame PROGBITS 00000000003054e0 3054e0 000690 00 A 0 0 8
[21] .tbss NOBITS 00000000003074d0 3064d0 000008 00 WAT 0 0 8
[22] .init_array INIT_ARRAY 00000000003074d0 3064d0 000008 08 WA 0 0 8
[23] .fini_array FINI_ARRAY 00000000003074d8 3064d8 000008 08 WA 0 0 8
[24] .data.rel.ro PROGBITS 00000000003074e0 3064e0 1c2750 00 WA 0 0 32
[25] .dynamic DYNAMIC 00000000004c9c30 4c8c30 0001f0 10 WA 8 0 8
[26] .got PROGBITS 00000000004c9e20 4c8e20 0001c8 08 WA 0 0 8
[27] .data PROGBITS 00000000004ca000 4c9000 008a50 00 WA 0 0 32
[28] .go.buildinfo PROGBITS 00000000004d2a50 4d1a50 000280 00 WA 0 0 16
[29] .noptrdata PROGBITS 00000000004d2ce0 4d1ce0 026722 00 WA 0 0 32
[30] .bss NOBITS 00000000004f9420 4f8402 02fea0 00 WA 0 0 32
[31] .noptrbss NOBITS 00000000005292c0 4f8402 006af0 00 WA 0 0 32
[32] .comment PROGBITS 0000000000000000 4f8402 00002b 01 MS 0 0 1
[33] .debug_aranges PROGBITS 0000000000000000 556680 000106 00 C 0 0 8
[34] .debug_info PROGBITS 0000000000000000 556788 09e24a 00 C 0 0 8
[35] .debug_abbrev PROGBITS 0000000000000000 5f49d8 000724 00 C 0 0 8
[36] .debug_line PROGBITS 0000000000000000 5f5100 05b2e1 00 C 0 0 8
[37] .debug_frame PROGBITS 0000000000000000 6503e8 011194 00 C 0 0 8
[38] .debug_str PROGBITS 0000000000000000 661580 0006a3 01 MSC 0 0 8
[39] .debug_loc PROGBITS 0000000000000000 661c28 06a159 00 C 0 0 8
[40] .debug_ranges PROGBITS 0000000000000000 6cbd88 0200ba 00 C 0 0 8
[41] .debug_line_str PROGBITS 0000000000000000 6ebe48 0001ec 01 MSC 0 0 8
[42] .debug_loclists PROGBITS 0000000000000000 6ec038 00066f 00 C 0 0 8
[43] .debug_rnglists PROGBITS 0000000000000000 6ec6a8 000084 00 C 0 0 8
[44] .debug_gdb_scripts PROGBITS 0000000000000000 6ec72c 00003f 00 0 0 1
[45] .symtab SYMTAB 0000000000000000 4f8430 02a660 18 46 7124 8
[46] .strtab STRTAB 0000000000000000 522a90 033bed 00 0 0 1
[47] .shstrtab STRTAB 0000000000000000 6ec76b 000201 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
D (mbind), l (large), p (processor specific)
Support for parsing types from big endian files.
Due to some logic bugs, not all information is extracted correctly.
Enable Go module support.
Currently some tests are failing when in "go mod" mode.
The estimate of function source code lines uses a deprecated function. Update to use the new functions provided by the standard library and improve its accuracy.
How can I overwrite/replace the extracted information in the compiled binary? e.g BuildID, package names etc. I didn't see any exposed methods that can do this.
Full support for MIPS binaries.
I test redress today and get this error:
redress can get compiler version and src correctly, only problems when trying to get the struct/types
The binary I used for test is bettercap
As https://github.com/codecov/codecov-action said:
Deprecation of v1
As of February 1, 2022, v1 has been fully sunset and no longer functions
Due to the deprecation of the underlying bash uploader, the Codecov GitHub Action has released v2/v3 which will use the new uploader. You can learn more about our deprecation plan and the new uploader on our blog.
We will be restricting any updates to the v1 Action to security updates and hotfixes.
But update to v2/v3 required a token from codecov, which can only be set by maintainer. It's hard to create to pr to fix this.
I am using gore to create my own project gsv, but my project is released under the Mozilla Public License 2.0, and I'm not sure if this is compatible with the AGPL that gore uses, so I'd like to get an explicit permit from the author for this use.
Thank you sincerely for your work on gore.
in goroot.go:357
, subpath := fmt.Sprintf("/src/%s", v.Name)
, subpath
will be /src/:packageName
.
in goroot.go:358
, *github.com/goretk/gore.Package.Filepath
will return\usr\local\go\src\:packageName
.
so in goroot.go:358
, if strings.HasSuffix(v.Filepath, subpath)
will alway be false.
if i use this statement subpath := filepath.Join("/src", v.Name)
, it will get expect result.
but, in goroot.go:359
, it will return \usr\local\go
, not equal expectGoRoot
in goroot_test.go
in my project, i use filepath.ToSlash
to deal with the result return from GetGoRoot
. i have no idea, if use filepath.ToSlash
in goroot.go:360
, will it adversely affect the project?
i run go test
, it seems good.
Running tool: go.exe test -timeout 30s -run ^TestExtractGoRoot$ github.com/goretk/gore
=== RUN TestExtractGoRoot
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.10.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.11.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.12.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.13.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.14.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.5.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.6.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.7.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.7beta1
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.8.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.9.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.10.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.11.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.12.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.13.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.14.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.15.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.16.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.17.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.18.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.5.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.6.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.7.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.7beta1
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.8.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.9.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.10.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.11.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.12.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.13.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.14.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.15.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.16.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.17.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.18.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.5.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.6.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.7.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.7beta1
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.8.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-386-1.9.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.10.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.11.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.12.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.13.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.14.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.15.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.16.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.17.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.18.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.5.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.6.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.7.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.7beta1
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.8.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.9.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.10.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.11.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.12.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.13.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.14.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.15.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.16.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.17.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.18.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.5.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.6.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.7.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.7beta1
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.8.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-386-1.9.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.10.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.11.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.12.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.13.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.14.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.15.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.16.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.17.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.18.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.5.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.6.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.7.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.7beta1
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.8.0
=== RUN TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.9.0
--- PASS: TestExtractGoRoot (0.74s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.10.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.11.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.12.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.13.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.14.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.5.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.6.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.7.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.7beta1 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.8.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.9.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.10.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.11.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.12.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.13.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.14.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.15.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.16.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.17.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.18.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.5.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.6.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.7.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.7beta1 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.8.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.9.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.10.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.11.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.12.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.13.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.14.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.15.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.16.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.17.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.18.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.5.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.6.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.7.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.7beta1 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.8.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.9.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.10.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.11.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.12.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.13.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.14.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.15.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.16.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.17.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.18.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.5.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.6.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.7.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.7beta1 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.8.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.9.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.10.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.11.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.12.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.13.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.14.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.15.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.16.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.17.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.18.0 (0.00s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.5.0 (0.02s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.6.0 (0.02s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.7.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.7beta1 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.8.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.9.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.10.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.11.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.12.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.13.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.14.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.15.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.16.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.17.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.18.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.5.0 (0.02s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.6.0 (0.02s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.7.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.7beta1 (0.02s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.8.0 (0.01s)
--- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.9.0 (0.02s)
PASS
ok github.com/goretk/gore 0.805s
The internal structure for the map type has changed between some Go versions. The current parsing logic can't handle Go 1.7 to 1.13. Due to this, if the the map has methods, the parser reads bad data. This bug only affects the develop branch and not the stable branch.
Support PIE binaries.
Create a public struct for moduledata and a function to get it.
support go1.18
Go version I was using: Go 1.13 linux/amd64
I was testing out gore today, and came across a curious bug. I compiled the code below, with no special flags: go build -trimpath -o test.bin main.go
I then ran the file against itself ./test.bin test.bin
, and this error occured:
panic: runtime error: slice bounds out of range [:5203186120246329699] with capacity 1001107
goroutine 1 [running]:
github.com/goretk/gore.parseString(0xc0000c6540, 0xfffff8250c8b4864, 0x401000, 0xc000936000, 0xf4693, 0xf4693, 0x0, 0x0)
github.com/goretk/gore/type.go:785 +0x24e
github.com/goretk/gore.parseUncommonType(0xc0003004b0, 0xc00022f290, 0xc0000c6540, 0xc000936000, 0xf4693, 0xf4693, 0x401000, 0xc00022f140)
github.com/goretk/gore/type.go:805 +0x40a
github.com/goretk/gore.typeParse(0xc00022f140, 0xc0000c6540, 0xed0, 0xc000936000, 0xf4693, 0xf4693, 0x401000, 0x0)
github.com/goretk/gore/type.go:387 +0x353f
github.com/goretk/gore.getLegacyTypes(0xc0000c6540, 0x56cec0, 0xc00000e040, 0xa, 0xffffffffffffffff, 0x8)
github.com/goretk/gore/type.go:107 +0x235
github.com/goretk/gore.getTypes(0xc0000c6540, 0x56cec0, 0xc00000e040, 0x0, 0x4e9c20, 0xc0000b0140)
github.com/goretk/gore/type.go:47 +0x4cc
github.com/goretk/gore.(*GoFile).GetTypes(0xc0000b0140, 0x0, 0x0, 0x0, 0x0, 0x7762a6bf)
github.com/goretk/gore/file.go:262 +0x52
main.main()
command-line-arguments/main.go:21 +0xdc
I also came across this error running this code against various other Go ELF files on my system, so it isn't unique to this file.
Code mentioned above:
package main
import (
"fmt"
"os"
"path"
"github.com/goretk/gore"
)
func main() {
file, err := gore.Open(os.Args[1])
if err != nil {
panic(err)
}
packages, err := file.GetPackages()
if err != nil {
panic(err)
}
types, err := file.GetTypes()
if err != nil {
panic(err)
}
symbols := make([]string, (len(packages) + len(types)*2))
for _, goType := range types {
symbols = append(symbols, path.Join(goType.PackagePath, goType.Name))
}
for _, pkg := range packages {
for _, method := range pkg.Methods {
symbols = append(symbols, path.Join(method.PackageName, method.Name))
}
for _, function := range pkg.Functions {
symbols = append(symbols, path.Join(function.PackageName, function.Name))
}
}
for _, symbol := range symbols {
fmt.Println(symbol)
}
}
EDIT: ran compiled binary through redress
just to make sure I was using gore correctly, and as I thought it panic'd with the same error.
As described in golang/go#65232, gosym.NewLineTable
should be used with the value of symbol runtime.text
but not just use the start of .text
segment, which was used by gore right now.
I have no idea how to implement a search for runtime.text
in the stripped binary, but at least we can show a warning like the offset in func can be incorrect in cgo binary
right now.
I used redress to analyze a program of about 70mb. When using -struct or -interface, the program reported an error.
github.com/goretk/gore.resolveName(...)
github.com/goretk/[email protected]/type.go:980
github.com/goretk/gore.typeParse(0xc000ea1170, 0xc000192e40, 0xed923c, 0xc007bba000, 0x1fbda00, 0x1fbda00, 0x20a5000, 0x0)
github.com/goretk/[email protected]/type.go:371 +0x39fb
github.com/goretk/gore.typeParse(0xc000ea1170, 0xc000192e40, 0x284d20, 0xc007bba000, 0x1fbda00, 0x1fbda00, 0x20a5000, 0x0)
github.com/goretk/[email protected]/type.go:654 +0x148e
github.com/goretk/gore.typeParse(0xc000ea1170, 0xc000192e40, 0x1dcac0, 0xc007bba000, 0x1fbda00, 0x1fbda00, 0x20a5000, 0x0)
github.com/goretk/[email protected]/type.go:418 +0x2529
github.com/goretk/gore.getTypes(0xc000192e40, 0xa05368, 0xc0001120f0, 0x0, 0x9784e0, 0xc00011e280)
github.com/goretk/[email protected]/type.go:76 +0x2a5
github.com/goretk/gore.(*GoFile).GetTypes(0xc00011e280, 0x0, 0x0, 0x0, 0x0, 0x0)
github.com/goretk/[email protected]/file.go:262 +0x59
main.standalone()
github.com/goretk/redress/standalone.go:59 +0x308
main.main()
github.com/goretk/redress/main.go:73 +0x54
When running the following script on a installation of pygore on a debian system i sometimes see erroneous values for kind. These are parsed correctly on a windows installation, using the same binary. I've verified the binaries are not corrupted by checking their hashes.
import pygore
import sys
testfile = sys.argv[1]
f = pygore.GoFile(testfile)
c = f.get_compiler_version()
types = f.get_types()
f.close()
for t in types:
val, = t.kind
if val > 30 :
print(val)
Output:
140033113718791
140033113718785
140033113718803
140033113718803
140033113718786
140033113718809
140033113718807
Support for processing ARM binaries.
here is the scan file md5sum: 02bf1d9f09eb370101bf971c0a0214bc
you can download this file from url below
https://www.virustotal.com/gui/file/56b110a95c2b16784ba053c69f3ffcdbffcef1fdf42214f71d61b9e0d59b9a42
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x58ad15]
goroutine 1 [running]:
github.com/goretk/gore.typeParse(0xd76fe0, 0xc0000c7b00, 0x295800, {0xc001bb6000, 0x435600, 0x435600}, 0x401000)
/home/nobody/go/pkg/mod/github.com/goretk/[email protected]/type.go:497 +0x11d5
github.com/goretk/gore.typeParse(0xc00000e540, 0xc0000c7b00, 0x21d6e0, {0xc001bb6000, 0x435600, 0x435600}, 0x401000)
/home/nobody/go/pkg/mod/github.com/goretk/[email protected]/type.go:578 +0xaed
github.com/goretk/gore.getLegacyTypes(0xc0000c7b00, {0xd7da98, 0xc00000e540})
/home/nobody/go/pkg/mod/github.com/goretk/[email protected]/type.go:129 +0x271
github.com/goretk/gore.getTypes(0xc0000c7b00, {0xd7da98, 0xc00000e540})
/home/nobody/go/pkg/mod/github.com/goretk/[email protected]/type.go:60 +0x3b1
github.com/goretk/gore.(*GoFile).GetTypes(0xc0009f4000)
/home/nobody/go/pkg/mod/github.com/goretk/[email protected]/file.go:319 +0x71
The daily cron job is currently timing out after 6 hours. It appears to be due to the moduledata code generation. It has currently been disabled.
https://github.com/goretk/gore/actions/runs/7862718547
Run go generate ./...
go: downloading github.com/google/go-github/v58 v58.0.0
go: downloading golang.org/x/mod v0.14.0
go: downloading golang.org/x/arch v0.6.0
go: downloading github.com/google/go-querystring v1.1.0
Error when parsing time: parsing time "date" as "2006-01-02T15:04:05Z07:00": cannot parse "date" as "2006"
Error when parsing time: parsing time "date" as "2006-01-02T15:04:05Z07:00": cannot parse "date" as "2006"
Error when parsing time: parsing time "date" as "2006-01-02T15:04:05Z07:00": cannot parse "date" as "2006"
Error when parsing time: parsing time "date" as "2006-01-02T15:04:05Z07:00": cannot parse "date" as "2006"
Error when parsing time: parsing time "date" as "2006-01-02T15:04:05Z07:00": cannot parse "date" as "2006"
/home/runner/work/gore/gore/goversion_gen.go changes detected.
Fetching moduledata for go1.5...
Fetching moduledata for go1.6...
Fetching moduledata for go1.7...
Fetching moduledata for go1.8...
Fetching moduledata for go1.9...
Fetching moduledata for go1.10...
Fetching moduledata for go1.11...
Fetching moduledata for go1.12...
Fetching moduledata for go1.13...
Fetching moduledata for go1.14...
Fetching moduledata for go1.15...
Fetching moduledata for go1.16...
Fetching moduledata for go1.17...
Fetching moduledata for go1.18...
Fetching moduledata for go1.19...
Fetching moduledata for go1.20...
Fetching moduledata for go1.21...
Fetching moduledata for go1.22...
Error: The operation was canceled.
Extract build id from the file and provide it as an attribute.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.