projectdiscovery / naabu

A fast port scanner written in go with a focus on reliability and simplicity. Designed to be used in combination with other tools for attack surface discovery in bug bounties and pentests
https://projectdiscovery.io
MIT License
4.79k stars 551 forks source link

Build fails on OpenBSD: pkg/privileges/privileges.go:6:17: undefined: isPrivileged #976

Closed maybebyte closed 9 months ago

maybebyte commented 9 months ago

Naabu version:

v2.2.1

Current Behavior:

On OpenBSD 7.4, the build fails in the same way as it did for FreeBSD in #782.

github.com/projectdiscovery/naabu/v2/pkg/privileges
# github.com/projectdiscovery/naabu/v2/pkg/privileges
go/pkg/mod/github.com/projectdiscovery/naabu/v2@v2.2.1/pkg/privileges/privileges.go:6:17: undefined: isPrivileged

Expected Behavior:

A successful build without that error.

Steps To Reproduce:

On OpenBSD 7.4, install Go and then run go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@v2.2.1.

Anything else:

$ go version
go version go1.21.1 openbsd/amd64

Also, the code required to patch this probably looks similar to #856. I threw this together and it works on OpenBSD, so os.Geteuid is supported:

package main

import (
    "fmt"
    "os"
)

func main()  {
    fmt.Println(os.Geteuid())
}

Maybe it makes sense to generalize the fix for this somehow so that other systems (NetBSD, Dragonfly BSD) have a chance of working as well? Not sure how to do this offhand, I've only written really minor things in Go.

maybebyte commented 9 months ago

Seems like you all resolved the issue, thank you! I can successfully build the binary by cloning the repository, checking out the dev branch, and using gmake build.

$ git clone https://github.com/projectdiscovery/naabu
$ cd naabu
$ git checkout dev
$ cd v2
$ gmake build

Here's the output of the health check:

$ ./naabu -health-check
Version: 2.2.1
Operative System: openbsd
Architecture: amd64
Go Version: go1.21.1
Compiler: gc
Privileged/NET_RAW: Ko
Config file "/home/bugbounty/.config/naabu/config.yaml" Read => Ok
Config file "/home/bugbounty/.config/naabu/config.yaml" Write => Ok
TCP IPv4 connectivity to scanme.sh:80 => Ok
TCP IPv6 connectivity to scanme.sh:80 => Ok
UDP IPv4 connectivity to scanme.sh:80 => Ok
UDP IPv6 connectivity to scanme.sh:80 => Ok