diff --git a/Log Manager/Database Schema/shellm_sessions_answers.sql b/Log Manager/Database Schema/shellm_sessions_answers.sql
new file mode 100644
index 0000000..d69846b
--- /dev/null
+++ b/Log Manager/Database Schema/shellm_sessions_answers.sql
@@ -0,0 +1,44 @@
+-- MySQL dump 10.13 Distrib 8.0.40, for Win64 (x86_64)
+--
+-- Host: localhost Database: shellm_sessions
+-- ------------------------------------------------------
+-- Server version 8.0.40
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!50503 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `answers`
+--
+
+DROP TABLE IF EXISTS `answers`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `answers` (
+ `answer_id` int NOT NULL AUTO_INCREMENT,
+ `command_id` int DEFAULT NULL,
+ `answer` text NOT NULL,
+ PRIMARY KEY (`answer_id`),
+ KEY `command_id` (`command_id`),
+ CONSTRAINT `answers_ibfk_1` FOREIGN KEY (`command_id`) REFERENCES `commands` (`command_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2024-12-06 9:42:51
diff --git a/Log Manager/Database Schema/shellm_sessions_attacker_session.sql b/Log Manager/Database Schema/shellm_sessions_attacker_session.sql
new file mode 100644
index 0000000..b9b6746
--- /dev/null
+++ b/Log Manager/Database Schema/shellm_sessions_attacker_session.sql
@@ -0,0 +1,30 @@
+-- MySQL dump 10.13 Distrib 8.0.40, for Win64 (x86_64)
+--
+-- Host: localhost Database: shellm_sessions
+-- ------------------------------------------------------
+-- Server version 8.0.40
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!50503 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `attacker_session`
+--
+
+DROP TABLE IF EXISTS `attacker_session`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `attacker_session` (
+ `attacker_session_id` int NOT NULL AUTO_INCREMENT,
+ `src_ip` varchar(45) NOT NULL,
+ PRIMARY KEY (`attacker_session_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=224 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
diff --git a/Log Manager/Database Schema/shellm_sessions_commands.sql b/Log Manager/Database Schema/shellm_sessions_commands.sql
new file mode 100644
index 0000000..e1b698a
--- /dev/null
+++ b/Log Manager/Database Schema/shellm_sessions_commands.sql
@@ -0,0 +1,44 @@
+-- MySQL dump 10.13 Distrib 8.0.40, for Win64 (x86_64)
+--
+-- Host: localhost Database: shellm_sessions
+-- ------------------------------------------------------
+-- Server version 8.0.40
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!50503 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `commands`
+--
+
+DROP TABLE IF EXISTS `commands`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `commands` (
+ `command_id` int NOT NULL AUTO_INCREMENT,
+ `shellm_session_id` int DEFAULT NULL,
+ `command` text NOT NULL,
+ PRIMARY KEY (`command_id`),
+ KEY `shellm_session_id` (`shellm_session_id`),
+ CONSTRAINT `commands_ibfk_1` FOREIGN KEY (`shellm_session_id`) REFERENCES `shellm_session` (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=153 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2024-12-06 9:42:50
diff --git a/Log Manager/Database Schema/shellm_sessions_shellm_session.sql b/Log Manager/Database Schema/shellm_sessions_shellm_session.sql
new file mode 100644
index 0000000..c2b4ea0
--- /dev/null
+++ b/Log Manager/Database Schema/shellm_sessions_shellm_session.sql
@@ -0,0 +1,49 @@
+-- MySQL dump 10.13 Distrib 8.0.40, for Win64 (x86_64)
+--
+-- Host: localhost Database: shellm_sessions
+-- ------------------------------------------------------
+-- Server version 8.0.40
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!50503 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `shellm_session`
+--
+
+DROP TABLE IF EXISTS `shellm_session`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `shellm_session` (
+ `id` int NOT NULL AUTO_INCREMENT,
+ `ssh_session_id` int DEFAULT NULL,
+ `model` varchar(255) NOT NULL,
+ `start_time` datetime NOT NULL,
+ `end_time` datetime NOT NULL,
+ `attacker_id` int DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `ssh_session_id` (`ssh_session_id`),
+ KEY `fk_attacker` (`attacker_id`),
+ CONSTRAINT `fk_attacker` FOREIGN KEY (`attacker_id`) REFERENCES `attacker_session` (`attacker_session_id`),
+ CONSTRAINT `shellm_session_ibfk_1` FOREIGN KEY (`ssh_session_id`) REFERENCES `ssh_session` (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2024-12-06 9:42:51
diff --git a/Log Manager/Database Schema/shellm_sessions_ssh_session.sql b/Log Manager/Database Schema/shellm_sessions_ssh_session.sql
new file mode 100644
index 0000000..fb6063f
--- /dev/null
+++ b/Log Manager/Database Schema/shellm_sessions_ssh_session.sql
@@ -0,0 +1,46 @@
+-- MySQL dump 10.13 Distrib 8.0.40, for Win64 (x86_64)
+--
+-- Host: localhost Database: shellm_sessions
+-- ------------------------------------------------------
+-- Server version 8.0.40
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!50503 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `ssh_session`
+--
+
+DROP TABLE IF EXISTS `ssh_session`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `ssh_session` (
+ `id` int NOT NULL AUTO_INCREMENT,
+ `username` varchar(255) NOT NULL,
+ `time_date` datetime NOT NULL,
+ `src_ip` varchar(45) NOT NULL,
+ `dst_ip` varchar(45) NOT NULL,
+ `src_port` int DEFAULT NULL,
+ `dst_port` int DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=227 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2024-12-06 9:42:50
diff --git a/Log Manager/dashboard.html b/Log Manager/dashboard.html
new file mode 100644
index 0000000..52f04a0
--- /dev/null
+++ b/Log Manager/dashboard.html
@@ -0,0 +1,104 @@
+
+
+
+
+
+ Log Manager Dashboard
+
+
+
+ Log Manager Dashboard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID |
+ Username |
+ Time & Date |
+ Source IP |
+ Destination IP |
+ Destination Port |
+
+
+
+
+
+
+
+
+
+
+
+ ID |
+ ssh_session_id |
+ model |
+ start_time |
+ end_time |
+ attacker_id |
+
+
+
+
+
+
+
+
+
+
+
+ command_id |
+ Command |
+ answer_id |
+ Answer |
+
+
+
+
+
+
+
+
+
+
+
+ command_id |
+ shellm_session_id |
+ Command |
+
+
+
+
+
+
+
+
+
+
+
+ answer_id |
+ command_id |
+ answer |
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Log Manager/log_manager.py b/Log Manager/log_manager.py
new file mode 100644
index 0000000..b2c0eed
--- /dev/null
+++ b/Log Manager/log_manager.py
@@ -0,0 +1,112 @@
+from flask import Flask, jsonify, render_template
+from flask_cors import CORS # Import Flask-CORS
+import ssh_module
+import mysql.connector
+from datetime import datetime, timedelta
+from dotenv import load_dotenv
+import os
+
+# Load environment variables from .env file
+load_dotenv('db_credentials.env')
+
+MYSQL_USER = os.getenv('MYSQL_USER')
+MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD')
+MYSQL_HOST = os.getenv('MYSQL_HOST')
+
+def connect_to_db():
+ # Connect to the MySQL server
+ conn = mysql.connector.connect(
+ host=MYSQL_HOST,
+ user=MYSQL_USER,
+ password=MYSQL_PASSWORD,
+ database='shellm_sessions'
+ )
+ cursor = conn.cursor()
+
+ return conn, cursor
+
+app = Flask(__name__)
+
+CORS(app)
+
+# Route to fetch SSH sessions from the database
+@app.route('/ssh_sessions', methods=['GET'])
+def get_ssh_sessions():
+ conn, cursor = connect_to_db()
+ if conn is None:
+ return jsonify({"error": "Database connection failed"}), 500
+
+ try:
+ cursor.execute("SELECT * FROM ssh_session ORDER BY id DESC;")
+ sessions = cursor.fetchall() # Fetch data as a list of dictionaries
+ return jsonify(sessions)
+ except Exception as e:
+ return jsonify({"error": str(e)}), 500
+ finally:
+ cursor.close()
+ conn.close()
+
+@app.route('/shellm_sessions', methods=['GET'])
+def get_shellm_sessions():
+ conn, cursor = connect_to_db()
+ cursor.execute("SELECT * FROM shellm_session ORDER BY id DESC;")
+ sessions = cursor.fetchall()
+ cursor.close()
+ conn.close()
+
+ return jsonify(sessions)
+
+@app.route('/commands', methods=['GET'])
+def get_commands():
+ conn, cursor = connect_to_db()
+ cursor.execute("SELECT * FROM commands ORDER BY command_id DESC;")
+ commands = cursor.fetchall()
+ cursor.close()
+ conn.close()
+
+ return jsonify(commands)
+
+@app.route('/answers', methods=['GET'])
+def get_answers():
+ conn, cursor = connect_to_db()
+ cursor.execute("SELECT * FROM answers ORDER BY answer_id DESC;")
+ answers = cursor.fetchall()
+ cursor.close()
+ conn.close()
+
+ return jsonify(answers)
+
+# Route to render the dashboard
+@app.route('/', methods=['GET'])
+def dashboard():
+ return render_template('dashboard.html')
+
+@app.route('/commands_answers/', methods=['GET'])
+def get_commands_answers(shellm_session_id):
+ conn, cursor = connect_to_db()
+
+ # Fetch commands and their associated answers
+ cursor.execute("""
+ SELECT c.command_id, c.command, a.answer_id, COALESCE(a.answer, 'No answer') AS answer
+ FROM commands c
+ LEFT JOIN answers a ON c.command_id = a.command_id
+ WHERE c.shellm_session_id = %s
+ """, (shellm_session_id,))
+
+ results = cursor.fetchall()
+ conn.close()
+
+ # Return as a JSON response
+ # Return as a JSON response
+ return jsonify([
+ {
+ "command_id": row[0],
+ "command": row[1],
+ "answer_id": row[2],
+ "answer": row[3]
+ }
+ for row in results
+ ])
+
+if __name__ == "__main__":
+ app.run(debug=True)
\ No newline at end of file
diff --git a/Log Manager/script.js b/Log Manager/script.js
new file mode 100644
index 0000000..cb74775
--- /dev/null
+++ b/Log Manager/script.js
@@ -0,0 +1,388 @@
+// Function to fetch SSH session data from the Flask server
+function fetchSSH_Sessions() {
+ fetch('http://127.0.0.1:5000/ssh_sessions')
+ .then(response => response.json())
+ .then(data => {
+ displaySSHSessions(data);
+ })
+ .catch(error => {
+ console.error('Error fetching SSH sessions:', error);
+ });
+}
+
+// Function to fetch shelLM sessions data from the Flask server
+function fetchShelLM_Sessions() {
+ fetch('http://127.0.0.1:5000/shellm_sessions')
+ .then(response => response.json())
+ .then(data => {
+ displayshelLMSessions(data);
+ })
+ .catch(error => {
+ console.error('Error fetching shelLM sessions:', error);
+ });
+}
+
+// Function to fetch Commands data from the Flask server
+function fetchCommands() {
+ fetch('http://127.0.0.1:5000/commands')
+ .then(response => response.json())
+ .then(data => {
+ displayCommands(data);
+ })
+ .catch(error => {
+ console.error('Error fetching Commands:', error);
+ });
+}
+
+// Function to fetch Answers data from the Flask server
+function fetchAnswers() {
+ fetch('http://127.0.0.1:5000/answers')
+ .then(response => response.json())
+ .then(data => {
+ displayAnswers(data);
+ })
+ .catch(error => {
+ console.error('Error fetching Answers:', error);
+ });
+}
+
+// Function to display SSH sessions in the table
+function displaySSHSessions(sessions) {
+ console.log("Sessions data received:", sessions);
+
+ const table = document.getElementById("ssh-sessions-table"); // Reference to the table
+ const tableBody = document.getElementById("ssh-sessions-table-body");
+
+ if (!table || !tableBody) {
+ console.error("Table or table body with ID 'ssh-sessions-table' or 'ssh-sessions-table-body' not found.");
+ return;
+ }
+
+ // Make sure the table is visible
+ table.style.display = "table"; // Unhide the table
+
+ // Clear previous entries
+ tableBody.innerHTML = "";
+
+ // Check if 'sessions' is an array and contains valid data
+ if (Array.isArray(sessions) && sessions.length > 0) {
+ sessions.forEach((session, index) => {
+ console.log(`Processing session ${index}:`, session);
+
+ if (!Array.isArray(session) || session.length < 7) {
+ console.error("Invalid session data:", session);
+ return;
+ }
+
+ const row = document.createElement("tr");
+
+ const idCell = document.createElement("td");
+ idCell.textContent = session[0];
+
+ const usernameCell = document.createElement("td");
+ usernameCell.textContent = session[1];
+
+ const timeDateCell = document.createElement("td");
+ timeDateCell.textContent = session[2];
+
+ const srcIPCell = document.createElement("td");
+ srcIPCell.textContent = session[3];
+
+ const dstIPCell = document.createElement("td");
+ dstIPCell.textContent = session[4];
+
+ const dstPortCell = document.createElement("td");
+ dstPortCell.textContent = session[6];
+
+ row.appendChild(idCell);
+ row.appendChild(usernameCell);
+ row.appendChild(timeDateCell);
+ row.appendChild(srcIPCell);
+ row.appendChild(dstIPCell);
+ row.appendChild(dstPortCell);
+
+ tableBody.appendChild(row);
+ });
+
+ console.log("Table populated successfully.");
+ } else {
+ console.error("Invalid data structure received:", sessions);
+ }
+}
+
+
+// Function to display SSH sessions in the table
+function displayshelLMSessions(sessions) {
+ console.log("Sessions data received:", sessions);
+
+ const table = document.getElementById("shellm-sessions-table"); // Reference to the table
+ const tableBody = document.getElementById("shellm-sessions-table-body");
+
+ if (!table || !tableBody) {
+ console.error("Table or table body with ID 'shellm-sessions-table' or 'shellm-sessions-table-body' not found.");
+ return;
+ }
+
+ // Make sure the table is visible
+ table.style.display = "table"; // Unhide the table
+
+ // Clear previous entries
+ tableBody.innerHTML = "";
+
+ // Check if 'sessions' is an array and contains valid data
+ if (Array.isArray(sessions) && sessions.length > 0) {
+ sessions.forEach((session, index) => {
+ console.log(`Processing session ${index}:`, session);
+
+ if (!Array.isArray(session) || session.length < 6) {
+ console.error("Invalid session data:", session);
+ return;
+ }
+
+ const row = document.createElement("tr");
+
+ const idCell = document.createElement("td");
+ idCell.textContent = session[0];
+ idCell.style.cursor = "pointer";
+ idCell.addEventListener("click", () => fetchAndDisplayCommandsAnswers(session[0]));
+
+ const ssh_session_idCell = document.createElement("td");
+ ssh_session_idCell.textContent = session[1];
+
+ const modelCell = document.createElement("td");
+ modelCell.textContent = session[2];
+
+ const start_timeCell = document.createElement("td");
+ start_timeCell.textContent = session[3];
+
+ const end_timeCell = document.createElement("td");
+ end_timeCell.textContent = session[4];
+
+ const attacker_idCell = document.createElement("td");
+ attacker_idCell.textContent = session[5];
+
+ row.appendChild(idCell);
+ row.appendChild(ssh_session_idCell);
+ row.appendChild(modelCell);
+ row.appendChild(start_timeCell);
+ row.appendChild(end_timeCell);
+ row.appendChild(attacker_idCell);
+
+ tableBody.appendChild(row);
+ });
+
+ console.log("Table populated successfully.");
+ } else {
+ console.error("Invalid data structure received:", sessions);
+ }
+}
+
+// Function to display SSH sessions in the table
+function displayCommands(sessions) {
+ console.log("Commands data received:", sessions);
+
+ const table = document.getElementById("commands-table"); // Reference to the table
+ const tableBody = document.getElementById("commands-table-body");
+
+ if (!table || !tableBody) {
+ console.error("Table or table body with ID 'commands-table' or 'commands-table-body' not found.");
+ return;
+ }
+
+ // Make sure the table is visible
+ table.style.display = "table"; // Unhide the table
+
+ // Clear previous entries
+ tableBody.innerHTML = "";
+
+ // Check if 'sessions' is an array and contains valid data
+ if (Array.isArray(sessions) && sessions.length > 0) {
+ sessions.forEach((session, index) => {
+ console.log(`Processing command ${index}:`, session);
+
+ if (!Array.isArray(session) || session.length < 3) {
+ console.error("Invalid commands data:", session);
+ return;
+ }
+
+ const row = document.createElement("tr");
+
+ const idCell = document.createElement("td");
+ idCell.textContent = session[0];
+
+ const shellm_session_idCell = document.createElement("td");
+ shellm_session_idCell.textContent = session[1];
+
+ const commandCell = document.createElement("td");
+ commandCell.textContent = session[2];
+
+ row.appendChild(idCell);
+ row.appendChild(shellm_session_idCell);
+ row.appendChild(commandCell);
+
+ tableBody.appendChild(row);
+ });
+
+ console.log("Table populated successfully.");
+ } else {
+ console.error("Invalid data structure received:", sessions);
+ }
+}
+
+// Function to display SSH sessions in the table
+function displayAnswers(sessions) {
+ console.log("Answers data received:", sessions);
+
+ const table = document.getElementById("answers-table"); // Reference to the table
+ const tableBody = document.getElementById("answers-table-body");
+
+ if (!table || !tableBody) {
+ console.error("Table or table body with ID 'answers-table' or 'answers-table-body' not found.");
+ return;
+ }
+
+ // Make sure the table is visible
+ table.style.display = "table"; // Unhide the table
+
+ // Clear previous entries
+ tableBody.innerHTML = "";
+
+ // Check if 'sessions' is an array and contains valid data
+ if (Array.isArray(sessions) && sessions.length > 0) {
+ sessions.forEach((session, index) => {
+ console.log(`Processing answer ${index}:`, session);
+
+ if (!Array.isArray(session) || session.length < 3) {
+ console.error("Invalid answer data:", session);
+ return;
+ }
+
+ const row = document.createElement("tr");
+
+ const idCell = document.createElement("td");
+ idCell.textContent = session[0];
+
+ const command_idCell = document.createElement("td");
+ command_idCell.textContent = session[1];
+
+ const answerCell = document.createElement("td");
+ answerCell.textContent = session[2];
+
+ row.appendChild(idCell);
+ row.appendChild(command_idCell);
+ row.appendChild(answerCell);
+
+ tableBody.appendChild(row);
+ });
+
+ console.log("Table populated successfully.");
+ } else {
+ console.error("Invalid data structure received:", sessions);
+ }
+}
+
+// Function to fetch and display commands and answers for a shellm session
+function fetchAndDisplayCommandsAnswers(shellmSessionID) {
+ console.log("Fetching commands and answers for ShellM Session ID:", shellmSessionID);
+
+ fetch(`http://127.0.0.1:5000/commands_answers/${shellmSessionID}`)
+ .then((response) => {
+ if (!response.ok) {
+ throw new Error(`HTTP error! status: ${response.status}`);
+ }
+ return response.json();
+ })
+ .then((data) => {
+ const tableBody = document.getElementById("commands-answers-table-body");
+ const commandsAnswersTable = document.getElementById("commands-answers-table");
+
+ if (!tableBody || !commandsAnswersTable) {
+ console.error("Commands and Answers table elements not found in the DOM.");
+ return;
+ }
+
+ // Clear previous entries
+ tableBody.innerHTML = "";
+
+ // Show the table
+ commandsAnswersTable.style.display = "table";
+
+ // Populate the table with the received data
+ if (Array.isArray(data) && data.length > 0) {
+ data.forEach((entry) => {
+ const row = document.createElement("tr");
+
+ // Create and populate cells
+ const commandIDCell = document.createElement("td");
+ commandIDCell.textContent = entry.command_id || "N/A";
+
+ const commandCell = document.createElement("td");
+ commandCell.textContent = entry.command || "N/A";
+
+ const answerIDCell = document.createElement("td");
+ answerIDCell.textContent = entry.answer_id || "N/A";
+
+ const answerCell = document.createElement("td");
+ answerCell.textContent = entry.answer || "N/A";
+
+ // Append cells to the row
+ row.appendChild(commandIDCell);
+ row.appendChild(commandCell);
+ row.appendChild(answerIDCell);
+ row.appendChild(answerCell);
+
+ // Append the row to the table body
+ tableBody.appendChild(row);
+ });
+ } else {
+ // If no data is found, show a "No data available" message
+ const row = document.createElement("tr");
+ const noDataCell = document.createElement("td");
+ noDataCell.textContent = "No commands or answers found for this session.";
+ noDataCell.colSpan = 4;
+ row.appendChild(noDataCell);
+ tableBody.appendChild(row);
+ }
+ })
+ .catch((error) => console.error("Error fetching commands and answers:", error));
+}
+
+// Function to hide all tables
+function hideAllTables() {
+ const tables = document.querySelectorAll('table');
+ tables.forEach(table => table.style.display = 'none');
+}
+
+// Add event listeners to the buttons
+document.getElementById('sshSessionsBtn').addEventListener('click', () => {
+ hideAllTables();
+ fetchSSH_Sessions();
+});
+document.getElementById('shelLM_SessionsBtn').addEventListener('click', () => {
+ hideAllTables();
+ fetchShelLM_Sessions();
+});
+document.getElementById('commandsBtn').addEventListener('click', () => {
+ hideAllTables();
+ fetchCommands();
+});
+document.getElementById('answersBtn').addEventListener('click', () => {
+ hideAllTables();
+ fetchAnswers();
+});
+
+// Function to handle ID click
+function handleIDClick(shellmSessionID) {
+ console.log("ShellM Session ID clicked:", shellmSessionID);
+
+ const commandsAnswersSection = document.getElementById("commands-answers-section");
+ commandsAnswersSection.style.display = "block"; // Show the new button
+
+ const commandsAnswersBtn = document.getElementById("commandsAnswersBtn");
+ commandsAnswersBtn.onclick = () => fetchAndDisplayCommandsAnswers(shellmSessionID); // Attach handler
+}
+
+// Ensure the page is ready for actions
+document.addEventListener("DOMContentLoaded", () => {
+ console.log("Log Manager Dashboard ready.");
+});
diff --git a/Log Manager/style.css b/Log Manager/style.css
new file mode 100644
index 0000000..0ce352e
--- /dev/null
+++ b/Log Manager/style.css
@@ -0,0 +1,93 @@
+body {
+ font-family: Arial, sans-serif;
+ margin: 0;
+ padding: 0;
+ background-color: #f9f9f9;
+ color: #333;
+}
+
+h1 {
+ text-align: center;
+ padding: 20px;
+ background-color: #4CAF50;
+ color: white;
+ margin: 0;
+}
+
+.container {
+ max-width: 1200px;
+ margin: 20px auto;
+ padding: 20px;
+ background: white;
+ border-radius: 8px;
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
+}
+
+.button-container {
+ display: flex;
+ justify-content: center;
+ margin-bottom: 20px;
+}
+
+.button-container button {
+ background-color: #4CAF50;
+ color: white;
+ border: none;
+ padding: 10px 20px;
+ margin: 0 10px;
+ border-radius: 5px;
+ font-size: 16px;
+ cursor: pointer;
+ transition: background-color 0.3s ease;
+}
+
+.button-container button:hover {
+ background-color: #45a049;
+}
+
+table {
+ border-collapse: collapse;
+ width: 100%;
+ margin-top: 20px;
+}
+
+th, td {
+ border: 1px solid #ddd;
+ padding: 12px;
+ text-align: left;
+}
+
+th {
+ background-color: #4CAF50;
+ color: white;
+}
+
+tr:nth-child(even) {
+ background-color: #f2f2f2;
+}
+
+tr:hover {
+ background-color: #ddd;
+}
+
+#commands-answers-table {
+ display: none;
+}
+
+.table-header {
+ margin-top: 30px;
+ text-align: center;
+ font-size: 18px;
+ color: #555;
+}
+
+footer {
+ text-align: center;
+ margin-top: 40px;
+ padding: 10px 0;
+ background-color: #4CAF50;
+ color: white;
+ position: relative;
+ bottom: 0;
+ width: 100%;
+}