
Executing Red Team Exercise
- 71 installs
- 27.3k repo stars
- Updated August 2, 2026
- mukul975/anthropic-cybersecurity-skills
Helps with ai & agent building tasks.
About
executing-red-team-exercise is a Claude Code skill for ai & agent building. It helps developers move faster with AI-assisted coding.
- executing-red-team-exercise
- AI & Agent Building
- AI-coding skill
Executing Red Team Exercise by the numbers
- 71 all-time installs (skills.sh)
- Ranked #5,673 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill executing-red-team-exerciseAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 71 |
|---|---|
| repo stars | ★ 27.3k |
| Last updated | August 2, 2026 |
| Repository | mukul975/anthropic-cybersecurity-skills ↗ |
What it does
Helps with ai & agent building tasks.
Files
Executing Red Team Exercise
When to Use
- Assessing an organization's ability to detect, respond to, and contain a realistic adversary operation
- Testing the effectiveness of the security operations center (SOC), incident response team, and threat hunting capabilities
- Validating security investments by simulating attacks that chain multiple vulnerabilities and techniques
- Evaluating the organization's security posture against specific threat actors (nation-state, ransomware groups, insider threats)
- Meeting regulatory requirements for adversary simulation (TIBER-EU, CBEST, AASE, iCAST)
Do not use without executive-level authorization and a detailed Rules of Engagement document, against systems where disruption could affect safety or critical operations, or as a replacement for basic vulnerability management (fix known vulnerabilities first).
Prerequisites
- Executive-level written authorization with clearly defined objectives, scope, and off-limits systems
- Red team command and control (C2) infrastructure: primary and backup C2 channels with domain fronting or redirectors
- Operator workstations with OPSEC-hardened toolsets (Cobalt Strike, Sliver, Brute Ratel, or Mythic)
- Threat intelligence on adversary groups relevant to the target organization for adversary emulation planning
- Trusted agent (white cell) within the target organization who manages the exercise boundaries without alerting defenders
- MITRE ATT&CK matrix for mapping planned and executed techniques
Legal Notice: This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.
Workflow
Step 1: Adversary Emulation Planning
Develop the operation plan based on a realistic threat model:
- Threat actor selection: Select an adversary group relevant to the organization's industry. For financial services, emulate FIN7 or Lazarus Group. For healthcare, emulate APT41 or FIN12. Map the selected adversary's known TTPs from MITRE ATT&CK.
- Objective definition: Define measurable objectives such as "Access customer financial data from the core banking system" or "Demonstrate ability to deploy ransomware across the domain"
- Attack plan development: Create a step-by-step operation plan mapping each phase to ATT&CK tactics:
1. Initial Access (TA0001): Phishing, exploiting public-facing applications, or supply chain compromise 2. Execution (TA0002): PowerShell, scripting, exploitation for client execution 3. Persistence (TA0003): Scheduled tasks, registry modifications, implant deployment 4. Privilege Escalation (TA0004): Token impersonation, exploitation for privilege escalation 5. Defense Evasion (TA0005): Process injection, timestomping, indicator removal 6. Credential Access (TA0006): LSASS dumping, Kerberoasting, credential stuffing 7. Lateral Movement (TA0008): Remote services, pass-the-hash, remote desktop 8. Collection/Exfiltration (TA0009/TA0010): Data staging, exfiltration over C2
- Deconfliction plan: Establish procedures for the white cell to distinguish red team activity from actual threats
Step 2: Infrastructure Preparation
Build OPSEC-hardened attack infrastructure:
- C2 infrastructure: Deploy primary C2 server behind redirectors that filter Blue Team investigation traffic. Use domain fronting or legitimate cloud services (Azure CDN, CloudFront) to blend C2 traffic with normal web traffic.
- Phishing infrastructure: Register aged domains (30+ days old), configure SPF/DKIM/DMARC, and build credential harvesting or payload delivery pages
- Payload development: Create custom implants or configure C2 framework payloads with:
- AMSI bypass for PowerShell execution
- ETW patching to evade security product telemetry
- Sleep masking and memory encryption to defeat memory scanning
- Signed binary proxy execution (rundll32, msbuild, regsvr32) for defense evasion
- Staging infrastructure: Set up file hosting for second-stage payloads, exfiltration drop servers, and backup communication channels
- OPSEC verification: Test the entire infrastructure against the same EDR/AV products deployed in the target environment before going live
Step 3: Initial Access
Gain initial foothold in the target environment:
- Phishing campaign: Send targeted spear-phishing emails to selected employees with weaponized documents or credential harvesting links. Use pretexts based on OSINT gathered during reconnaissance.
- External exploitation: Exploit vulnerabilities in internet-facing applications (VPN portals, web applications, email servers) identified during reconnaissance
- Physical access: If in scope, attempt physical access to deploy network implants (LAN Turtle, Bash Bunny) or USB drops
- Supply chain: If in scope, compromise a vendor or supplier relationship to gain indirect access
- Upon successful initial access, establish the first C2 beacon and confirm communication with the C2 server. Immediately implement persistence (multiple mechanisms) to survive reboots and credential changes.
Step 4: Post-Exploitation and Objective Completion
Operate within the target environment while maintaining stealth:
- Internal reconnaissance: Enumerate the domain, identify high-value targets, and map the network using BloodHound and internal scanning, with traffic designed to blend with normal administrative activity
- Privilege escalation: Escalate from initial user to local admin, then to domain admin, using the least detectable techniques (Kerberoasting over pass-the-hash, living-off-the-land over custom tools)
- Lateral movement: Move to target systems using legitimate protocols (RDP, WinRM, SMB) with stolen credentials. Vary techniques to test multiple detection signatures.
- Defense evasion: Continuously adapt to avoid detection. If a technique triggers an alert, note the detection and switch to an alternative approach.
- Objective execution: Complete the defined objectives (access target data, demonstrate ransomware staging, exfiltrate data) and document evidence of achievement
- Detection timeline: Record timestamps for every technique executed to later compare against Blue Team's detection timeline
Step 5: Purple Team Integration and Reporting
Convert red team findings into defensive improvements:
- Detection gap analysis: Compare the red team's technique timeline against the Blue Team's detection log. Identify which techniques were detected, which were missed, and the mean time to detect (MTTD) for each.
- ATT&CK coverage mapping: Create an ATT&CK Navigator heatmap showing which techniques were tested and whether they were detected, missed, or partially detected
- Purple team sessions: Conduct collaborative sessions where the red team reveals each technique step-by-step while the Blue Team identifies where detection should have occurred and writes new detection rules
- Report: Deliver a comprehensive report including the operation narrative, technique-by-technique analysis with detection status, and prioritized recommendations for improving detection and response
Key Concepts
| Term | Definition |
|---|---|
| Adversary Emulation | Simulating the specific TTPs of a known threat actor to test defenses against realistic threats relevant to the organization |
| C2 (Command and Control) | Infrastructure and communication channels used by the red team to remotely control implants deployed on compromised systems |
| OPSEC | Operational Security; practices employed by the red team to avoid detection by the defending team during the exercise |
| Domain Fronting | A technique for hiding C2 traffic behind legitimate CDN domains to evade network-based detection and domain blocking |
| Purple Teaming | Collaborative exercise where red and blue teams work together to improve detection by sharing attack techniques and defensive gaps |
| White Cell | The trusted agent or exercise control group that manages the exercise, handles deconfliction, and mediates between red and blue teams |
| Implant | Software deployed by the red team on compromised systems to maintain access, execute commands, and facilitate lateral movement |
| MTTD/MTTR | Mean Time to Detect / Mean Time to Respond; metrics measuring how long it takes the defending team to identify and contain threats |
Tools & Systems
- Cobalt Strike: Commercial adversary simulation platform providing beacons, malleable C2 profiles, and post-exploitation capabilities
- Sliver: Open-source C2 framework supporting multiple protocols (mTLS, WireGuard, HTTP/S, DNS) with cross-platform implants
- MITRE ATT&CK Navigator: Tool for visualizing ATT&CK technique coverage, enabling comparison of planned vs. executed vs. detected techniques
- Mythic: Open-source C2 framework with a modular agent architecture and web-based operator interface
Common Scenarios
Scenario: Adversary Emulation of FIN7 Against a Retail Company
Context: A national retail chain wants to test its defenses against FIN7, a financially motivated threat group known for targeting retail and hospitality organizations with point-of-sale malware, phishing, and data exfiltration.
Approach: 1. Emulate FIN7 TTPs: spear-phishing with malicious document containing VBA macros that execute PowerShell 2. Initial access achieved through spear-phishing a marketing employee; macro drops Cobalt Strike beacon using rundll32 proxy execution 3. Internal reconnaissance with BloodHound reveals a path from the compromised user to a service account with access to the POS management server 4. Kerberoast the service account, crack the password, and move laterally to the POS management system 5. Demonstrate data access to cardholder data environment, staging simulated card data for exfiltration 6. Exfiltrate staged data over DNS C2 channel to simulate data theft 7. SOC detected the lateral movement at hour 47 but did not detect the initial phishing, macro execution, or Kerberoasting
Pitfalls:
- Operating too aggressively and getting detected immediately, providing no value for testing Blue Team's advanced detection capabilities
- Using exclusively custom tools instead of living-off-the-land techniques that real adversaries prefer
- Not recording detailed timestamps for every action, making post-exercise analysis and detection gap mapping impossible
- Failing to establish backup C2 channels, getting burned by a single detection, and losing access without completing objectives
Output Format
## Red Team Exercise Report - FIN7 Adversary Emulation
### Exercise Summary
**Duration**: November 4-22, 2025 (15 business days)
**Objective**: Access cardholder data environment and demonstrate data exfiltration capability
**Outcome**: OBJECTIVE ACHIEVED - Red team accessed POS management system and staged cardholder data for exfiltration
### ATT&CK Technique Coverage
| Technique | ID | Status | Detected? | MTTD |
|-----------|----|--------|-----------|------|
| Spear-Phishing Attachment | T1566.001 | Executed | No | - |
| Visual Basic Macro | T1059.005 | Executed | No | - |
| Process Injection | T1055 | Executed | No | - |
| Kerberoasting | T1558.003 | Executed | No | - |
| Remote Desktop Protocol | T1021.001 | Executed | YES | 47h |
| Data Staged | T1074 | Executed | No | - |
| Exfiltration Over C2 | T1041 | Executed | No | - |
### Detection Summary
- **Techniques Executed**: 14
- **Techniques Detected**: 3 (21.4%)
- **Mean Time to Detect**: 47 hours (for detected techniques)
- **Mean Time to Respond**: 4 hours (from detection to containment)
### Priority Recommendations
1. Deploy email detonation sandboxing for macro-enabled document analysis
2. Implement Kerberoasting detection via Windows Event ID 4769 monitoring
3. Enhance PowerShell logging (Script Block Logging, Module Logging)
4. Deploy memory-scanning EDR capability to detect process injection
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. Please do not remove or change
the license header comment from a contributed file except when
necessary.
Copyright 2026 mukul975
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
API Reference: Red Team Exercise Agent
Dependencies
| Library | Version | Purpose |
|---|---|---|
| requests | >=2.28 | Download MITRE ATT&CK STIX data |
CLI Usage
python scripts/agent.py \
--actor "APT29" \
--target "Retail Corp" \
--objectives "Access POS data" "Exfiltrate cardholder data" \
--output redteam_plan.jsonFunctions
load_attack_techniques(cache_file) -> dict
Downloads or loads cached MITRE ATT&CK Enterprise STIX bundle from GitHub (mitre/cti).
get_actor_techniques(attack_data, actor_name) -> list
Resolves intrusion-set by name, follows uses relationships to collect attack-pattern objects. Returns list of {id, name, tactic}.
build_operation_plan(actor_name, target, objectives, attack_data) -> RedTeamOperation
Creates a full operation plan with technique list mapped from the emulated actor's known TTPs.
log_technique_execution(op, technique_id, detected, notes)
Updates a technique's status to executed, records detection boolean and timestamp.
generate_detection_gap_report(op) -> dict
Compares executed vs. detected techniques. Outputs detection rate and missed technique recommendations.
Data Classes
TechniqueExecution
technique_id,technique_name,tactic,timestamp,status,detected,detection_time,notes
RedTeamOperation
operation_name,target_org,emulated_actor,start_date,objectives,techniques
MITRE ATT&CK Data Source
- URL:
https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json - Format: STIX 2.0 bundle with
intrusion-set,attack-pattern, andrelationshipobjects - Locally cached as
attack_enterprise.jsonafter first download
#!/usr/bin/env python3
# For authorized testing in lab/CTF environments only
"""Red team exercise planning and ATT&CK technique tracking agent."""
import argparse
import json
import logging
from datetime import datetime
from dataclasses import dataclass, field, asdict
from typing import List
try:
import requests
except ImportError:
import sys; sys.exit("requests is required: pip install requests")
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
logger = logging.getLogger(__name__)
MITRE_ATTACK_URL = "https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json"
@dataclass
class TechniqueExecution:
technique_id: str
technique_name: str
tactic: str
timestamp: str = ""
status: str = "planned"
detected: bool = False
detection_time: str = ""
notes: str = ""
@dataclass
class RedTeamOperation:
operation_name: str
target_org: str
emulated_actor: str
start_date: str
objectives: List[str] = field(default_factory=list)
techniques: List[TechniqueExecution] = field(default_factory=list)
def load_attack_techniques(cache_file: str = "attack_enterprise.json") -> dict:
"""Load MITRE ATT&CK Enterprise techniques from local cache or upstream."""
import os
if os.path.exists(cache_file):
with open(cache_file) as f:
return json.load(f)
logger.info("Downloading ATT&CK Enterprise data...")
resp = requests.get(MITRE_ATTACK_URL, timeout=60)
resp.raise_for_status()
data = resp.json()
with open(cache_file, "w") as f:
json.dump(data, f)
return data
def get_actor_techniques(attack_data: dict, actor_name: str) -> List[dict]:
"""Extract techniques used by a specific threat actor from ATT&CK data."""
actor_id = None
for obj in attack_data.get("objects", []):
if obj.get("type") == "intrusion-set" and actor_name.lower() in obj.get("name", "").lower():
actor_id = obj["id"]
break
if not actor_id:
logger.warning("Actor '%s' not found in ATT&CK data", actor_name)
return []
technique_refs = set()
for obj in attack_data.get("objects", []):
if obj.get("type") == "relationship" and obj.get("source_ref") == actor_id:
if obj.get("relationship_type") == "uses":
technique_refs.add(obj["target_ref"])
techniques = []
for obj in attack_data.get("objects", []):
if obj.get("id") in technique_refs and obj.get("type") == "attack-pattern":
ext_refs = obj.get("external_references", [])
tech_id = next((r["external_id"] for r in ext_refs if r.get("source_name") == "mitre-attack"), "")
kill_chain = obj.get("kill_chain_phases", [{}])
tactic = kill_chain[0].get("phase_name", "") if kill_chain else ""
techniques.append({"id": tech_id, "name": obj["name"], "tactic": tactic})
logger.info("Found %d techniques for actor '%s'", len(techniques), actor_name)
return techniques
def build_operation_plan(actor_name: str, target: str, objectives: List[str],
attack_data: dict) -> RedTeamOperation:
"""Create a red team operation plan based on emulated threat actor TTPs."""
techniques = get_actor_techniques(attack_data, actor_name)
executions = [
TechniqueExecution(
technique_id=t["id"], technique_name=t["name"],
tactic=t["tactic"], status="planned",
)
for t in techniques
]
return RedTeamOperation(
operation_name=f"{actor_name} Emulation - {target}",
target_org=target, emulated_actor=actor_name,
start_date=datetime.utcnow().isoformat(),
objectives=objectives, techniques=executions,
)
def log_technique_execution(op: RedTeamOperation, technique_id: str,
detected: bool = False, notes: str = "") -> None:
"""Mark a technique as executed and record detection status."""
for tech in op.techniques:
if tech.technique_id == technique_id:
tech.status = "executed"
tech.timestamp = datetime.utcnow().isoformat()
tech.detected = detected
if detected:
tech.detection_time = datetime.utcnow().isoformat()
tech.notes = notes
logger.info("Technique %s executed (detected=%s)", technique_id, detected)
return
logger.warning("Technique %s not found in operation plan", technique_id)
def generate_detection_gap_report(op: RedTeamOperation) -> dict:
"""Produce a detection gap analysis comparing executed vs detected techniques."""
executed = [t for t in op.techniques if t.status == "executed"]
detected = [t for t in executed if t.detected]
missed = [t for t in executed if not t.detected]
return {
"operation": op.operation_name,
"emulated_actor": op.emulated_actor,
"total_techniques_planned": len(op.techniques),
"techniques_executed": len(executed),
"techniques_detected": len(detected),
"techniques_missed": len(missed),
"detection_rate": f"{len(detected)/len(executed)*100:.1f}%" if executed else "N/A",
"detected_list": [asdict(t) for t in detected],
"missed_list": [asdict(t) for t in missed],
"recommendations": [
f"Improve detection for {t.technique_id} ({t.technique_name})"
for t in missed
],
}
def main():
parser = argparse.ArgumentParser(description="Red Team Exercise Agent")
parser.add_argument("--actor", required=True, help="Threat actor to emulate (e.g., APT29)")
parser.add_argument("--target", required=True, help="Target organization name")
parser.add_argument("--objectives", nargs="+", default=["Demonstrate domain compromise"])
parser.add_argument("--output", default="redteam_plan.json")
args = parser.parse_args()
attack_data = load_attack_techniques()
op = build_operation_plan(args.actor, args.target, args.objectives, attack_data)
report = {
"operation": asdict(op),
"technique_count": len(op.techniques),
"tactics_covered": list(set(t.tactic for t in op.techniques if t.tactic)),
}
with open(args.output, "w") as f:
json.dump(report, f, indent=2)
logger.info("Operation plan saved to %s", args.output)
print(json.dumps(report, indent=2))
if __name__ == "__main__":
main()