# swisskyrepo/ssrfmap architecture

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

## Overview

##### Project Context and Purpose
- SSRFmap is a penetration testing tool aimed at helping security professionals leverage SSRF vulnerabilities. The tool accepts a Burp request file and a target parameter and uses one or more plug-and-play modules (located in the “modules” directory) to craft specialized payloads that interact with various services (e.g., MySQL, Redis, Docker, AWS, etc.).
- The README emphasizes that users can specify a module (or several comma-separated ones) via the command-line interface to test different exploitation scenarios. There’s also integration for reverse shell handling, as evidenced by arguments like “-l” with ports and host settings.

##### File Structure and Its Implications
- Entry Point & Core Logic:
- The main script is ssrfmap.py. This file is the entry point that processes command-line arguments and orchestrates the flow.
- The “core” directory houses key components:
- handler.py – Manages reverse shell or other handler functionalities.
- requester.py – Likely responsible for sending crafted HTTP requests to the target.
- ssrf.py – Contains logic specifically for SSRF exploitation.
- utils.py – Contains utility functions shared between different parts of the tool.
- Modules Directory:
- The “modules” directory includes individual Python files for exploiting specific services (e.g., axfr.py, docker.py, redis.py, etc.). Each module encapsulates the logic required to craft, manipulate, and send payloads specific to a target vulnerability.
- Additional Resources:
- The “data” and “examples” directories provide sample request payloads, test files, and sample vulnerable services to facilitate testing.
- The “handlers” directory (with files like http.py) likely sets up or listens for reverse shell callbacks.
- Other support files include Dockerfile (for containerization), requirements.txt (dependency management), and GitHub configuration files.

##### Final Assembly
- Top Layer: User Input / Command-Line Interface.
- Middle Layer: Core Processing (with sub-blocks for core functions and modules).
- Bottom Layer: External Interaction (target systems, reverse shell handler).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Layer: User Input
    UserInput["User Input (request files)"]:::input
    CLI["CLI Entry Point (ssrfmap.py)"]:::cli

    %% Middle Layer: Core Logic
    Core["Core Logic (core/)"]:::core
    CoreHandler["handler.py"]:::core
    CoreRequester["requester.py"]:::core
    CoreSSR["ssrf.py"]:::core
    CoreUtils["utils.py"]:::core

    %% Exploitation Modules Subgraph
    subgraph "Exploitation Modules (modules/)"
        ModuleAWS["AWS Exploitation (modules/aws.py)"]:::module
        ModuleDocker["Docker Exploitation (modules/docker.py)"]:::module
        ModuleRedis["Redis Exploitation (modules/redis.py)"]:::module
    end

    %% Reverse Shell Handlers Subgraph
    subgraph "Reverse Shell Handlers (handlers/)"
        ReverseHTTP["HTTP Handler (handlers/http.py)"]:::handler
    end

    %% Auxiliary Deployment & Configuration Subgraph
    subgraph "Auxiliary Deployment & Config"
        Dockerfile["Dockerfile"]:::auxiliary
        Req["requirements.txt"]:::auxiliary
        GitHub["CI/CD & Funding (.github/)"]:::auxiliary
    end

    %% User Examples and Payloads Subgraph
    subgraph "User Input Examples & Payloads"
        Examples["Examples Directory (examples/)"]:::input
        Data["Data Directory (data/)"]:::input
    end

    %% Connections
    UserInput -->|"provides_input"| CLI
    CLI -->|"processes_args"| Core
    CLI -->|"reads_deployment"| Dockerfile
    CLI -->|"reads_deployment"| Req
    CLI -->|"reads_deployment"| GitHub
    UserInput -->|"provides_samples"| Examples
    UserInput -->|"provides_data"| Data

    Core -->|"invokes_handler"| CoreHandler
    Core -->|"invokes_requester"| CoreRequester
    Core -->|"runs_ssrf_logic"| CoreSSR
    Core -->|"uses_utilities"| CoreUtils

    Core -->|"delegates_payload"| ModuleAWS
    Core -->|"delegates_payload"| ModuleDocker
    Core -->|"delegates_payload"| ModuleRedis

    ModuleAWS -->|"sends_requests"| Target["Target Services (External)"]:::external
    ModuleDocker -->|"sends_requests"| Target
    ModuleRedis -->|"sends_requests"| Target

    Core -->|"activates_shell"| ReverseHTTP

    %% Click Events
    click CLI "https://github.com/swisskyrepo/ssrfmap/blob/master/ssrfmap.py"
    click Core "https://github.com/swisskyrepo/ssrfmap/tree/master/core/"
    click CoreHandler "https://github.com/swisskyrepo/ssrfmap/blob/master/core/handler.py"
    click CoreRequester "https://github.com/swisskyrepo/ssrfmap/blob/master/core/requester.py"
    click CoreSSR "https://github.com/swisskyrepo/ssrfmap/blob/master/core/ssrf.py"
    click CoreUtils "https://github.com/swisskyrepo/ssrfmap/blob/master/core/utils.py"
    click ModuleAWS "https://github.com/swisskyrepo/ssrfmap/blob/master/modules/aws.py"
    click ModuleDocker "https://github.com/swisskyrepo/ssrfmap/blob/master/modules/docker.py"
    click ModuleRedis "https://github.com/swisskyrepo/ssrfmap/blob/master/modules/redis.py"
    click ReverseHTTP "https://github.com/swisskyrepo/ssrfmap/blob/master/handlers/http.py"
    click Examples "https://github.com/swisskyrepo/ssrfmap/tree/master/examples/"
    click Data "https://github.com/swisskyrepo/ssrfmap/tree/master/data/"
    click Dockerfile "https://github.com/swisskyrepo/ssrfmap/tree/master/Dockerfile"
    click Req "https://github.com/swisskyrepo/ssrfmap/blob/master/requirements.txt"
    click GitHub "https://github.com/swisskyrepo/ssrfmap/tree/master/.github/"

    %% Styles
    classDef cli fill:#FCDFFF,stroke:#333,stroke-width:2px;
    classDef core fill:#D6E5FA,stroke:#333,stroke-width:2px;
    classDef module fill:#FCEBB6,stroke:#333,stroke-width:2px;
    classDef handler fill:#CFF0CC,stroke:#333,stroke-width:2px;
    classDef input fill:#FFE5CC,stroke:#333,stroke-width:2px;
    classDef auxiliary fill:#E5E5FF,stroke:#333,stroke-width:2px;
    classDef external fill:#FFCCCC,stroke:#333,stroke-width:2px;
```
