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.69k stars 547 forks source link

No valid ipv4 or ipv6 targets were found with running as library in docker container #898

Closed Ice3man543 closed 9 months ago

Ice3man543 commented 10 months ago

Naabu version:

Latest

Current Behavior:

An error No valid ipv4 or ipv6 targets were found occurs when running as code inside of docker container. only occurs when using syn scan mode, doesn't happen with connect. Seems to be related to Host Discovery as disabling host discovery using SkipHostDiscovery: true works.

Expected Behavior:

Should run scan in syn mode as well.

Steps To Reproduce:

Create a go program with below code

        targets := []string{"scanme.sh"}
    options := runner.Options{
        Verbose:  true,
        Debug:    true,
        Host:     targets,
        ScanType: "s",
        Silent:   true,
        OnResult: func(hr *result.HostResult) {
            for _, port := range hr.Ports {
                result := net.JoinHostPort(hr.Host, strconv.Itoa(port.Port))
                fmt.Printf("got portscan: %s\n", result)
            }
        },
        TopPorts: "100",
        Threads:  25,
        Rate:     1000,
        Timeout:  1000,
        Retries:  3,
    }

    naabuRunner, err := runner.NewRunner(&options)
    if err != nil {
        return err
    }
    defer naabuRunner.Close()

    if err := naabuRunner.RunEnumeration(); err != nil {
        return err
    }

Anything else:

Happens when running inside a docker container. Doesn't occur outside it.

dogancanbakir commented 10 months ago

options.ConfigureHostDiscovery() is the missing line in your example; to enable default probes, we must call it. I'll keep this issue open and probably move this to NewRunner or elsewhere to prevent others from suffering.