# sensepost/mallet architecture

> Architecture diagram of the GitHub repository sensepost/mallet, 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/sensepost/mallet
- Repository: https://github.com/sensepost/mallet

## Overview

##### Main Components

a) Core Components:
- Proxy Engine (Netty-based)
- Graph Editor Interface
- Channel Handler System
- Interceptor Components
- Protocol Codec Framework

b) Supporting Components:
- SSL/TLS Handling System
- Script Engine Integration
- Data Model & Persistence Layer
- User Interface Components

##### Key Relationships to Highlight

- Data flow paths through the pipeline system
- Protocol transformation points
- Demonstrate the relationship between interceptors and the main proxy flow

##### Implementation Details

- Relationship between:
- Channel handlers (com.sensepost.mallet.handlers/*)
- SSL components (com.sensepost.mallet.ssl/*)
- Graph management (com.sensepost.mallet.graph/*)
- Model components (com.sensepost.mallet.model/*)

##### Specific Features to Highlight

- Dynamic protocol detection
- SSL/TLS interception capabilities
- Script-based message manipulation
- Real-time traffic inspection
- Multiple protocol support in a single instance

Remember to show both the static architecture (component relationships) and the dynamic aspects (message flow through the system) in separate but related views if necessary.

This design should reflect Mallet's nature as a flexible, extensible proxy framework while clearly showing how it leverages Netty's pipeline architecture for protocol handling.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef ui fill:#FFE5CC,stroke:#FF9933
    classDef core fill:#CCE5FF,stroke:#3399FF
    classDef protocol fill:#D6F5D6,stroke:#4CAF50
    classDef security fill:#FFB3B3,stroke:#FF4D4D
    classDef handler fill:#E6CCE6,stroke:#9933CC

    %% User Interface Layer
    subgraph UI
        GE["Graph Editor"]
        IF["Intercept Frame"]
        CM["Connection Management"]
    end

    %% Core Processing Layer
    subgraph Core
        GEE["Graph Execution Engine"]
        CPM["Channel Pipeline Manager"]
        SEE["Script Execution Environment"]
    end

    %% Protocol Handlers Layer
    subgraph Protocols
        direction TB
        HTTP["HTTP Handler"]
        HTTP2["HTTP2 Handler"]
        WS["WebSocket Handler"]
        ISO["ISO8583 Handler"]
        CP["Custom Protocol Handler"]
        BP["Binary Protocol Handler"]
    end

    %% Network Layer
    subgraph Network
        SOCKS["SOCKS Proxy"]
        TCP["TCP Handler"]
        UDP["UDP Handler"]
        SSL["SSL/TLS Manager"]
    end

    %% Extension Points
    subgraph Extensions
        SH["Script Handlers"]
        CI["Custom Codec Integration"]
        PH["Protocol Handlers"]
    end

    %% Relationships
    GE --> GEE
    IF --> CPM
    CM --> SOCKS
    GEE --> CPM
    CPM --> |Protocol Processing| Protocols
    CPM --> |Network Communication| Network
    SEE --> SH
    SOCKS --> TCP
    SOCKS --> UDP
    TCP & UDP --> SSL
    SSL --> Protocols
    Protocols --> CI
    CI --> PH

    %% Click events for component mapping
    click GE "https://github.com/sensepost/mallet/blob/master/src/main/java/com/sensepost/mallet/swing/GraphEditor.java"
    click IF "https://github.com/sensepost/mallet/blob/master/src/main/java/com/sensepost/mallet/swing/InterceptFrame.java"
    click SSL "https://github.com/sensepost/mallet/tree/master/src/main/java/com/sensepost/mallet/ssl/"
    click HTTP "https://github.com/sensepost/mallet/tree/master/src/main/java/com/sensepost/mallet/handlers/http/"
    click HTTP2 "https://github.com/sensepost/mallet/tree/master/src/main/java/com/sensepost/mallet/handlers/http2/"
    click ISO "https://github.com/sensepost/mallet/tree/master/src/main/java/com/sensepost/mallet/handlers/iso8583/"
    click SOCKS "https://github.com/sensepost/mallet/blob/master/src/main/java/com/sensepost/mallet/SocksServerHandler.java"
    click GEE "https://github.com/sensepost/mallet/tree/master/src/main/java/com/sensepost/mallet/graph/"
    click BP "https://github.com/sensepost/mallet/blob/master/src/main/java/com/sensepost/mallet/handlers/ByteBufAggregationHandler.java"
    click SH "https://github.com/sensepost/mallet/blob/master/scripts/ScriptHandler.groovy"

    %% Style applications
    class GE,IF,CM ui
    class GEE,CPM,SEE core
    class HTTP,HTTP2,WS,ISO,CP,BP protocol
    class SSL,SOCKS security
    class SH,CI,PH handler
```
