�
i>i�W � �~ � S r SSKJr SSKJr SSKJr SSKJr SSK J
r
SSKJr SSK
Jr SS KJrJr S
\S\4S jrg
)z@Deployment FastMCP tools - scenarios, orchestration, monitoring.� )�Any)�FastMCP)�LudusAPIClient)�ScenarioHandler)�DeploymentHandler)�DeploymentOrchestrator)�ValidationHandler)�LazyHandlerRegistry�format_tool_response�client�returnc � ^ ^� [ S5 n[ T 5 mUR 5 S[ [ [ 4 4U4S jj5 nUR 5 S$S[ S[ S- S[
S[ S [ S
[
S[
S[ [ [ [ 4 S- S
[ [ [ 4 S- S[ [ [ 4 S- S[ [ [ 4 S- S[ 4U4S jjj5 nUR 5 S%S[ S[ S[ 4U4S jjj5 nUR 5 S%S[ S[ S[ 4U4S jjj5 nUR 5 S&S[ S[ S [ S[ 4U4S jjj5 nUR 5 S'S[ S- S[ 4U4S jjj5 nUR 5 S'S[ S- S[ 4U4S jjj5 nUR 5 S'S[ S- S[ 4U 4S jjj5 n UR 5 S(S[ S[ S[
S[
S[
S[ S- S[ 4U4S jjj5 n
UR 5 S)S[ S- S[ S[ S[ 4U4S jjj5 nUR 5 S'S[ S- S[ 4U4S jjj5 nUR 5 S[ [ [ 4 S[ 4U4S jj5 n
UR 5 S*S![ S"[
S[ S- S[ 4U4S# jjj5 nU$ )+z�Create deployment operation tools.
Args:
client: Ludus API client
Returns:
FastMCP instance with deployment tools registered
zDeployment Operationsr
c � �p ># � TR S[ 5 n U R 5 I Sh v�N nU$ N7f)zYList all available scenarios.
Returns:
Dictionary of scenario keys and descriptions
�scenarioN)�get_handlerr �list_scenarios)�handler�result�registrys ��Q/home/tjnull/Documents/scripts/Ludus-FastMCP/ludus_mcp/server/tools/deployment.pyr �/create_deployment_tools.<locals>.list_scenarios s5 �� � � �&�&�z�?�C���-�-�/�/���
� 0�s �*6�4�6N�scenario_key�user_id�ensure_roles� siem_type�resource_profile� customize� randomize�custom_users�vulnerability_config�network_customizations�vm_customizationsc � �v ># � T
R S[ 5 nUR XX#U5 I Sh v�N nU$ N7f)u� Deploy a scenario with optional SIEM integration and customization.
IMPORTANT: This tool generates a FRESH configuration for each call.
Each deployment builds a new scenario from scratch - no state is reused.
NO FILE UPLOAD REQUIRED: This tool automatically generates the configuration
from the scenario parameters. You do NOT need to provide a config file or
manual configuration.
CUSTOMIZATION AND RANDOMIZATION:
- Use customize=True with custom parameters to deploy a customized scenario
- Use randomize=True to deploy a randomized version with varied users/vulnerabilities
- All customization parameters are optional - defaults used if not specified
Recommended Workflow:
1. Use preview_scenario() first to verify what will be deployed
2. (Optional) Abort any existing deployment: abort_range_deployment()
3. (Optional) Delete existing range: delete_range(confirm=True)
4. Deploy the scenario: deploy_scenario(scenario_key='redteam-lab-lite')
5. Monitor progress: monitor_deployment() or quick_status()
Internal Workflow:
1. Generates fresh scenario configuration based on parameters
2. Applies customizations or randomization if requested
3. Sets the configuration in Ludus (via PUT /range/config)
4. Verifies the configuration was set correctly
5. Starts deployment (via POST /range/deploy)
6. Generates comprehensive walkthrough
7. Returns deployment status, VM details, and walkthrough
Available scenarios:
- redteam-lab-lite: 5 VMs (DC, 2 workstations, file server, Kali)
- redteam-lab-intermediate: 10 VMs (DMZ, internal network, multiple servers)
- redteam-lab-advanced: 21 VMs (2 forests with trust, DMZ, secure zone)
- blueteam-lab-lite: 6 VMs (SOC with SIEM, detection)
- blueteam-lab-intermediate: 11 VMs (SOC with EDR, IDS)
- blueteam-lab-advanced: 21 VMs (Enterprise SOC, full stack)
- purpleteam-lab-lite: 6 VMs (Red/Blue collaborative)
- purpleteam-lab-intermediate: 10 VMs (Purple team with EDR)
- purpleteam-lab-advanced: 13 VMs (Full SOC + adversary emulation)
- malware-re-lab-lite: 3 VMs (Basic malware analysis)
- malware-re-lab-intermediate: 7 VMs (Pro malware lab)
- malware-re-lab-advanced: 18 VMs (Enterprise malware research)
- wireless-lab: 2 VMs (WiFi pentesting)
Args:
scenario_key: Scenario identifier (e.g., 'redteam-lab-lite')
user_id: Optional user ID (admin only)
ensure_roles: Ensure required Ansible roles are installed
siem_type: SIEM type to include (wazuh, splunk, elastic, security-onion, none)
resource_profile: Resource allocation profile (minimal, recommended, maximum)
customize: Enable customization mode (use provided customizations)
randomize: Enable randomization mode (generate random customizations)
custom_users: List of custom user dicts with keys: username, password, display_name,
groups (list), department (optional), title (optional), etc.
vulnerability_config: Dict with keys like esc1_enabled, esc2_enabled, open_shares, etc.
network_customizations: Dict with vlan_changes, additional_rules, remove_rules, etc.
vm_customizations: Dict with vm_count_overrides, additional_vms, remove_vms, etc.
Returns:
Deployment result with scenario details, VM list, deployment status, and walkthrough
Examples:
# Simple deployment (default)
deploy_scenario(scenario_key='redteam-lab-lite', siem_type='none')
# Randomized deployment
deploy_scenario(scenario_key='redteam-lab-lite', randomize=True)
# Custom users deployment
deploy_scenario(
scenario_key='redteam-lab-lite',
customize=True,
custom_users=[
{
"username": "admin.user",
"password": "CustomPass123!",
"display_name": "Admin User",
"groups": ["Domain Users", "Domain Admins"],
"department": "IT"
}
]
)
# Custom vulnerabilities
deploy_scenario(
scenario_key='redteam-lab-lite',
customize=True,
vulnerability_config={
"esc1_enabled": True,
"esc8_enabled": True,
"open_shares": True
}
)
Natural Language Translation:
- "Make a custom range using redteam-lab-lite" → customize=True
- "Randomize redteam-lab-lite" → randomize=True
- "Deploy with different users" → customize=True, custom_users=[...]
Note: For automated deployments with validation and monitoring,
consider using smart_deploy() instead, which handles the full workflow.
r N)r r �deploy_scenario)r r r r r r r r r r! r"