Skip to content

Naabu Port Scanner Cheat Sheet

Overview

Naabu is a fast port scanner written in Go by Project Discovery. It's designed with a focus on reliability and simplicity, making it an excellent tool for attack surface discovery. Naabu can scan thousands of hosts and ports in minutes, providing a quick way to identify open ports and potential entry points into target systems.

What sets Naabu apart from other port scanners is its integration capabilities with other security tools. It's designed to be used in combination with tools like httpx, nuclei, and other Project Discovery tools to create powerful security testing workflows. Naabu supports various scanning techniques, including SYN, CONNECT, and UDP scans, and can be customized to fit different scanning requirements.

Naabu is commonly used in the reconnaissance phase of security assessments and bug bounty hunting to identify open ports that could potentially host vulnerable services. Its speed and accuracy make it a valuable tool for security professionals who need to quickly map the attack surface of target organizations.

Installation

Using Go

bash
# Install using Go (requires Go 1.20 or later)
go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@latest

# Verify installation
naabu -version

Using Docker

bash
# Pull the latest Docker image
docker pull projectdiscovery/naabu:latest

# Run Naabu using Docker
docker run -it projectdiscovery/naabu:latest -h

Using Homebrew (macOS)

bash
# Install using Homebrew
brew install naabu

# Verify installation
naabu -version

Using PDTM (Project Discovery Tools Manager)

bash
# Install PDTM first if not already installed
go install -v github.com/projectdiscovery/pdtm/cmd/pdtm@latest

# Install Naabu using PDTM
pdtm -i naabu

# Verify installation
naabu -version

On Kali Linux

bash
# Install using apt
sudo apt install naabu

# Verify installation
naabu -version

Basic Usage

Scanning Hosts

bash
# Scan a single host (default: top 100 ports)
naabu -host example.com

# Scan multiple hosts
naabu -host example.com,hackerone.com

# Scan from a list of hosts
naabu -list hosts.txt

# Scan from STDIN
cat hosts.txt | naabu

Port Selection

bash
# Scan specific ports
naabu -host example.com -p 80,443,8080,8443

# Scan port ranges
naabu -host example.com -p 1-1000

# Scan top ports
naabu -host example.com -top-ports 100

# Scan all ports
naabu -host example.com -p -

Output Options

bash
# Save results to a file
naabu -host example.com -o results.txt

# Output in JSON format
naabu -host example.com -json -o results.json

# Output in CSV format
naabu -host example.com -csv -o results.csv

# Silent mode (only host:port)
naabu -host example.com -silent

Advanced Usage

Scan Types

bash
# SYN scan (default, requires root/sudo)
sudo naabu -host example.com -scan-type s

# CONNECT scan (no root required)
naabu -host example.com -scan-type c

# UDP scan (requires root/sudo)
sudo naabu -host example.com -scan-type u

Host Discovery

bash
# Ping scan for host discovery
naabu -host 192.168.1.0/24 -ping

# Skip host discovery
naabu -host 192.168.1.0/24 -skip-host-discovery

Network Options

bash
# Set source IP
sudo naabu -host example.com -source-ip 192.168.1.2

# Set source port
sudo naabu -host example.com -source-port 53

# Set interface
sudo naabu -host example.com -interface eth0

Scan Optimization

bash
# Set timeout (milliseconds)
naabu -host example.com -timeout 1000

# Set retries
naabu -host example.com -retries 3

# Set rate limit (packets per second)
naabu -host example.com -rate 1000

Performance Optimization

Concurrency and Rate Limiting

bash
# Set host concurrency (default: 25)
naabu -host example.com -c 50

# Set port concurrency (default: 25)
naabu -host example.com -port-concurrency 50

# Set rate limit
naabu -host example.com -rate 1000

Timeout Options

bash
# Set timeout for port scans (milliseconds)
naabu -host example.com -timeout 1000

# Set timeout for host discovery (milliseconds)
naabu -host example.com -ping-timeout 1000

Optimization for Large Scans

bash
# Use warm-up for large scans
naabu -host example.com -warm-up-time 2

# Increase concurrency for faster scanning
naabu -host example.com -c 100 -port-concurrency 100

Integration with Other Tools

Pipeline with Subfinder

bash
# Find subdomains and scan for open ports
subfinder -d example.com -silent | naabu -silent

# Find subdomains, scan for open ports, and probe for HTTP services
subfinder -d example.com -silent | naabu -silent | httpx -silent

Pipeline with HTTPX

bash
# Scan for open ports and probe for HTTP services
naabu -host example.com -silent | httpx -silent

# Scan for specific ports and probe for HTTP services
naabu -host example.com -p 80,443,8080,8443 -silent | httpx -silent

Pipeline with Nuclei

bash
# Scan for open ports, probe for HTTP services, and scan for vulnerabilities
naabu -host example.com -silent | httpx -silent | nuclei -t cves/

# Scan for specific ports and scan for vulnerabilities
naabu -host example.com -p 80,443,8080,8443 -silent | httpx -silent | nuclei -t cves/

Output Customization

Custom Output Format

bash
# Output only host:port
naabu -host example.com -silent

# Output with additional information
naabu -host example.com -v

# Count open ports
naabu -host example.com -silent | wc -l

# Sort output by port
naabu -host example.com -silent | sort -t: -k2 -n

Filtering Output

bash
# Filter by port
naabu -host example.com -silent | grep ":80$"

# Filter by host
naabu -list hosts.txt -silent | grep "example.com"

# Find unique ports
naabu -list hosts.txt -silent | cut -d: -f2 | sort -u

Advanced Filtering

Port Filtering

bash
# Exclude specific ports
naabu -host example.com -exclude-ports 80,443

# Scan only common web ports
naabu -host example.com -p 80,81,443,591,2082,2087,2095,2096,3000,8000,8001,8008,8080,8083,8443,8834,8888

Host Filtering

bash
# Exclude specific hosts
naabu -list hosts.txt -exclude-hosts excluded-hosts.txt

# Scan only specific CIDR ranges
naabu -host 192.168.1.0/24,10.0.0.0/24

Service Detection

bash
# Enable service detection
naabu -host example.com -s

# Enable service detection with version
naabu -host example.com -sv

Proxy and Network Options

bash
# Use SOCKS5 proxy
naabu -host example.com -proxy socks5://127.0.0.1:1080

# Use HTTP proxy
naabu -host example.com -proxy http://127.0.0.1:8080

# Set DNS resolvers
naabu -host example.com -resolvers 1.1.1.1,8.8.8.8

Nmap Integration

bash
# Enable Nmap integration
naabu -host example.com -nmap

# Pass additional Nmap flags
naabu -host example.com -nmap -nmap-flags "-sV -A"

# Use Nmap for service detection
naabu -host example.com -nmap-cli "nmap -sV"

Miscellaneous Features

CDN/WAF Detection

bash
# Skip CDN/WAF IPs
naabu -host example.com -exclude-cdn

IP Version Selection

bash
# Scan using IPv4
naabu -host example.com -ip-version 4

# Scan using IPv6
naabu -host example.com -ip-version 6

Passive Port Enumeration

bash
# Enable passive port enumeration
naabu -host example.com -passive

Troubleshooting

Common Issues

  1. Permission Issues

    bash
    # Use sudo for SYN and UDP scans
    sudo naabu -host example.com -scan-type s
    
    # Use CONNECT scan if you don't have root privileges
    naabu -host example.com -scan-type c
  2. Rate Limiting by Target

    bash
    # Reduce rate limit
    naabu -host example.com -rate 100
    
    # Increase timeout
    naabu -host example.com -timeout 2000
  3. False Negatives

    bash
    # Increase retries
    naabu -host example.com -retries 5
    
    # Use multiple scan types
    naabu -host example.com -scan-type s,c
  4. Firewall/IDS Detection

    bash
    # Use slower scan rate
    naabu -host example.com -rate 50
    
    # Use random port order
    naabu -host example.com -scan-random-port

Debugging

bash
# Enable verbose mode
naabu -host example.com -v

# Show debug information
naabu -host example.com -debug

# Show only open ports
naabu -host example.com -silent

Configuration

Configuration File

Naabu uses a configuration file located at $HOME/.config/naabu/config.yaml. You can customize various settings in this file:

yaml
# Example configuration file
concurrency: 25
port-concurrency: 25
rate: 1000
timeout: 1000
retries: 3
verify: false
scan-type: s
ports: "80,443,8080,8443"

Environment Variables

bash
# Set Naabu configuration via environment variables
export NAABU_CONCURRENCY=25
export NAABU_PORT_CONCURRENCY=25
export NAABU_RATE=1000
export NAABU_TIMEOUT=1000
export NAABU_RETRIES=3

Reference

Command Line Options

FlagDescription
-hostTarget host(s) to scan
-list, -lFile containing list of hosts to scan
-p, -portPorts to scan (comma-separated, range, or - for all)
-top-portsTop ports to scan (default: 100)
-exclude-portsPorts to exclude from scan
-o, -outputFile to write output to
-jsonWrite output in JSON format
-csvWrite output in CSV format
-silentShow only host:port in output
-v, -verboseShow verbose output
-scan-typeType of scan to perform (s=SYN, c=CONNECT, u=UDP)
-pingUse ping for host discovery
-skip-host-discoverySkip host discovery
-source-ipSource IP to use for scanning
-interfaceNetwork interface to use
-rateRate of packet sending (packets per second)
-timeoutTimeout in milliseconds
-retriesNumber of retries for failed requests
-c, -concurrencyNumber of concurrent hosts to scan
-port-concurrencyNumber of concurrent ports to scan
-warm-up-timeTime in seconds to wait before scanning
-sEnable service detection
-svEnable service detection with version
-nmapEnable Nmap integration
-nmap-flagsAdditional Nmap flags
-exclude-cdnSkip CDN/WAF IPs
-proxyHTTP/SOCKS5 proxy to use
-resolversDNS resolvers to use
-ip-versionIP version to use (4, 6, or both)
-passiveEnable passive port enumeration
-versionShow Naabu version

Port Lists

OptionDescription
top-10Top 10 most common ports
top-100Top 100 most common ports
top-1000Top 1000 most common ports
fullAll 65535 ports
80,443,8080Custom port list
1-1000Port range
-All ports (1-65535)

Scan Types

TypeDescriptionRoot Required
sSYN scanYes
cCONNECT scanNo
uUDP scanYes

Resources


This cheat sheet provides a comprehensive reference for using Naabu, from basic port scanning to advanced techniques and integration with other tools. For the most up-to-date information, always refer to the official documentation.