| <!DOCTYPE html>
|
| <html lang="en">
|
| <head>
|
| <meta charset="UTF-8">
|
| <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| <title>RAT Dashboard</title>
|
| <style>
|
| body { font-family: sans-serif; margin: 20px; }
|
| button { margin: 5px; padding: 8px 12px; cursor: pointer; }
|
| textarea { width: 100%; height: 100px; margin: 5px 0; }
|
| pre { border: 1px solid #ccc; padding: 10px; overflow-x: auto; }
|
| .error { color: red; }
|
| .success { color: green; }
|
| table { border-collapse: collapse; width: 100%; }
|
| th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
|
| th { background-color: #f2f2f2; }
|
| .loading { opacity: 0.6; pointer-events: none; }
|
| .form-group { margin-bottom: 10px; }
|
| .form-group label { display: block; margin-bottom: 5px; }
|
| button.loading::after {
|
| content: "";
|
| position: absolute;
|
| width: 16px;
|
| height: 16px;
|
| top: 50%;
|
| left: 50%;
|
| margin: -8px 0 0 -8px;
|
| border: 2px solid #f3f3f3;
|
| border-top: 2px solid #3498db;
|
| border-radius: 50%;
|
| animation: spin 1s linear infinite;
|
| }
|
| @keyframes spin {
|
| 0% { transform: rotate(0deg); }
|
| 100% { transform: rotate(360deg); }
|
| }
|
| .deployment-feedback {
|
| margin-top: 10px;
|
| padding: 10px;
|
| border: 1px solid #ddd;
|
| background-color: #f9f9f9;
|
| }
|
| .deployment-feedback.pending { background-color: #ffffcc; }
|
| .deployment-feedback.in-progress { background-color: #ccffff; }
|
| .deployment-feedback.success { background-color: #ccffcc; }
|
| .deployment-feedback.error { background-color: #ffcccc; }
|
| </style>
|
| </head>
|
| <body>
|
| <h1>RAT Dashboard</h1>
|
|
|
| <div class="form-group">
|
| <label for="apiKey">API Key:</label>
|
| <input type="text" id="apiKey" placeholder="Enter API Key" required>
|
| <button onclick="saveApiKey()">Save API Key</button>
|
| </div>
|
|
|
| <h2>Create RAT Server</h2>
|
| <form id="createRatServerForm">
|
| <div class="form-group">
|
| <label for="serverIP">Server IP:</label>
|
| <input type="text" id="serverIP" placeholder="Server IP" required>
|
| </div>
|
| <div class="form-group">
|
| <label for="serverPort">Server Port:</label>
|
| <input type="number" id="serverPort" placeholder="Server Port" required>
|
| </div>
|
| <div class="form-group">
|
| <label for="encryptionMethod">Encryption Method:</label>
|
| <input type="text" id="encryptionMethod" placeholder="Encryption Method">
|
| </div>
|
| <div class="form-group">
|
| <label for="serverDeploymentMethod">Deployment Method:</label>
|
| <select id="serverDeploymentMethod">
|
| <option value="ssh">SSH</option>
|
| <option value="powershell">PowerShell</option>
|
| <option value="manual">Manual</option>
|
| </select>
|
| </div>
|
| <button type="submit">Create Server</button>
|
| </form>
|
| <pre id="createServerResult"></pre>
|
|
|
| <h2>Create RAT Client</h2>
|
| <form id="createRatClientForm">
|
| <div class="form-group">
|
| <label for="clientConfig">Client Config (JSON):</label>
|
| <textarea id="clientConfig" placeholder="Client Config (JSON)" required></textarea>
|
| </div>
|
| <div class="form-group">
|
| <label for="clientDeploymentMethod">Deployment Method:</label>
|
| <select id="clientDeploymentMethod">
|
| <option value="ssh">SSH</option>
|
| <option value="powershell">PowerShell</option>
|
| <option value="manual">Manual</option>
|
| </select>
|
| </div>
|
| <button type="submit">Create Client</button>
|
| </form>
|
| <pre id="createClientResult"></pre>
|
|
|
| <h2>Generate RAT with AI</h2>
|
| <form id="generateRatAIForm">
|
| <div class="form-group">
|
| <label for="aiGoal">AI Goal:</label>
|
| <input type="text" id="aiGoal" placeholder="AI Goal" required>
|
| </div>
|
| <div class="form-group">
|
| <label for="aiConstraints">AI Constraints (JSON):</label>
|
| <textarea id="aiConstraints" placeholder="AI Constraints (JSON)"></textarea>
|
| </div>
|
| <button type="submit">Generate with AI</button>
|
| </form>
|
| <pre id="generateAIResult"></pre>
|
|
|
| <h2>List RAT Servers</h2>
|
| <button onclick="listRatServers()">List Servers</button>
|
| <div id="ratServerListContainer"></div>
|
|
|
| <h2>List RAT Clients</h2>
|
| <button onclick="listRatClients()">List Clients</button>
|
| <div id="ratClientListContainer"></div>
|
|
|
| <script>
|
| const API_BASE_URL = '/api/rat'; // Backend API endpoint
|
| let apiKey = localStorage.getItem('apiKey') || '';
|
| document.getElementById('apiKey').value = apiKey;
|
|
|
| function saveApiKey() {
|
| apiKey = document.getElementById('apiKey').value;
|
| localStorage.setItem('apiKey', apiKey);
|
| alert('API Key saved!');
|
| }
|
|
|
| async function createRatServer(event) {
|
| event.preventDefault();
|
| const serverIP = document.getElementById('serverIP').value;
|
| const serverPort = document.getElementById('serverPort').value;
|
| const encryptionMethod = document.getElementById('encryptionMethod').value;
|
| const deploymentMethod = document.getElementById('serverDeploymentMethod').value;
|
| const createButton = document.querySelector('#createRatServerForm button');
|
|
|
| if (!serverIP || !serverPort) {
|
| document.getElementById('createServerResult').textContent = 'Error: Server IP and Port are required.';
|
| document.getElementById('createServerResult').classList.add('error');
|
| return;
|
| }
|
|
|
| createButton.classList.add('loading');
|
| try {
|
| const response = await fetch(`${API_BASE_URL}/servers`, {
|
| method: 'POST',
|
| headers: { 'Content-Type': 'application/json', 'X-API-Key': apiKey },
|
| body: JSON.stringify({ server_ip: serverIP, server_port: parseInt(serverPort), encryption_method: encryptionMethod, deployment_method: deploymentMethod })
|
| });
|
| const data = await response.json();
|
| if (response.ok) {
|
| document.getElementById('createServerResult').textContent = 'RAT server created successfully: ' + JSON.stringify(data, null, 2);
|
| document.getElementById('createServerResult').classList.remove('error');
|
| document.getElementById('createServerResult').classList.add('success');
|
| listRatServers(); // Update the list after creating a server
|
| } else {
|
| document.getElementById('createServerResult').textContent = 'Error creating RAT server: ' + JSON.stringify(data, null, 2);
|
| document.getElementById('createServerResult').classList.add('error');
|
| document.getElementById('createServerResult').classList.remove('success');
|
| }
|
| } catch (error) {
|
| console.error('Error:', error);
|
| document.getElementById('createServerResult').textContent = 'Error creating RAT server: ' + error;
|
| document.getElementById('createServerResult').classList.add('error');
|
| document.getElementById('createServerResult').classList.remove('success');
|
| } finally {
|
| createButton.classList.remove('loading');
|
| }
|
| }
|
|
|
| async function createRatClient(event) {
|
| event.preventDefault();
|
| const clientConfig = document.getElementById('clientConfig').value;
|
| const deploymentMethod = document.getElementById('clientDeploymentMethod').value;
|
| const createButton = document.querySelector('#createRatClientForm button');
|
|
|
| if (!clientConfig) {
|
| document.getElementById('createClientResult').textContent = 'Error: Client config is required.';
|
| document.getElementById('createClientResult').classList.add('error');
|
| return;
|
| }
|
|
|
| createButton.classList.add('loading');
|
| try {
|
| const response = await fetch(`${API_BASE_URL}/clients`, {
|
| method: 'POST',
|
| headers: { 'Content-Type': 'application/json', 'X-API-Key': apiKey },
|
| body: JSON.stringify({ config: JSON.parse(clientConfig), deployment_method: deploymentMethod })
|
| });
|
| const data = await response.json();
|
| if (response.ok) {
|
| document.getElementById('createClientResult').textContent = 'RAT client created successfully: ' + JSON.stringify(data, null, 2);
|
| document.getElementById('createClientResult').classList.remove('error');
|
| document.getElementById('createClientResult').classList.add('success');
|
| listRatClients(); // Update the list after creating a client
|
| } else {
|
| document.getElementById('createClientResult').textContent = 'Error creating RAT client: ' + JSON.stringify(data, null, 2);
|
| document.getElementById('createClientResult').classList.add('error');
|
| document.getElementById('createClientResult').classList.remove('success');
|
| }
|
| } catch (error) {
|
| console.error('Error:', error);
|
| document.getElementById('createClientResult').textContent = 'Error creating RAT client: ' + error;
|
| document.getElementById('createClientResult').classList.add('error');
|
| document.getElementById('createClientResult').classList.remove('success');
|
| } finally {
|
| createButton.classList.remove('loading');
|
| }
|
| }
|
|
|
| async function generateRatAI(event) {
|
| event.preventDefault();
|
| const aiGoal = document.getElementById('aiGoal').value;
|
| const aiConstraints = document.getElementById('aiConstraints').value;
|
| const generateButton = document.querySelector('#generateRatAIForm button');
|
|
|
| if (!aiGoal) {
|
| document.getElementById('generateAIResult').textContent = 'Error: AI Goal is required.';
|
| document.getElementById('generateAIResult').classList.add('error');
|
| return;
|
| }
|
|
|
| generateButton.classList.add('loading');
|
| try {
|
| const response = await fetch(`${API_BASE_URL}/generate`, {
|
| method: 'POST',
|
| headers: { 'Content-Type': 'application/json', 'X-API-Key': apiKey },
|
| body: JSON.stringify({ goal: aiGoal, constraints: JSON.parse(aiConstraints || '{}') })
|
| });
|
| const data = await response.json();
|
| document.getElementById('generateAIResult').textContent = 'AI generated RAT config: ' + JSON.stringify(data, null, 2);
|
| document.getElementById('generateAIResult').classList.remove('error');
|
| document.getElementById('generateAIResult').classList.add('success');
|
| } catch (error) {
|
| console.error('Error:', error);
|
| document.getElementById('generateAIResult').textContent = 'Error generating RAT config with AI: ' + error;
|
| document.getElementById('generateAIResult').classList.add('error');
|
| document.getElementById('generateAIResult').classList.remove('success');
|
| } finally {
|
| generateButton.classList.remove('loading');
|
| }
|
| }
|
|
|
| async function listRatServers() {
|
| const listButton = document.querySelector('#ratServerListContainer').previousElementSibling;
|
| listButton.classList.add('loading');
|
| try {
|
| const response = await fetch(`${API_BASE_URL}/servers`, {
|
| headers: { 'X-API-Key': apiKey }
|
| });
|
| const data = await response.json();
|
| if (response.ok) {
|
| let tableHTML = '<table><thead><tr><th>ID</th><th>Server IP</th><th>Server Port</th><th>Encryption Method</th><th>Deployment Method</th><th>Actions</th></tr></thead><tbody>';
|
| data.forEach(server => {
|
| tableHTML += `<tr><td>${server.id}</td><td>${server.server_ip}</td><td>${server.server_port}</td><td>${server.encryption_method || ''}</td><td>${server.deployment_method || ''}</td><td><button onclick="deployRatServer(${server.id})">Deploy</button><div id="deploymentFeedbackServer${server.id}" class="deployment-feedback"></div></td></tr>`;
|
| });
|
| tableHTML += '</tbody></table>';
|
| document.getElementById('ratServerListContainer').innerHTML = tableHTML;
|
| document.getElementById('ratServerListContainer').classList.remove('error');
|
| } else {
|
| document.getElementById('ratServerListContainer').textContent = 'Error listing RAT servers: ' + JSON.stringify(data, null, 2);
|
| document.getElementById('ratServerListContainer').classList.add('error');
|
| }
|
| } catch (error) {
|
| console.error('Error:', error);
|
| document.getElementById('ratServerListContainer').textContent = 'Error listing RAT servers: ' + error;
|
| document.getElementById('ratServerListContainer').classList.add('error');
|
| } finally {
|
| listButton.classList.remove('loading');
|
| }
|
| }
|
|
|
| async function listRatClients() {
|
| const listButton = document.querySelector('#ratClientListContainer').previousElementSibling;
|
| listButton.classList.add('loading');
|
| try {
|
| const response = await fetch(`${API_BASE_URL}/clients`, {
|
| headers: { 'X-API-Key': apiKey }
|
| });
|
| const data = await response.json();
|
| if (response.ok) {
|
| let tableHTML = '<table><thead><tr><th>ID</th><th>Config</th><th>Deployment Method</th><th>Actions</th></tr></thead><tbody>';
|
| data.forEach(client => {
|
| tableHTML += `<tr><td>${client.id}</td><td>${JSON.stringify(client.config)}</td><td>${client.deployment_method || ''}</td><td><button onclick="deployRatClient(${client.id})">Deploy</button><div id="deploymentFeedbackClient${client.id}" class="deployment-feedback"></div></td></tr>`;
|
| });
|
| tableHTML += '</tbody></table>';
|
| document.getElementById('ratClientListContainer').innerHTML = tableHTML;
|
| document.getElementById('ratClientListContainer').classList.remove('error');
|
| } else {
|
| document.getElementById('ratClientListContainer').textContent = '
|
| document.getElementById('ratClientListContainer').classList.add('error');
|
| }
|
| } catch (error) {
|
| console.error('Error:', error);
|
| document.getElementById('ratClientListContainer').textContent = 'Error listing RAT clients: ' + error;
|
| document.getElementById('ratClientListContainer').classList.add('error');
|
| } finally {
|
| listButton.classList.remove('loading');
|
| }
|
| }
|
|
|
| async function deployRatServer(serverId) {
|
| const feedbackDiv = document.getElementById(`deploymentFeedbackServer${serverId}`);
|
| feedbackDiv.textContent = 'Deployment pending...';
|
| feedbackDiv.classList.add('pending');
|
|
|
| try {
|
| const response = await fetch(`${API_BASE_URL}/servers/${serverId}/deploy`, {
|
| method: 'POST',
|
| headers: { 'X-API-Key': apiKey }
|
| });
|
|
|
| if (!response.ok) {
|
| const errorData = await response.json();
|
| feedbackDiv.textContent = `Deployment failed: ${errorData.message || 'Unknown error'}`;
|
| feedbackDiv.classList.remove('pending');
|
| feedbackDiv.classList.add('error');
|
| return;
|
| }
|
|
|
| feedbackDiv.textContent = 'Deployment in progress...';
|
| feedbackDiv.classList.remove('pending');
|
| feedbackDiv.classList.add('in-progress');
|
|
|
| // Start polling for deployment status
|
| startDeploymentPolling(serverId, 'server', feedbackDiv);
|
|
|
| } catch (error) {
|
| console.error('Error deploying server:', error);
|
| feedbackDiv.textContent = `Deployment failed: ${error}`;
|
| feedbackDiv.classList.remove('pending');
|
| feedbackDiv.classList.add('error');
|
| }
|
| }
|
|
|
| async function deployRatClient(clientId) {
|
| const feedbackDiv = document.getElementById(`deploymentFeedbackClient${clientId}`);
|
| feedbackDiv.textContent = 'Deployment pending...';
|
| feedbackDiv.classList.add('pending');
|
|
|
| try {
|
| const response = await fetch(`${API_BASE_URL}/clients/${clientId}/deploy`, {
|
| method: 'POST',
|
| headers: { 'X-API-Key': apiKey }
|
| });
|
|
|
| if (!response.ok) {
|
| const </script>
|
| </body>
|
| </html> |