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

Silent doesn't work. Naabu (as a library) is too verbose. #958

Closed ca5ua1 closed 7 months ago

ca5ua1 commented 8 months ago

Hi, I try to use Naabu as a library and the problem I have is that Naabu generate on its own terminal output what I don't want without verbose flag.

Naabu version: v2.2.1

Current Behavior:

When running scan with Naabu library it writes following lines in stdout:

[INF] Running CONNECT scan with non root privileges
[INF] Found 2 ports on host scanme.sh (128.199.158.128)
scanme.sh:443
scanme.sh:80

Even with silent flag set to true

When running Naabu itself with -silent flag the output is:

scanme.sh:443
scanme.sh:80

Expected Behavior:

No output at all with silent flag. Maybe new -silent-full flag or levels to silent flag

Ideally would be amazing to also have control over [INF] Running ... to pass it to log file for example (in context of library usage)

Steps To Reproduce:

Add Silent: true, option to example so it would look like that:

package main

import (
    "log"

    "github.com/projectdiscovery/goflags"
    "github.com/projectdiscovery/naabu/v2/pkg/result"
    "github.com/projectdiscovery/naabu/v2/pkg/runner"
)

func main() {
    options := runner.Options{
        Host:      goflags.StringSlice{"scanme.sh"},
        ScanType: "s",
        OnResult: func(hr *result.HostResult) {
            log.Println(hr.Host, hr.Ports)
        },
        Ports: "80",
                Silent: true,
    }

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

    naabuRunner.RunEnumeration()
}

Btw, maybe naabu library need some documentation? As already stated in https://github.com/projectdiscovery/naabu/issues/432

Mzack9999 commented 8 months ago

Thanks for opening the issue @ca5ua1 - It should be fixed with https://github.com/projectdiscovery/naabu/pull/946 (currently the output configuration happens only when the runner is instantiated by CLI, I moved it within the runner itself, so it should cover also the sdk case)