How stealthcopter/deepce works
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.