Skip to content

Commit

Permalink
Adding the Log manager with DB schema to monitor connections
Browse files Browse the repository at this point in the history
When the DB is deployed and the Log Manager hosted on some server (now using Flask) all new connections are saved in the DB by ssh_module.py. The log_manager.py then fetches them and displays on the web dashboard that also needs to be hosted somewhere. Web dashboard is a simple web app that displays the tables of the connections to shelLM honeypot, as well the history of the session in the Commands_and_Answers table.
  • Loading branch information
msladic1 authored Dec 6, 2024
1 parent ccf102d commit 620d7be
Show file tree
Hide file tree
Showing 11 changed files with 1,332 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Log Manager/Database Schema/shellm_sessions_answers.sql
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions Log Manager/Database Schema/shellm_sessions_attacker_session.sql
Original file line number Diff line number Diff line change
@@ -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 */;
44 changes: 44 additions & 0 deletions Log Manager/Database Schema/shellm_sessions_commands.sql
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions Log Manager/Database Schema/shellm_sessions_shellm_session.sql
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions Log Manager/Database Schema/shellm_sessions_ssh_session.sql
Original file line number Diff line number Diff line change
@@ -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
104 changes: 104 additions & 0 deletions Log Manager/dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Log Manager Dashboard</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Log Manager Dashboard</h1>

<br>
<br>

<!-- Container for buttons -->
<div class="button-container">
<button id="sshSessionsBtn">SSH Sessions</button>
<button id="shelLM_SessionsBtn">shelLM Sessions</button>
<button id="commandsBtn">Commands</button>
<button id="answersBtn">Answers</button>
</div>

<br>

<!-- SSH Sessions Table -->
<table id="ssh-sessions-table" style="display:none;">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Time & Date</th>
<th>Source IP</th>
<th>Destination IP</th>
<th>Destination Port</th>
</tr>
</thead>
<tbody id="ssh-sessions-table-body">
<!-- Rows will be added here -->
</tbody>
</table>

<!-- shelLM Sessions Table -->
<table id="shellm-sessions-table" style="display:none;">
<thead>
<tr>
<th>ID</th>
<th>ssh_session_id</th>
<th>model</th>
<th>start_time</th>
<th>end_time</th>
<th>attacker_id</th>
</tr>
</thead>
<tbody id="shellm-sessions-table-body">
<!-- Rows will be added here -->
</tbody>
</table>

<!-- Placeholder for the commands and answers table -->
<table id="commands-answers-table" style="display: none; margin-top: 20px;">
<thead>
<tr>
<th>command_id</th>
<th>Command</th>
<th>answer_id</th>
<th>Answer</th>
</tr>
</thead>
<tbody id="commands-answers-table-body">
<!-- Rows will be added dynamically -->
</tbody>
</table>

<!-- Commands Table -->
<table id="commands-table" style="display:none;">
<thead>
<tr>
<th>command_id</th>
<th>shellm_session_id</th>
<th>Command</th>
</tr>
</thead>
<tbody id="commands-table-body">
<!-- Rows will be added here -->
</tbody>
</table>

<!-- Answers Table -->
<table id="answers-table" style="display:none;">
<thead>
<tr>
<th>answer_id</th>
<th>command_id</th>
<th>answer</th>
</tr>
</thead>
<tbody id="answers-table-body">
<!-- Rows will be added here -->
</tbody>
</table>

<script src="script.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions Log Manager/db_credentials.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MYSQL_USER=root
MYSQL_PASSWORD=RokeriSMoravu123!
MYSQL_HOST=localhost
Loading

0 comments on commit 620d7be

Please sign in to comment.