# marven11/fenjing architecture

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

- Interactive diagram: https://gitdiagram.com/marven11/fenjing
- Repository: https://github.com/marven11/fenjing

## Overview

##### Main Components
- Command-Line Interface (CLI): Modules like fenjing/cli.py and the __main__.py serve as the entry point for command-line usage (e.g., “scan”, “crack”, “crack-request”, etc.).
- Web UI Component: The fenjing/webui.py module along with its associated templates (in fenjing/templates) handles the web interface, allowing users to interactively launch scans and view results.
- Payload Generation Engine: This is the core of the project and includes modules such as fenjing/payload_gen.py and fenjing/full_payload_gen.py. It leverages a defined set of bypass “rules” (located under fenjing/rules) that encapsulate how to generate and adjust payloads to bypass the WAF.
- Cracker/Attack Module: Modules like fenjing/cracker.py and fenjing/shell_payload.py take the generated payloads and execute the attack logic (for instance, “crack”, “crack-path”, or “crack-request” operations).
- Network/Request Handler: Components such as fenjing/requester.py and fenjing/submitter.py manage HTTP interactions (sending payloads via GET/POST, handling responses, etc.).
- Utility and Configuration Modules: Files such as fenjing/config_payload.py, fenjing/options.py, fenjing/context_vars.py, and the “const” module consolidate configuration, context, and shared constants across the system.
- Testing and Example Components: The “tests” directory and example files (example.py, examples.md) indicate a well-tested design and provide usage demonstrations.

##### Relationship and Interaction Flow
◦ The user begins by invoking a command (via CLI or Web UI).
◦ The CLI/Web UI layer captures user inputs such as target URLs, method of attack, and options (e.g., scan, crack, etc.).
◦ This input is then directed to the Payload Generation Engine, which:
- Consults the rules engine (fenjing/rules) to generate payloads using various bypass techniques (handling key characters, natural numbers, and complex string assembly).
- May also work with the config (via config_payload) to adjust payload settings, ensuring shorter expressions or proper variable substitutions.
◦ Once payloads are generated, the Cracker/Attack module takes over to craft and dispatch HTTP requests to the target. This frequently works with the Network/Request Handler to send the payloads through GET, POST, or even by reading from a prepared request file.
◦ Responses may be processed and fed back to the user interface (CLI output or Web UI rendering), possibly with additional interactive components for further intervention (see the “interactive-panel” template).

##### Architectural Patterns and Principles
- Modularity: The project is divided into clear modules for CLI, Web UI, payload generation, and network interactions.
- Separation of Concerns: Each module (from rule-based payload generation to actual request sending) is clearly isolated, aiding testing and extensibility.
- Extensibility: The “rules” folder and many configuration/utility modules demonstrate a design that allows new payload generation techniques to be incorporated seamlessly.
- Automation: The end-to-end flow—from scanning a target, generating payloads automatically (using predefined rules), to executing an attack—is a key design goal.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface Layer
    subgraph "User Interface"
        subgraph "Command-Line Interface"
            CLI_Main["CLI Main"]:::interface
            CLI_Module["CLI Module"]:::interface
        end
        WebUI["Web UI"]:::interface
        Templates["Templates"]:::interface
    end

    %% Core Engine Layer
    subgraph "Core Engine"
        PayloadGen["Payload Generation Engine"]:::core
        FullPayloadGen["Full Payload Generation Engine"]:::core
        Rules["Rules Engine"]:::core
        subgraph "Utility & Config Modules"
            ConfigPayload["Config Payload"]:::util
            Options["Options"]:::util
            ContextVars["Context Vars"]:::util
            Constants["Constants"]:::util
        end
    end

    %% Attacker Modules
    subgraph "Attacker Module"
        Cracker["Cracker/Attack Module"]:::attack
        ShellPayload["Shell Payload"]:::attack
    end

    %% Networking Components
    subgraph "Networking"
        Requester["Request Handler (Requester)"]:::network
        Submitter["Request Handler (Submitter)"]:::network
    end

    %% Testing and Examples
    subgraph "Testing & Examples"
        Tests["Tests"]:::test
        Example["Example"]:::test
        Examples["Examples Info"]:::test
    end

    %% Connections from User Interfaces to Payload Generation
    CLI_Main -->|"input"| PayloadGen
    CLI_Module -->|"input"| PayloadGen
    WebUI -->|"input"| PayloadGen
    Templates -->|"input"| PayloadGen

    %% Payload Generation consults Rules Engine and Utility Config
    PayloadGen -->|"uses"| Rules
    ConfigPayload -->|"usage"| PayloadGen
    Options -->|"usage"| PayloadGen
    ContextVars -->|"usage"| PayloadGen
    Constants -->|"usage"| PayloadGen

    %% Integration within Payload Generation Engines
    PayloadGen -->|"extends"| FullPayloadGen

    %% Payload Generation sends output to Attack Modules
    PayloadGen -->|"generate_payload"| Cracker
    FullPayloadGen -->|"generate_payload"| Cracker

    %% Attacker Module internal flow
    Cracker -->|"executes_extra"| ShellPayload

    %% Attacker sends attack via Networking components
    Cracker -->|"sends_attack"| Requester
    Cracker -->|"sends_attack"| Submitter

    %% Networking sends feedback to User Interface
    Submitter -->|"feedback"| WebUI

    %% Testing and Examples connections
    Tests -->|"tests"| PayloadGen
    Example -->|"demonstrates"| CLI_Module
    Examples -->|"docs"| WebUI

    %% Styles
    classDef interface fill:#9fdefd,stroke:#1d70b8,stroke-width:2px;
    classDef core fill:#c2f0c2,stroke:#196619,stroke-width:2px;
    classDef attack fill:#ffcc99,stroke:#e68a00,stroke-width:2px;
    classDef network fill:#f9d6ac,stroke:#d48806,stroke-width:2px;
    classDef util fill:#fadadd,stroke:#e60026,stroke-width:2px;
    classDef test fill:#ffe6aa,stroke:#cc9900,stroke-width:2px;

    %% Click Events for Component Mapping
    click CLI_Main "https://github.com/marven11/fenjing/blob/main/fenjing/__main__.py"
    click CLI_Module "https://github.com/marven11/fenjing/blob/main/fenjing/cli.py"
    click WebUI "https://github.com/marven11/fenjing/blob/main/fenjing/webui.py"
    click Templates "https://github.com/marven11/fenjing/tree/main/fenjing/templates/"
    click PayloadGen "https://github.com/marven11/fenjing/blob/main/fenjing/payload_gen.py"
    click FullPayloadGen "https://github.com/marven11/fenjing/blob/main/fenjing/full_payload_gen.py"
    click Rules "https://github.com/marven11/fenjing/tree/main/fenjing/rules/"
    click ConfigPayload "https://github.com/marven11/fenjing/blob/main/fenjing/config_payload.py"
    click Options "https://github.com/marven11/fenjing/blob/main/fenjing/options.py"
    click ContextVars "https://github.com/marven11/fenjing/blob/main/fenjing/context_vars.py"
    click Constants "https://github.com/marven11/fenjing/blob/main/fenjing/const.py"
    click Cracker "https://github.com/marven11/fenjing/blob/main/fenjing/cracker.py"
    click ShellPayload "https://github.com/marven11/fenjing/blob/main/fenjing/shell_payload.py"
    click Requester "https://github.com/marven11/fenjing/blob/main/fenjing/requester.py"
    click Submitter "https://github.com/marven11/fenjing/blob/main/fenjing/submitter.py"
    click Tests "https://github.com/marven11/fenjing/tree/main/tests/"
    click Example "https://github.com/marven11/fenjing/blob/main/example.py"
    click Examples "https://github.com/marven11/fenjing/blob/main/examples.md"
```
