Skip to content

Commit

Permalink
fix: support for go 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Chatelain committed Jul 26, 2023
1 parent ee150f6 commit df68495
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 681 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: goreleaser

on:
pull_request:
push:

permissions:
Expand All @@ -20,7 +19,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: 1.20
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ This allows running tools like *nmap* without the use of *proxychains* (simpler
Precompiled binaries (Windows/Linux/macOS) are available on the [Release page](https://github.com/nicocha30/ligolo-ng/releases).

### Building Ligolo-ng
Building *ligolo-ng* (Go >= 1.17 is required):
Building *ligolo-ng* (Go >= 1.20 is required):

```shell
$ go build -o agent cmd/agent/main.go
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nicocha30/ligolo-ng

go 1.17
go 1.20

require (
github.com/AlecAivazis/survey/v2 v2.3.5
Expand All @@ -10,12 +10,12 @@ require (
github.com/jedib0t/go-pretty/v6 v6.3.5
github.com/sirupsen/logrus v1.9.0
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
golang.org/x/net v0.0.0-20220708220712-1185a9018129
golang.org/x/net v0.5.0
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224 // indirect
golang.zx2c4.com/wireguard v0.0.0-20220703234212-c31a7b1ab478
)

require github.com/nicocha30/gvisor-ligolo v0.0.0-20230201100237-f26fe0a6c03c
require github.com/nicocha30/gvisor-ligolo v0.0.0-20230726075806-989fa2c0a413

require (
github.com/desertbit/closer/v3 v3.1.3 // indirect
Expand All @@ -34,8 +34,8 @@ require (
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/rivo/uniseg v0.2.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/term v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
)
671 changes: 10 additions & 661 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pkg/proxy/netstack/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package netstack

import (
"github.com/hashicorp/yamux"
"github.com/nicocha30/gvisor-ligolo/pkg/tcpip"
"github.com/nicocha30/gvisor-ligolo/pkg/tcpip/adapters/gonet"
"github.com/nicocha30/gvisor-ligolo/pkg/tcpip/header"
"github.com/nicocha30/gvisor-ligolo/pkg/tcpip/stack"
Expand Down Expand Up @@ -84,7 +85,7 @@ func HandlePacket(nstack *stack.Stack, localConn TunConn, yamuxConn *yamux.Sessi
return
}

if endpointID.LocalAddress.To4() != "" {
if endpointID.LocalAddress.To4() != (tcpip.Address{}) {
protonet = protocol.Networkv4
} else {
protonet = protocol.Networkv6
Expand Down
13 changes: 6 additions & 7 deletions pkg/proxy/netstack/icmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package netstack
import (
"bytes"
"errors"
"github.com/nicocha30/gvisor-ligolo/pkg/bufferv2"
"github.com/nicocha30/gvisor-ligolo/pkg/buffer"
"github.com/nicocha30/gvisor-ligolo/pkg/tcpip"
"github.com/nicocha30/gvisor-ligolo/pkg/tcpip/checksum"
"github.com/nicocha30/gvisor-ligolo/pkg/tcpip/header"
Expand Down Expand Up @@ -61,7 +61,7 @@ func icmpResponder(s *NetStack) error {

// Reconstruct a ICMP PacketBuffer from bytes.

view := bufferv2.MakeWithData(buff.Bytes())
view := buffer.MakeWithData(buff.Bytes())
packetbuff := stack.NewPacketBuffer(stack.PacketBufferOptions{
Payload: view,
ReserveHeaderBytes: hlen,
Expand Down Expand Up @@ -127,12 +127,11 @@ func ProcessICMP(nstack *stack.Stack, pkt stack.PacketBufferPtr) {
localAddressBroadcast := pkt.NetworkPacketInfo.LocalAddressBroadcast

// It's possible that a raw socket expects to receive this.
pkt = stack.PacketBufferPtr{}
_ = pkt // Suppress unused variable warning.
pkt = nil

// Take the base of the incoming request IP header but replace the options.
replyHeaderLength := uint8(header.IPv4MinimumSize + len(newOptions))
replyIPHdrView := bufferv2.NewView(int(replyHeaderLength))
replyIPHdrView := buffer.NewView(int(replyHeaderLength))
replyIPHdrView.Write(iph[:header.IPv4MinimumSize])
replyIPHdrView.Write(newOptions)
replyIPHdr := header.IPv4(replyIPHdrView.AsSlice())
Expand All @@ -143,7 +142,7 @@ func ProcessICMP(nstack *stack.Stack, pkt stack.PacketBufferPtr) {
// or multicast address).
localAddr := ipHdr.DestinationAddress()
if localAddressBroadcast || header.IsV4MulticastAddress(localAddr) {
localAddr = ""
localAddr = tcpip.Address{}
}

r, err := nstack.FindRoute(1, localAddr, ipHdr.SourceAddress(), ipv4.ProtocolNumber, false /* multicastLoop */)
Expand All @@ -162,7 +161,7 @@ func ProcessICMP(nstack *stack.Stack, pkt stack.PacketBufferPtr) {
replyICMPHdr.SetChecksum(0)
replyICMPHdr.SetChecksum(^checksum.Checksum(replyData.AsSlice(), 0))

replyBuf := bufferv2.MakeWithView(replyIPHdrView)
replyBuf := buffer.MakeWithView(replyIPHdrView)
replyBuf.Append(replyData.Clone())
replyPkt := stack.NewPacketBuffer(stack.PacketBufferOptions{
ReserveHeaderBytes: int(r.MaxHeaderLength()),
Expand Down
8 changes: 5 additions & 3 deletions pkg/proxy/netstack/tun/wireguard_ep.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package tun

import (
"github.com/nicocha30/gvisor-ligolo/pkg/bufferv2"
"github.com/nicocha30/gvisor-ligolo/pkg/buffer"
"github.com/nicocha30/gvisor-ligolo/pkg/tcpip"
"github.com/nicocha30/gvisor-ligolo/pkg/tcpip/header"
"github.com/nicocha30/gvisor-ligolo/pkg/tcpip/stack"
Expand Down Expand Up @@ -64,7 +64,7 @@ func (m *RWEndpoint) dispatchLoop() {
}

pkb := stack.NewPacketBuffer(stack.PacketBufferOptions{
Payload: bufferv2.MakeWithData(packet[:n]),
Payload: buffer.MakeWithData(packet[:n]),
})

switch header.IPVersion(packet) {
Expand Down Expand Up @@ -95,7 +95,7 @@ func (m *RWEndpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error

// WritePacket writes outbound packets
func (m *RWEndpoint) WritePacket(pkt stack.PacketBufferPtr) tcpip.Error {
var buf bufferv2.Buffer
var buf buffer.Buffer
pktBuf := pkt.ToBuffer()
buf.Merge(&pktBuf)

Expand All @@ -121,3 +121,5 @@ func (*RWEndpoint) AddHeader(pkt stack.PacketBufferPtr) {
func (*RWEndpoint) WriteRawPacket(stack.PacketBufferPtr) tcpip.Error {
return &tcpip.ErrNotSupported{}
}

func (*RWEndpoint) ParseHeader(stack.PacketBufferPtr) bool { return true }

0 comments on commit df68495

Please sign in to comment.