Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 85 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,86 @@
# -LSSE-Linux-System-Security-Enhancer
(LSSE) Linux System Security Enhancer

- [installation](#installation)
- [Usage](#usage)
- [Description](#Description)
- [Key Features](#key-features)
- [How the Tool Operates](#how-the-tool-operates)
- [Results and Effectiveness](#results-and-effectiveness)


# installation

**Clone th repository**
```bash
git clone [email protected]:ahlyel-amine/-LSSE-Linux-System-Security-Enhancer.git LSSE
```

**Install in the system**
after the installation in the system you can run the tool by running the command `lsse`
```bash
cd LSSE
bash install
cd ..
rm -rf LSSE
```

**For simple use**

For simple use just enter to the repository folder and run the executable located on `./bin/lsse`


# Usage

after updating the config file located on `$(HOME)/.lsse/lsse.conf` you can run the command `lsse`

```bash
lsse
```

if you're using the executable or you want to move the config file to other location you can pass the config file to the command:

```bash
lsse -c /path/to/conf/file/lsse.conf
```
or
```bash
./path/to/repository/bin/lsse -c /path/to/conf/file/lsse.conf
```

for help you can run the command and discover the command options :

```bash
lsse -h
```


# Description

`LSSE` is a tool in C that enhances the security of a Linux system by monitoring for suspicious activities and potential intrusions.

The `LSSE` tool addresses the issue of intrusion detection by monitoring system logs and network activity for patterns that indicate potential security breaches. It provides real-time alerts and logs detailed information about suspicious activities.

---
#### **Key Features:**

- Real-time Monitoring: Continuously monitors system logs and network traffic for predefined suspicious patterns.
- Intrusion Detection: Utilizes a set of rules to detect common intrusion attempts, such as unauthorized access, unusual user activities, and malware signatures.
- Alert System: Sends real-time alerts via email and logs details about detected intrusions.
- Network Traffic Analysis: Analyzes incoming and outgoing network packets to identify potential threats.
- Report Generation: Generates detailed reports of security incidents for further analysis.


#### **How the Tool Operates:**
- Initialization: On startup, LSSE reads configuration files to load the rules and thresholds for detecting suspicious activities.
- Log Monitoring: Continuously monitors system logs (e.g., /var/log/auth.log, /var/log/syslog) for suspicious entries.
- Network Traffic Analysis: Captures network packets using a packet sniffing library and analyzes them for known malicious patterns.
- Detection: When a suspicious activity or pattern is detected, LSSE logs the event and triggers an alert.
- Alert System: Sends an email alert to the system administrator with details of the detected threat and logs the event in a specified log file.
- Report Generation: Periodically generates comprehensive reports of all detected intrusions and suspicious activities for review.


#### **Results and Effectiveness:**
- Deployment: Deployed LSSE on a test server to monitor its effectiveness in detecting real-world security threats.
- Detection Rate: Successfully identified multiple intrusion attempts during the testing phase, including unauthorized SSH access attempts and malware traffic.
- Performance: Demonstrated low resource usage, ensuring that the tool does not significantly impact system performance.
- Usability: Provided clear and actionable alerts and reports, enabling quick response to potential threats.
6 changes: 5 additions & 1 deletion config/lsse.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ syslog=/var/log/syslog
[network]

interface=eth0
ip=
mask=

[alerts]

ip=192
mask=255

Expand All @@ -32,4 +37,3 @@ mask=255
# example: ssh = alert_to_authorities
# example: ssh = disable_to_authorities
# example: ssh = delete_to_authorities

13 changes: 13 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [ ! -f ./bin/lsse ]; then
# if [ ! -f /usr/include/sys/inotify.h ]; then
# echo "inotify library is not installed"
# echo "installing inotify-tools"
# sudo apt-get install inotify-tools
# fi
make
fi
cp ./bin/lsse /usr/local/bin
mkdir -p $HOME/.lsse
cp ./config/lsse.conf $HOME/.lsse/
15 changes: 14 additions & 1 deletion src/config/load_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,26 @@ int load_config(const char *filepath) {
continue;
}
if (line[0] == '[') {
printf("Line: %s\n", line);
char *section = strtok(line, "[]");
if (strcmp(section, "network") == 0) {
load_network_config(file);
if (line[0] == '[')
section = strtok(line, "[]");
}
if (strcmp(section, "log_files") == 0) {
load_log_config(file);
if (line[0] == '[')
section = strtok(line, "[]");
}
if (strcmp(section, "rules") == 0) {
load_detection_config(file);
if (line[0] == '[')
section = strtok(line, "[]");
}
if (strcmp(section, "alerts") == 0) {
load_report_config(file);
if (line[0] == '[')
section = strtok(line, "[]");
if (strcmp(section, "log") == 0) {
load_log_config(file);
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/load_detection_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ void load_detection_config(FILE *file)
;
}
}
}
}
10 changes: 10 additions & 0 deletions src/config/load_log_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ void load_log_config(FILE *file)
}
key = strtok(line, "="); // get key
value = strtok(NULL, "\n"); // get value
if (key && value)
{
max_log_count++;
if (strcmp(key, "auth_log") != 0 && strcmp(key, "syslog") != 0) // check if key is valid
{
fprintf(stderr, "Invalid key in log configuration: %s expected auth_log, syslog\n", key);
exit (EXIT_FAILURE);
}
strncpy(config_entries.log[max_log_count].alias, key, MAX_CONFIG_KEY_LENGTH);
strncpy(config_entries.log[max_log_count].file, value, MAX_CONFIG_KEY_LENGTH);
max_log_count++;
if (key && value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/config/load_report_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ void load_report_config(FILE *file)
;
}
}
}
}
8 changes: 8 additions & 0 deletions src/init/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

void initialize(int ac, char **av)
{
bool custom_config = false;
for (int i = 1; i < ac; i++) {
if (strcmp(av[i], "-h") == 0) {
printf("Usage: %s [-h] [-v] [-c file]\n", av[0]);
Expand All @@ -14,6 +15,7 @@ void initialize(int ac, char **av)
exit(EXIT_SUCCESS);
}
if (strcmp(av[i], "-c") == 0) {
custom_config = true;
if (ac < i + 1) {
fprintf(stderr, "Missing argument for -c\n");
exit(EXIT_FAILURE);
Expand All @@ -24,6 +26,12 @@ void initialize(int ac, char **av)
}
}
}
if (!custom_config) {
if (load_config("~/.lsse/lsse.conf") != 0) {
fprintf(stderr, "Failed to load configuration.\n");
exit(EXIT_FAILURE);
}
}
if (ac == 1)
{
printf("Usage: %s [-h] [-v] [-c file]\n", av[0]);
Expand Down
22 changes: 20 additions & 2 deletions src/log_monitor/log_monitor.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
#include <stdio.h>
#include <stdlib.h>
#include "config.h"

#include <unistd.h>
void monitor_logs() {
// Open log files and monitor for suspicious patterns
t_log_entry *log = config_entries.log;

for (int i = 0; i < MAX_LOG_COUNT; i++) {
if (log[i].file[0] == '\0') {
break;
}
printf("Monitoring log: %s\n", log[i].file);
pid_t pid = fork();
if (pid == -1) {
perror("fork");
exit(EXIT_FAILURE);
}
if (pid == 0) {
execlp("tail", "tail", "-f", log[i].file, NULL);
perror("execlp");
exit(EXIT_FAILURE);
}
}
}

Loading