# stealthcopter/deepce architecture

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

- Interactive diagram: https://gitdiagram.com/stealthcopter/deepce
- Repository: https://github.com/stealthcopter/deepce

## Overview

##### Main Components
- Main Entry Points:
– The primary deepce.sh script from which enumeration, exploitation, and payload execution is driven.
– Additional wrappers (docker-wrapper.sh and lxc-wrapper.sh) that provide compatibility for different container runtimes.
- Core Functional Modules (logical, even if all are in one script):
– Enumeration Module: Responsible for gathering container environment details (e.g., container ID, container name, IP addresses, mounts, environment variables, etc.).
– Exploitation Module: Contains logic for different exploits such as Docker Group Privilege Escalation, Privileged Mode Exploits, and Docker Sock Exploits.
– Payload Module: Allows execution of post-exploitation payloads like adding a new root user, running custom commands, or launching a reverse shell.
- External Dependencies:
– Standard shell utilities (curl, nmap, nslookup, dig) that the script leverages if available.
- CI/CD and Testing:
– GitHub workflows in the .github folder (for ShellCheck and container tests).
– Test scripts under the tests directory that simulate various container environments and exploits.

##### Relationships and Data Flow
- User Input: Starting with a command-line invocation where flags (e.g., --exploit, --no-enumeration) determine the execution path.
- Flow of Control:
– The main deepce.sh script first parses options and then triggers the enumeration phase (collecting system/environment information).
– Conditional on the provided flags, it proceeds to the exploitation phase where one of the defined exploit methods (DOCKER, PRIVILEGED, SOCK, etc.) is executed.
– If an exploit is selected, appropriate payloads (like reverse shell, root user creation, etc.) are applied.
- External Communication:
– The script may optionally call external utilities (curl, nmap, etc.) for further enumeration or exploitation.
- CI/CD Integration:
– Automated workflows analyze the script with ShellCheck and run container tests to verify the behavior across different container images (alpine, ubuntu, etc.)

##### Architectural Patterns and Design Influences
- Modularity: Although it’s a single script, the internal logic separates enumeration, exploitation, and payload handling clearly.
- Minimal Dependency and Portability: Written in pure sh for maximum compatibility.
- Integration with Container Ecosystems: Leverages lightweight container wrappers and tests different container platforms, reflecting a design considerate of varying environments.
- Automated Testing and Continuous Integration: The inclusion of GitHub workflows and extensive test scripts shows an adherence to maintaining quality in a security-sensitive tool.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User Input/CLI Options"]:::user
    M["Main Script (deepce.sh)"]:::core
    U -->|"parsesOptions"| M

    subgraph "Core Modules"
        E["Enumeration Module"]:::core
        X["Exploitation Module"]:::core
        P["Payload Module"]:::core
        E -->|"collectsData"| X
        X -->|"triggersPayload"| P
    end
    M -->|"initiates"| E
    M -->|"initiates"| X

    subgraph "Container Wrappers"
        D["Docker Wrapper (docker-wrapper.sh)"]:::wrapper
        L["LXC Wrapper (lxc-wrapper.sh)"]:::wrapper
    end
    M -->|"calls"| D
    M -->|"calls"| L

    EU["External Utilities (curl,nmap,nslookup,dig)"]:::external
    E -->|"uses"| EU
    X -->|"uses"| EU

    CI["CI/CD & Testing (GitHub Workflows)"]:::external
    CI -->|"validates"| M

    T["Test Scripts"]:::test
    CI -->|"runsTests"| T

    subgraph "Support Resources"
        DOCS["Documentation (docs/)"]:::docs
        GUIDES["Guides (guides/)"]:::docs
    end
    DOCS -->|"supports"| M
    GUIDES -->|"supports"| M

    %% Click Events
    click M "https://github.com/stealthcopter/deepce/blob/main/deepce.sh"
    click D "https://github.com/stealthcopter/deepce/blob/main/docker-wrapper.sh"
    click L "https://github.com/stealthcopter/deepce/blob/main/lxc-wrapper.sh"
    click CI "https://github.com/stealthcopter/deepce/tree/main/.github/workflows/"
    click T "https://github.com/stealthcopter/deepce/tree/main/tests/"
    click DOCS "https://github.com/stealthcopter/deepce/tree/main/docs/"
    click GUIDES "https://github.com/stealthcopter/deepce/tree/main/guides/"

    %% Styles
    classDef user fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef core fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef wrapper fill:#f94144,stroke:#333,stroke-width:2px;
    classDef external fill:#577590,stroke:#333,stroke-width:2px;
    classDef docs fill:#277da1,stroke:#333,stroke-width:2px;
    classDef test fill:#f3722c,stroke:#333,stroke-width:2px;
```
