# sensepost/gowitness architecture

> Architecture diagram of the GitHub repository sensepost/gowitness, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sensepost/gowitness
- Repository: https://github.com/sensepost/gowitness

## Overview

##### Main Components Identification
The system can be broken down into these major components:

a. Command Line Interface (CLI)
- Located in /cmd directory
- Handles different commands like scan, report, version

b. Core Screenshot Engine
- Located in /pkg/runner
- Supports multiple drivers (Chrome Headless via chromedp and go-rod)

c. Input Processing System
- Located in /pkg/readers
- Handles multiple input sources (CIDR, file, Nessus, Nmap)

d. Output Management System
- Located in /pkg/writers
- Supports multiple output formats (CSV, JSON, SQLite, stdout)

e. Web Interface
- Located in /web directory
- Contains both API and UI components

##### User Interaction Layer
- CLI Interface
- Web UI (React/TypeScript based)
- REST API endpoints

##### Core Processing Layer
- Screenshot Engine
- Driver Management
- Input Processing
- Output Management

##### Storage Layer
- File System (screenshots)
- Database (SQLite)

##### Component Relationships

**User Input -> CLI/Web UI**

- v
**Input Processing (pkg/readers) -> Screenshot Engine (pkg/runner)**

- v
- Driver Interface
- /            \
- ChromeDP              Go-Rod
- /
- v              v
- Screenshot Capture

- v
**Output Management (pkg/writers) -> Storage Systems**

- v
- Web Interface (Viewing)

##### Important Elements

a. Input Sources:
- CIDR Ranges
- URL Lists
- Nmap Scans
- Nessus Results
- Single URLs

b. Output Formats:
- SQLite Database
- JSON Lines
- CSV
- Screenshots Directory

c. Web Interface Components:
- REST API Endpoints
- React Frontend
- Gallery View
- Detail View
- Search Functionality

##### Technical Details to Note
- Built in Go
- Uses Chrome Headless
- Supports multiple browser automation drivers
- Includes a full REST API
- React/TypeScript frontend
- SQLite database for data persistence

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interaction Layer"
        CLI["Command Line Interface"]:::cli
        WebUI["Web UI (React/TypeScript)"]:::ui
        API["REST API"]:::api
    end

    subgraph "Core Processing Layer"
        InputProc["Input Processing"]:::core
        ScreenEngine["Screenshot Engine"]:::core
        DriverMgr["Driver Management"]:::core

        subgraph "Drivers"
            ChromeDP["ChromeDP Driver"]:::driver
            GoRod["Go-Rod Driver"]:::driver
        end

        subgraph "Input Sources"
            CIDR["CIDR Reader"]:::input
            FileIn["File Reader"]:::input
            Nessus["Nessus Reader"]:::input
            Nmap["Nmap Reader"]:::input
        end

        subgraph "Output Handlers"
            CSV["CSV Writer"]:::output
            JSON["JSON Writer"]:::output
            DB["Database Writer"]:::output
            Console["Console Writer"]:::output
        end
    end

    subgraph "Storage Layer"
        SQLite[(SQLite Database)]:::storage
        FileSystem[("Screenshot Storage")]:::storage
    end

    subgraph "Web Interface Components"
        Gallery["Gallery View"]:::ui
        Detail["Detail View"]:::ui
        Search["Search Interface"]:::ui
    end

    %% Relationships
    CLI --> InputProc
    WebUI --> API
    API --> SQLite

    InputProc --> |Process URLs| ScreenEngine
    CIDR --> InputProc
    FileIn --> InputProc
    Nessus --> InputProc
    Nmap --> InputProc

    ScreenEngine --> DriverMgr
    DriverMgr --> ChromeDP
    DriverMgr --> GoRod
    ChromeDP --> FileSystem
    GoRod --> FileSystem

    ScreenEngine --> |Screenshot Data| DB
    ScreenEngine --> CSV
    ScreenEngine --> JSON
    ScreenEngine --> Console

    DB --> SQLite
    WebUI --> Gallery
    WebUI --> Detail
    WebUI --> Search

    %% Click Events
    click CLI "https://github.com/sensepost/gowitness/tree/master/cmd"
    click InputProc "https://github.com/sensepost/gowitness/tree/master/pkg/readers"
    click ScreenEngine "https://github.com/sensepost/gowitness/blob/master/pkg/runner/runner.go"
    click DriverMgr "https://github.com/sensepost/gowitness/blob/master/pkg/runner/driver.go"
    click ChromeDP "https://github.com/sensepost/gowitness/blob/master/pkg/runner/drivers/chromedp.go"
    click GoRod "https://github.com/sensepost/gowitness/blob/master/pkg/runner/drivers/go-rod.go"
    click CIDR "https://github.com/sensepost/gowitness/blob/master/pkg/readers/cidr.go"
    click FileIn "https://github.com/sensepost/gowitness/blob/master/pkg/readers/file.go"
    click Nessus "https://github.com/sensepost/gowitness/blob/master/pkg/readers/nessus.go"
    click Nmap "https://github.com/sensepost/gowitness/blob/master/pkg/readers/nmap.go"
    click CSV "https://github.com/sensepost/gowitness/blob/master/pkg/writers/csv.go"
    click JSON "https://github.com/sensepost/gowitness/blob/master/pkg/writers/json.go"
    click DB "https://github.com/sensepost/gowitness/blob/master/pkg/writers/db.go"
    click Console "https://github.com/sensepost/gowitness/blob/master/pkg/writers/stdout.go"
    click WebUI "https://github.com/sensepost/gowitness/tree/master/web/ui/src"
    click API "https://github.com/sensepost/gowitness/tree/master/web/api"
    click Gallery "https://github.com/sensepost/gowitness/blob/master/web/ui/src/pages/gallery/Gallery.tsx"
    click Detail "https://github.com/sensepost/gowitness/blob/master/web/ui/src/pages/detail/Detail.tsx"
    click Search "https://github.com/sensepost/gowitness/blob/master/web/ui/src/pages/search/Search.tsx"
    click SQLite "https://github.com/sensepost/gowitness/blob/master/pkg/database/db.go"

    %% Styles
    classDef cli fill:#2196F3,stroke:#1565C0,color:white
    classDef ui fill:#4CAF50,stroke:#2E7D32,color:white
    classDef api fill:#FF9800,stroke:#EF6C00,color:white
    classDef core fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef driver fill:#FF5722,stroke:#D84315,color:white
    classDef input fill:#00BCD4,stroke:#00838F,color:white
    classDef output fill:#FFC107,stroke:#FFA000,color:white
    classDef storage fill:#607D8B,stroke:#37474F,color:white
```
