Documentation
¶
Index ¶
- Constants
- Variables
- func AuthWithPDCP()
- func DefaultResumeFilePath() string
- func DefaultResumeFolderPath() string
- func DoHealthCheck(options *Options, flagSet *goflags.FlagSet) string
- func GetUpdateCallback() func()
- func ParsePorts(options *Options) ([]*port.Port, error)
- func WriteCsvOutput(host, ip string, ports []*port.Port, outputCDN bool, isCdn bool, ...) error
- func WriteCsvOutputWithMac(host, ip, macAddress string, ports []*port.Port, outputCDN bool, isCdn bool, ...) error
- func WriteHostOutput(host string, ports []*port.Port, outputCDN bool, cdnName string, ...) error
- func WriteJSONOutput(host, ip string, ports []*port.Port, outputCDN bool, isCdn bool, ...) error
- func WriteJSONOutputWithMac(host, ip, macAddress string, ports []*port.Port, outputCDN bool, isCdn bool, ...) error
- type Options
- type Result
- type ResumeCfg
- type Runner
- func (r *Runner) AddTarget(target string) error
- func (r *Runner) BackgroundWorkers(ctx context.Context)
- func (r *Runner) Close() error
- func (r *Runner) ConnectVerification()
- func (r *Runner) GetTargetIps(ipsCallback func() ([]*net.IPNet, []string)) (targets, targetsV4, targetsV6 []*net.IPNet, targetsWithPort []string, ...)
- func (r *Runner) Load() error
- func (r *Runner) PickIP(targets []*net.IPNet, index int64) string
- func (r *Runner) PickPort(index int) *port.Port
- func (r *Runner) PickSubnetIP(network *net.IPNet, index int64) string
- func (r *Runner) PreProcessTargets() error
- func (r *Runner) RawSocketEnumeration(ctx context.Context, ip string, p *port.Port)
- func (r *Runner) RawSocketHostDiscovery(ip string)
- func (r *Runner) RunEnumeration(pctx context.Context) error
- func (r *Runner) SetInterface(interfaceName string) error
- func (r *Runner) SetSourceIP(sourceIP string) error
- func (r *Runner) SetSourcePort(sourcePort string) error
- func (r *Runner) ShowScanResultOnExit()
- type SYNSender
- type Target
Constants ¶
const ( DefaultPortTimeoutSynScan = time.Second DefaultPortTimeoutConnectScan = time.Duration(3 * time.Second) DefaultRateSynScan = 1000 DefaultRateConnectScan = 1500 DefaultRetriesSynScan = 3 DefaultRetriesConnectScan = 3 SynScan = scan.TypeSyn ConnectScan = scan.TypeConnect DefautStatsInterval = 5 // DefaultThreadsNum is the default number of threads to use for the scan // the default value of 25 is a good balance between performance and resource usage DefaultThreadsNum = 25 )
const ( Full = "1-65535" NmapTop100 = "" /* 393-byte string literal not displayed */ NmapTop1000 = "" /* 3813-byte string literal not displayed */ )
List of default ports
const Version = `2.6.1`
Version is the current Version of naabu
Variables ¶
var ( PDCPApiKey = "" TeamIDEnv = env.GetEnvOrDefault("PDCP_TEAM_ID", "") )
var (
NumberOfCsvFieldsErr = errors.New("exported fields don't match csv tags")
)
Functions ¶
func AuthWithPDCP ¶ added in v2.3.5
func AuthWithPDCP()
AuthWithPDCP is used to authenticate with PDCP
func DefaultResumeFilePath ¶
func DefaultResumeFilePath() string
DefaultResumeFilePath returns the default resume file full path
func DefaultResumeFolderPath ¶
func DefaultResumeFolderPath() string
DefaultResumeFolderPath returns the default resume folder path
func GetUpdateCallback ¶
func GetUpdateCallback() func()
GetUpdateCallback returns a callback function that updates naabu
func ParsePorts ¶
ParsePorts parses the list of ports and creates a port map
func WriteCsvOutput ¶
func WriteCsvOutput(host, ip string, ports []*port.Port, outputCDN bool, isCdn bool, cdnName string, header bool, excludedFields []string, writer io.Writer) error
WriteCsvOutput writes the output list of subdomain in csv format to an io.Writer
func WriteCsvOutputWithMac ¶ added in v2.3.6
func WriteCsvOutputWithMac(host, ip, macAddress string, ports []*port.Port, outputCDN bool, isCdn bool, cdnName string, header bool, excludedFields []string, writer io.Writer) error
WriteCsvOutputWithMac writes the output list of subdomain in csv format to an io.Writer with MAC address
func WriteHostOutput ¶
func WriteHostOutput(host string, ports []*port.Port, outputCDN bool, cdnName string, writer io.Writer) error
WriteHostOutput writes the output list of host ports to an io.Writer
func WriteJSONOutput ¶
func WriteJSONOutput(host, ip string, ports []*port.Port, outputCDN bool, isCdn bool, cdnName string, excludedFields []string, writer io.Writer) error
WriteJSONOutput writes the output list of subdomain in JSON to an io.Writer
func WriteJSONOutputWithMac ¶ added in v2.3.6
func WriteJSONOutputWithMac(host, ip, macAddress string, ports []*port.Port, outputCDN bool, isCdn bool, cdnName string, excludedFields []string, writer io.Writer) error
WriteJSONOutputWithMac writes the output list of subdomain in JSON to an io.Writer with MAC address
Types ¶
type Options ¶
type Options struct {
Verbose bool // Verbose flag indicates whether to show verbose output or not
NoColor bool // No-Color disables the colored output
JSON bool // JSON specifies whether to use json for output format or text file
Silent bool // Silent suppresses any extra text and only writes found host:port to screen
DisableStdout bool // DisableStdout suppresses stdout output (useful for SDK usage with OnResult callback)
Stdin bool // Stdin specifies whether stdin input was given to the process
Verify bool // Verify is used to check if the ports found were valid using CONNECT method
Version bool // Version specifies if we should just show version and exit
Ping bool // Ping uses ping probes to discover fastest active host and discover dead hosts
Debug bool // Prints out debug information
ExcludeCDN bool // Excludes ip of knows CDN ranges for full port scan
Nmap bool // Invoke nmap detailed scan on results (only when NmapCLI is provided)
InterfacesList bool // InterfacesList show interfaces list
Retries int // Retries is the number of retries for the port
Rate int // Rate is the rate of port scan requests
// Timeout int // Timeout is the milliseconds to wait for ports to respond
Timeout time.Duration
WarmUpTime int // WarmUpTime between scan phases
Host goflags.StringSlice // Host is the single host or comma-separated list of hosts to find ports for
HostsFile string // HostsFile is the file containing list of hosts to find port for
Output string // Output is the file to write found ports to.
ListOutputFields bool // OutputFields is the list of fields to output (comma separated)
ExcludeOutputFields goflags.StringSlice // ExcludeOutputFields is the list of fields to exclude from the output
Ports string // Ports is the ports to use for enumeration
PortsFile goflags.StringSlice // PortsFile is the file containing ports to use for enumeration
ExcludePorts goflags.StringSlice // ExcludePorts is the list of ports to exclude from enumeration
ExcludeIps string // Ips or cidr to be excluded from the scan
ExcludeIpsFile string // File containing Ips or cidr to exclude from the scan
TopPorts string // Tops ports to scan
PortThreshold int // PortThreshold is the number of ports to find before skipping the host
SourceIP string // SourceIP to use in TCP packets
SourcePort string // Source Port to use in packets
Interface string // Interface to use for TCP packets
ConfigFile string // Config file contains a scan configuration
NmapCLI string // Nmap command (has priority over config file)
Threads int // Internal worker threads
// Deprecated: stats are automatically available through local endpoint
EnableProgressBar bool // Enable progress bar
// Deprecated: stats are automatically available through local endpoint (maybe used on cloud?)
StatsInterval int // StatsInterval is the number of seconds to display stats after
ScanAllIPS bool // Scan all the ips
IPVersion goflags.StringSlice // IP Version to use while resolving hostnames
ScanType string // Scan Type
ConnectPayload string // Payload to use with CONNECT scan types
Proxy string // Socks5 proxy
ProxyAuth string // Socks5 proxy authentication (username:password)
Resolvers string // Resolvers (comma separated or file)
DnsOrder string // DNS resolution order (p/l/lp/pl)
SystemResolver bool // Use system DNS resolver as fallback
OnResult result.ResultFn // callback on final host result
OnReceive result.ResultFn // callback on response receive
CSV bool
Resume bool
ResumeCfg *ResumeCfg
Stream bool
Passive bool
OutputCDN bool // display cdn in use
HealthCheck bool
OnlyHostDiscovery bool // Perform only host discovery
// Deprecated: use WithHostDiscovery instead
SkipHostDiscovery bool // Skip Host discovery
WithHostDiscovery bool // Enable Host discovery
TcpSynPingProbes goflags.StringSlice
TcpAckPingProbes goflags.StringSlice
// UdpPingProbes goflags.StringSlice - planned
// STcpInitPingProbes goflags.StringSlice - planned
IcmpEchoRequestProbe bool
IcmpTimestampRequestProbe bool
IcmpAddressMaskRequestProbe bool
// IpProtocolPingProbes goflags.StringSlice - planned
ArpPing bool
IPv6NeighborDiscoveryPing bool
// HostDiscoveryIgnoreRST bool - planned
InputReadTimeout time.Duration
DisableStdin bool
// ServiceDiscovery enables service discovery on found open ports (matches port number with service)
ServiceDiscovery bool
// ServiceVersion attempts to discover service running on open ports with active/passive probes
ServiceVersion bool
// ReversePTR lookup for ips
ReversePTR bool
//DisableUpdateCheck disables automatic update check
DisableUpdateCheck bool
// MetricsPort with statistics
MetricsPort int
NetworkPolicyOptions *networkpolicy.Options
// PdcpAuth for projectdiscovery cloud
PdcpAuth string
// PdcpAuthCredFile for projectdiscovery cloud
PdcpAuthCredFile string
// AssetUpload for projectdiscovery cloud
AssetUpload bool
// TeamID for projectdiscovery cloud
TeamID string
// AssetID for projectdiscovery cloud
AssetID string
// AssetName for projectdiscovery cloud
AssetName string
// AssetFileUpload for projectdiscovery cloud
AssetFileUpload string
// OnClose adds a callback function that is invoked when naabu is closed
// to be exact at end of existing closures
OnClose func()
// SmartScan enables predictive port scanning: after the initial scan,
// a correlation model predicts additional likely-open ports per host.
SmartScan bool
// PredictionThreshold is the minimum confidence percentage (0–100) to
// act on a port prediction (default 20, meaning 20%).
PredictionThreshold int
// contains filtered or unexported fields
}
Options contains the configuration options for tuning the port enumeration process. nolint
func ParseOptions ¶
func ParseOptions() *Options
ParseOptions parses the command line flags provided by a user
func (*Options) GetTimeout ¶ added in v2.3.5
func (*Options) ShouldLoadResume ¶
ShouldLoadResume resume file
func (*Options) ShouldScanIPv4 ¶
func (*Options) ShouldScanIPv6 ¶
func (*Options) ValidateOptions ¶
ValidateOptions validates the configuration options passed
type Result ¶
type Result struct {
Host string `json:"host,omitempty" csv:"host"`
IP string `json:"ip,omitempty" csv:"ip"`
Port int `json:"port,omitempty" csv:"port"`
Protocol string `json:"protocol,omitempty" csv:"protocol"`
TLS bool `json:"tls,omitempty" csv:"tls"`
IsCDNIP bool `json:"cdn,omitempty" csv:"cdn"`
CDNName string `json:"cdn-name,omitempty" csv:"cdn-name"`
TimeStamp time.Time `json:"timestamp,omitempty" csv:"timestamp"`
MacAddress string `json:"mac_address,omitempty" csv:"mac_address"`
// TODO: flattening fields should be fully reworked to reuse nested structs
// just add the service flat structure
DeviceType string `json:"device_type,omitempty"`
ExtraInfo string `json:"extra_info,omitempty"`
HighVersion string `json:"high_version,omitempty"`
Hostname string `json:"hostname,omitempty"`
LowVersion string `json:"low_version,omitempty"`
Method string `json:"method,omitempty"`
Name string `json:"name,omitempty"`
OSType string `json:"os_type,omitempty"`
Product string `json:"product,omitempty"`
Proto string `json:"proto,omitempty"`
RPCNum string `json:"rpc_num,omitempty"`
ServiceFP string `json:"service_fp,omitempty"`
Tunnel string `json:"tunnel,omitempty"`
Version string `json:"version,omitempty"`
Confidence int `json:"confidence,omitempty"`
}
Result contains the result for a host
type ResumeCfg ¶
type ResumeCfg struct {
sync.RWMutex
Retry int `json:"retry"`
Seed int64 `json:"seed"`
Index int64 `json:"index"`
}
ResumeCfg contains the scan progression
func NewResumeCfg ¶
func NewResumeCfg() *ResumeCfg
NewResumeCfg creates a new scan progression structure
func (*ResumeCfg) CleanupResumeConfig ¶
func (resumeCfg *ResumeCfg) CleanupResumeConfig()
CleanupResumeConfig cleaning up the config file
func (*ResumeCfg) ConfigureResume ¶
ConfigureResume read the resume config file
func (*ResumeCfg) SaveResumeConfig ¶
SaveResumeConfig to file
func (*ResumeCfg) ShouldSaveResume ¶
ShouldSaveResume file
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner is an instance of the port enumeration client used to orchestrate the whole process.
func NewRunner ¶
NewRunner creates a new runner struct instance by parsing the configuration options, configuring sources, reading lists, etc
func (*Runner) BackgroundWorkers ¶
func (*Runner) ConnectVerification ¶
func (r *Runner) ConnectVerification()
func (*Runner) GetTargetIps ¶
func (*Runner) PreProcessTargets ¶
func (*Runner) RawSocketEnumeration ¶
func (*Runner) RawSocketHostDiscovery ¶
func (*Runner) RunEnumeration ¶
RunEnumeration runs the ports enumeration flow on the targets specified
func (*Runner) SetInterface ¶
func (*Runner) SetSourceIP ¶
func (*Runner) SetSourcePort ¶
func (*Runner) ShowScanResultOnExit ¶
func (r *Runner) ShowScanResultOnExit()
type SYNSender ¶ added in v2.6.0
type SYNSender struct {
// contains filtered or unexported fields
}
SYNSender builds and sends raw TCP SYN packets without gopacket serialization. Per-packet work: patch 3 fields + one sendto syscall.
Sending is delegated to rawsend.Sender (direct sendto) with an optional rawsend.Batch for sendmmsg on Linux.
NOT safe for concurrent use, reuses internal buffers.