⚠️ NEW USERS: This tool requires AKS cluster configuration. See CUSTOMER-README.md for quick setup, or run./customer-setup.ps1
An enhanced version of Microsoft's Defender for Cloud Attack Simulation tool, specifically adapted for testing Defender for Containers in AKS environments with additional real-world attack scenarios and improved usability.
This tool simulates various attack scenarios commonly used in real-world attacks against containerized environments:
- Reconnaissance - Gather information about the cluster environment
- Lateral Movement - Cluster to cloud movement and IMDS access
- Secrets Gathering - Search for sensitive information and credentials
- Crypto Mining - Simulate cryptocurrency mining attacks
- Web Shell - Exploit web shells for remote access
- Container Escape - Attempt container breakout techniques
- Privilege Escalation - Escalate privileges within containers
- Binary Drift - Execute binaries not in the original image
- Multi-cluster support - Target specific AKS clusters by resource ID
- Enhanced reporting - Detailed attack logs and timeline
- Custom scenarios - Support for user-defined attack scenarios
- Alert correlation - Track which attacks trigger which Defender alerts
- Automated cleanup - Comprehensive resource cleanup after testing
- Configuration management - Easy configuration for different environments
Option 1: Environment Variables (Recommended)
# Set these environment variables
export AZURE_SUBSCRIPTION_ID="your-subscription-id"
export AZURE_RESOURCE_GROUP="your-resource-group"
export AZURE_CLUSTER_NAME="your-cluster-name"Option 2: Update Configuration File
Edit configs/aks-testing.yaml with your cluster details
Option 3: Interactive Prompt The script will prompt you for cluster details if not configured
# List your AKS clusters
az aks list --output table
# Get specific cluster details
az aks show --name YOUR_CLUSTER_NAME --resource-group YOUR_RESOURCE_GROUP- Admin permissions over the target Kubernetes cluster
- Defender for Containers enabled with the sensor installed:
kubectl get ds microsoft-defender-collector-ds -n kube-system
- Helm 3.x installed locally
- Python 3.7+ installed
- kubectl configured for your target cluster:
az aks get-credentials --name YOUR_CLUSTER_NAME --resource-group YOUR_RESOURCE_GROUP
-
Clone this repository:
git clone <this-repo> cd DefenderForContainers
-
Install Python dependencies:
pip install -r requirements.txt
-
Verify cluster connectivity:
kubectl cluster-info
Run the enhanced simulation:
python enhanced_simulation.pyOr run with specific configuration:
python enhanced_simulation.py --config configs/aks-testing.yamlThe tool supports flexible configuration through YAML files. See configs/ directory for examples.
| Scenario | Expected Alerts |
|---|---|
| Reconnaissance | Possible Web Shell activity detected, Suspicious Kubernetes service account operation detected, Network scanning tool detected |
| Lateral Movement | Possible Web Shell activity detected, Access to cloud metadata service detected |
| Secrets Gathering | Possible Web Shell activity detected, Sensitive files access detected, Possible secret reconnaissance detected |
| Crypto Mining | Possible Web Shell activity detected, Kubernetes CPU optimization detected, Command within a container accessed ld.so.preload, Possible Crypto miners download detected, A drift binary detected executing in the container |
| Container Escape | Privileged container detected, Suspicious mount detected, Container with sensitive volume mount detected |
| Privilege Escalation | Privileged operation detected, Container with high privileges detected |
| Binary Drift | Binary drift detected in container, A drift binary detected executing in the container |
- Dedicated Environment: Run simulations on dedicated test clusters only
- Monitoring: Monitor Defender for Containers alerts during testing
- Cleanup: Always run cleanup after simulations
- Documentation: Document which scenarios trigger which alerts
Beyond the original Microsoft scenarios, this tool includes:
- Multi-stage attack chains
- Data exfiltration techniques
- Command and control communication
- Supply chain attacks
- Image vulnerabilities exploitation
- Runtime security bypass
- Service mesh exploitation
- Istio/Envoy proxy attacks
- Kubernetes API abuse
MIT License - Based on Microsoft's original Defender for Cloud Attack Simulation