<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>MITRE Caldera API Interface</title> <script> const CALDERA_URL = "http://localhost:8888/api/v2"; const API_KEY = "your_api_key_here"; const HEADERS = { "Content-Type": "application/json", "Authorization": `Bearer ${API_KEY}` }; async function getAgents() { try { let response = await fetch(`${CALDERA_URL}/agents`, { headers: HEADERS }); if (!response.ok) throw new Error(`Error: ${response.status} - ${response.statusText}`); let agents = await response.json(); displayAgents(agents); } catch (error) { console.error("Error fetching agents:", error); document.getElementById("agents").innerText = "Failed to load agents."; } } function displayAgents(agents) { let container = document.getElementById("agents"); container.innerHTML = ""; if (agents.length === 0) { container.innerText = "No agents found."; return; } agents.forEach(agent => { let btn = document.createElement("button"); btn.innerText = `Attack ${agent.host} (${agent.platform})`; btn.onclick = () => createOperation(agent.id, agent.host); container.appendChild(document.createElement("br")); container.appendChild(btn); }); } async function createOperation(agentId, agentHost) { const adversaryId = "a3b48e27-6a86-4dd4-85b7-3c530d6056c4"; let data = { name: `Exploit ${agentHost}`, agents: [agentId], adversary_id: adversaryId, group: "default", state: "running" }; try { let response = await fetch(`${CALDERA_URL}/operations`, { method: "POST", headers: HEADERS, body: JSON.stringify(data) }); if (!response.ok) throw new Error(`Error: ${response.status} - ${response.statusText}`); let operation = await response.json(); alert(`Operation started successfully: ${operation.id}`); } catch (error) { console.error("Error creating operation:", error); alert("Failed to create operation."); } } </script> </head> <body> <h1>MITRE Caldera Attack Simulation</h1> <button onclick="getAgents()">Fetch Agents</button> <div id="agents"></div> </body> </html>