nicocha30 / ligolo-ng

An advanced, yet simple, tunneling/pivoting tool that uses a TUN interface.
GNU General Public License v3.0
2.62k stars 260 forks source link

Ligolo doesn't work with golang version 20 #32

Closed QU35T-code closed 1 year ago

QU35T-code commented 1 year ago

Hello,

There is a problem with the proxy build (agent is ok) with golang version 20. The build with version 19 is functional but an error occurs with version 20.

root@f33e8b06d6cc:/opt/tools/ligolo-ng# wget -O /tmp/go.tar.gz https://go.dev/dl/go1.19.linux-arm64.tar.gz

Saving to: '/tmp/go.tar.gz'

root@f33e8b06d6cc:/opt/tools/ligolo-ng# tar -C /usr/local -xzf /tmp/go.tar.gz
root@f33e8b06d6cc:/opt/tools/ligolo-ng# /usr/local/go/bin/go build -o proxy cmd/proxy/main.go

[...BUILD OK...]
root@f33e8b06d6cc:/opt/tools/ligolo-ng# wget -O /tmp/go.tar.gz https://go.dev/dl/go1.20.linux-arm64.tar.gz

Saving to: '/tmp/go.tar.gz'

root@f33e8b06d6cc:/opt/tools/ligolo-ng# tar -C /usr/local -xzf /tmp/go.tar.gz
root@f33e8b06d6cc:/opt/tools/ligolo-ng# /usr/local/go/bin/go build -o proxy cmd/proxy/main.go

# github.com/nicocha30/gvisor-ligolo/pkg/gohacks
/root/go/pkg/mod/github.com/nicocha30/gvisor-ligolo@v0.0.0-20230201100237-f26fe0a6c03c/pkg/gohacks/string_go120_unsafe.go:27:7: unsafe.StringData requires go1.20 or later (-lang was set to go1.18; check go.mod)
/root/go/pkg/mod/github.com/nicocha30/gvisor-ligolo@v0.0.0-20230201100237-f26fe0a6c03c/pkg/gohacks/string_go120_unsafe.go:38:9: unsafe.String requires go1.20 or later (-lang was set to go1.18; check go.mod)
dismantl commented 1 year ago

Possibly related to this issue: https://github.com/golang/go/issues/58554

I haven't tried this yet but I expect upgrading gvisor-ligolo to the latest upstream gvisor may solve this problem, as upstream now sets go1.20 as the minimum version.

I'd be happy to submit a PR but am unsure exactly what changes the fork has. I see that ICMP handling was removed, but are there other changes too?

dismantl commented 1 year ago

I was able to get ligolo-ng to build successfully with go 1.20 by using an updated gvisor fork. Here's the branch I used, and you can see that there are a few minor changes needed relating to updated type definitions in the latest gvisor.

ikstream commented 1 year ago

Hi, are there any updates on this @nicocha30?

nicocha30 commented 1 year ago

Hey,

I'm working on it today. Will keep you updated.

Nicolas

ikstream commented 1 year ago

Thank you very much

nicocha30 commented 1 year ago

Done! After struggling with gvisor and the CI, release 0.4.4 now supports Go >= 1.20.

https://github.com/nicocha30/ligolo-ng/releases/tag/v0.4.4

ikstream commented 1 year ago

Thank you, works like a charm, as far as I can tell.