# projectdiscovery/naabu architecture

> Architecture diagram of the GitHub repository projectdiscovery/naabu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/projectdiscovery/naabu
- Repository: https://github.com/projectdiscovery/naabu

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Components:
- Command Line Interface (cmd/naabu)
- Runner System (pkg/runner)
- Scanning Engine (pkg/scan)
- Results Handler (pkg/result)
- Protocol Handler (pkg/protocol)

b) Supporting Components:
- Port Management (pkg/port)
- Privilege Handler (pkg/privileges)
- Routing System (pkg/routing)

**┌─ Input Layer ─────────────────────┐**
- CLI Interface                   │
- Configuration Management        │
- Input Validation               │
- ┬──────────────────┘
- ↓
**┌─ Core Processing Layer ───────────┐**
- ┌─ Runner Engine ───────────────┐ │
- Target Management          │ │
- Port Selection            │ │
- Scan Orchestration       │ │
- ┬────────────────┘ │
- ↓                  │
- ┌─ Scanning Engine ────────────┐ │
- SYN Scanning             │ │
- Connect Scanning         │ │
- UDP Scanning            │ │
- Host Discovery          │ │
- ┬────────────────┘ │
- ┬──────────────────┘
- ↓
**┌─ Output Layer ──────────────────┐**
- Results Processing           │
- Output Formatting           │
- Nmap Integration           │
- ┘

##### Integration Points

External integration capabilities:
- Nmap integration
- Shodan InternetDB API
- DNS resolution system
- Metrics endpoint

##### Technical Details

Annotations for:
- Supported protocols (TCP SYN, CONNECT, UDP)
- Port scanning strategies
- Host discovery methods (ARP, ICMP, TCP ping)
- Performance configurations (rate limiting, threading)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        CLI["Command Line Interface"]:::input
        Config["Configuration Management"]:::input
        InputVal["Input Validation"]:::input
    end

    subgraph Core
        subgraph Runner["Runner Engine"]
            TargetMgmt["Target Management"]:::core
            PortSelect["Port Selection"]:::core
            ScanOrch["Scan Orchestration"]:::core
        end

        subgraph Scanner["Scanning Engine"]
            SYNScan["SYN Scanning"]:::scan
            ConnScan["Connect Scanning"]:::scan
            UDPScan["UDP Scanning"]:::scan
            HostDisc["Host Discovery"]:::scan
            CDNDet["CDN Detection"]:::scan
        end

        PrivHandler["Privilege Handler"]:::security
        RoutSys["Routing System"]:::security
        PortMgmt["Port Management"]:::util
        ProtHandler["Protocol Handler"]:::util
    end

    subgraph Output
        ResultProc["Results Processing"]:::output
        OutFormat["Output Formatting"]:::output
        NmapInt["Nmap Integration"]:::output
    end

    %% Relationships
    CLI --> Config
    Config --> InputVal
    InputVal --> TargetMgmt

    TargetMgmt --> PortSelect
    PortSelect --> ScanOrch
    ScanOrch --> Scanner

    Scanner --> ResultProc
    ResultProc --> OutFormat
    ResultProc --> NmapInt

    PrivHandler -.-> Scanner
    RoutSys -.-> Scanner
    PortMgmt -.-> PortSelect
    ProtHandler -.-> Scanner

    %% Styles
    classDef input fill:#90EE90
    classDef core fill:#ADD8E6
    classDef scan fill:#4169E1
    classDef output fill:#98FB98
    classDef security fill:#FF6B6B
    classDef util fill:#FFD700

    %% Click Events
    click CLI "https://github.com/projectdiscovery/naabu/blob/dev/cmd/naabu/main.go"
    click TargetMgmt "https://github.com/projectdiscovery/naabu/blob/dev/pkg/runner/targets.go"
    click ScanOrch "https://github.com/projectdiscovery/naabu/blob/dev/pkg/runner/runner.go"
    click Config "https://github.com/projectdiscovery/naabu/blob/dev/pkg/runner/options.go"
    click OutFormat "https://github.com/projectdiscovery/naabu/blob/dev/pkg/runner/output.go"
    click ConnScan "https://github.com/projectdiscovery/naabu/blob/dev/pkg/scan/connect.go"
    click HostDisc "https://github.com/projectdiscovery/naabu/blob/dev/pkg/scan/icmp.go"
    click CDNDet "https://github.com/projectdiscovery/naabu/blob/dev/pkg/scan/cdn.go"
    click Scanner "https://github.com/projectdiscovery/naabu/blob/dev/pkg/scan/scan.go"
    click ResultProc "https://github.com/projectdiscovery/naabu/blob/dev/pkg/result/results.go"
    click ProtHandler "https://github.com/projectdiscovery/naabu/blob/dev/pkg/protocol/protocol.go"
    click PortMgmt "https://github.com/projectdiscovery/naabu/blob/dev/pkg/port/port.go"
    click PrivHandler "https://github.com/projectdiscovery/naabu/blob/dev/pkg/privileges/privileges.go"
    click RoutSys "https://github.com/projectdiscovery/naabu/blob/dev/pkg/routing/router.go"
```
