# nuvlt/sqli-scanner architecture

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

- Interactive diagram: https://gitdiagram.com/nuvlt/sqli-scanner
- Repository: https://github.com/nuvlt/sqli-scanner

## Overview

##### Main Components

a) Core Scanner Component:
- Entry Point (sqli-scanner.py)
- Configuration Handler (lib/conf.py)
- Process Management System

b) Processing Pipeline Components:
- URL Reader (lib/reader.py)
- SQL Injection Scanner/Cleaner (lib/cleaner.py)
- Result Writer (lib/writer.py)
- Error Handler (error.ini)
- Reporter (lib/reporter.py)

**[Input Layer]**

- ▼
**[Process Management Layer]**

- ┬─────┬─────┐
- ▼     ▼     ▼     ▼
**[Worker Process 1..N]**

- ▼
**[Output Layer]**

##### Component Relationships

- Input file flow to the URL reader
- Parallel processing with multiple worker processes
- Demonstrate result aggregation to the output writer
- Error handling flows
- Configuration influence on all components

##### Specific Elements

a) Input Section:
- File input handler (-f option)
- Process count configuration (-p option)
- Verbose mode toggle (-v option)

b) Process Management:
- CPU core detection
- Process pool creation
- Work distribution mechanism

c) Worker Process Details:
- URL validation
- SQL injection testing logic
- Result collection

d) Output Handling:
- Vulnerability reporting
- Output file writing (-o option)

##### Technical Details to Highlight

- Multi-processing capability
- CPU core utilization
- Error handling mechanisms
- File I/O operations
- Reporting structure

##### Configuration flow through the system

- Process multiplication
- Data flow between components
- Error handling paths
- Configuration influence

Remember to include a note about the process management considerations, particularly regarding the process termination mechanism mentioned in the README (Ctrl+C vs. Ctrl+Z handling).

This system design should clearly communicate the tool's architecture while highlighting its key feature of parallel processing for efficient SQL injection vulnerability scanning.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        FI[File Input]
        PC[Process Count]
        VM[Verbose Mode]
    end

    subgraph Core
        EP["Entry Point"]:::core
        CH["Configuration Handler"]:::core
        PM["Process Manager"]:::core
    end

    subgraph "Worker Processes"
        direction TB
        WP1["Worker Process 1"]:::worker
        WP2["Worker Process 2"]:::worker
        WP3["Worker Process N"]:::worker
    end

    subgraph "Processing Components"
        direction TB
        UR["URL Reader"]:::io
        SC["SQL Injection Scanner"]:::scanner
        RW["Result Writer"]:::io
        RP["Reporter"]:::utility
        EH["Error Handler"]:::error
        OF["Output Formatter"]:::utility
    end

    subgraph Output
        VR[Vulnerability Report]
        OF1[Output File]
    end

    %% Connections
    FI --> EP
    PC --> EP
    VM --> EP

    EP --> CH
    CH --> PM
    PM --> WP1 & WP2 & WP3

    WP1 & WP2 & WP3 --> UR
    UR --> SC
    SC --> RW
    RW --> RP
    RP --> OF
    OF --> VR
    OF --> OF1

    CH -.-> UR & SC & RW & RP
    EH -.-> WP1 & WP2 & WP3

    %% Styles
    classDef core fill:#3498db
    classDef worker fill:#95a5a6
    classDef io fill:#2ecc71
    classDef scanner fill:#f1c40f
    classDef error fill:#e74c3c
    classDef utility fill:#bdc3c7

    %% Click Events
    click EP "https://github.com/nuvlt/sqli-scanner/blob/master/sqli-scanner.py"
    click CH "https://github.com/nuvlt/sqli-scanner/blob/master/lib/conf.py"
    click UR "https://github.com/nuvlt/sqli-scanner/blob/master/lib/reader.py"
    click SC "https://github.com/nuvlt/sqli-scanner/blob/master/lib/cleaner.py"
    click RW "https://github.com/nuvlt/sqli-scanner/blob/master/lib/writer.py"
    click EH "https://github.com/nuvlt/sqli-scanner/blob/master/error.ini"
    click RP "https://github.com/nuvlt/sqli-scanner/blob/master/lib/reporter.py"
    click OF "https://github.com/nuvlt/sqli-scanner/blob/master/lib/colour.py"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Worker Processes"]:::worker
        L3["I/O Operations"]:::io
        L4["Scanner"]:::scanner
        L5["Error Handling"]:::error
        L6["Utilities"]:::utility
    end
```
