# nextkool/zphisher architecture

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

- Interactive diagram: https://gitdiagram.com/nextkool/zphisher
- Repository: https://github.com/nextkool/zphisher

## Overview

##### Main Components
- CLI/Orchestration Layer – This is driven by the main script (zphisher.sh), which is the entry point for launching the toolkit. It handles user inputs, dependency checks, and routing to the proper modules.
- Template Manager – Represented by the “.sites” directory. Each subdirectory (e.g., adobe, facebook, google, etc.) is a distinct phishing template with its own index.php, login pages, and additional resources. This layer encapsulates the various phishing page “modules.”
- Web Server/Runtime Environment – When a template is selected, the script initiates a PHP built-in server to serve the phishing pages.
- Tunneling/Exposure Module – This part manages the tunneling options (localhost, Ngrok, Cloudflared, etc.), which are used to expose the locally served pages to the public.
- Packaging & Deployment – Indicated by directories like “.package” (with DEBIAN and TERMUX subfolders), the Dockerfile, and make-deb.sh script. They handle the creation of installation packages or containers, ensuring the toolkit is easily distributable across platforms.
- Dependencies & External Tools – The README explicitly notes dependencies such as PHP, wget, curl, and git; these are external components that the system requires to operate.

##### Relationships and Interactions
- The user interacts with the CLI (zphisher.sh), triggering the main flow.
- The main script then allows the user to choose a phishing target/template from those available in the “.sites” directory.
- Once a template is selected, zphisher.sh configures and launches a local PHP server that serves the selected phishing page.
- Simultaneously, the script can initiate a tunnel (via Ngrok, Cloudflared, or localhost) using installed utilities, which then routes external requests to the local server.
- The packaging scripts (and Dockerfile) enable deployment or installation on different platforms; they can be shown as separate nodes that interact with the main script for building or deploying the package.

##### Architectural Patterns and Design Principles
- Modular Design: The separation between the main orchestrator (zphisher.sh), the phishing templates (.sites), and packaging components (.package, Dockerfile) indicates a modular approach.
- Layered Architecture: There is a clear division into layers – the user interface/CLI layer, the application logic (template selection and server launch), and the infrastructure (dependencies and tunneling exposure).

##### Detailing Essential Elements
- Core components:
- CLI Phase (zphisher.sh)
- Template Selection (each site under the “.sites” folder)
- Runtime PHP Server (index.php and supporting scripts in each template)
- Tunneling and URL masking mechanism (for Ngrok, Cloudflared, etc.)
- Configuration and packaging steps:
- The .package directory, make-deb.sh, and Dockerfile indicate different methods for distribution.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    U("User Input"):::user

    %% Orchestration Layer
    Z("zphisher.sh (Orchestrator)"):::orchestrator

    %% External Dependencies
    DDeps("Dependencies (PHP,wget,curl,git)"):::dependency

    %% Template Manager
    S(" .sites/ (Template Manager)"):::template

    %% Local PHP Server / Runtime Environment
    P("Local PHP Server (Runtime)"):::server

    %% Tunneling / Exposure Module
    T("Tunneling Module (Ngrok/Cloudflared/Localhost)"):::tunnel

    %% Packaging & Deployment
    PD("Packaging & Deployment"):::packaging
    subgraph "Packaging Components"
      PD1(".package/"):::packaging
      PD2("Dockerfile"):::packaging
      PD3("make-deb.sh"):::packaging
    end

    %% Flows
    U -->|"launches"| Z
    DDeps -->|"prerequisites"| Z
    Z -->|"selects template"| S
    Z -->|"launches server"| P
    S -->|"loads template content (index.php etc.)"| P
    P -->|"exposes via tunnel"| T
    Z -->|"triggers"| PD

    %% Click Events
    click Z "https://github.com/nextkool/zphisher/blob/main/zphisher.sh"
    click S "https://github.com/nextkool/zphisher/tree/main/.sites/"
    click PD1 "https://github.com/nextkool/zphisher/tree/main/.package/"
    click PD2 "https://github.com/nextkool/zphisher/tree/main/Dockerfile"
    click PD3 "https://github.com/nextkool/zphisher/blob/main/make-deb.sh"

    %% Styles
    classDef orchestrator fill:#87CEFA,stroke:#000,stroke-width:2px;
    classDef template fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef server fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef tunnel fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef packaging fill:#F08080,stroke:#000,stroke-width:2px;
    classDef dependency fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef user fill:#ADD8E6,stroke:#000,stroke-width:2px;
```
