jlasti / secmon

Lightweight SIEM based on SEC and Yii2
GNU General Public License v2.0
3 stars 11 forks source link

SecMon User Guide

How to Install

Prerequisite for installing SecMon system is OS CentOS7/CentOS Stream 8/Rocky Linux 9/Ubuntu 22.04 (tested Linux distribution) with user secmon (under which we will deploy SecMon system), internet access and installed programs Docker Engine and Docker Compose v2.3.3.

The functionality of the Docker Engine can be verified with the command docker run hello-world. Docker Compose functionality can be verified with docker compose version. If the commands do not run correctly, this problem must be resolved or the installation will not be successful.


CentOS 7

# System Update
sudo yum clean all
sudo yum -y update

# Install git, firewall & rsyslog
sudo yum install -y git firewalld rsyslog

# Install python packages
sudo yum install -y https://repo.ius.io/ius-release-el7.rpm
sudo yum install -y python36u python36u-libs python36u-devel python36u-pip
sudo pip3.6 install -U configparser

# Setting up firewall
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --permanent --add-port=8443/tcp
sudo firewall-cmd --permanent --add-port=514/tcp
sudo firewall-cmd --reload

# Download SecMon repository
git clone https://github.com/jlasti/secmon.git secmon

# Start deployment process with configuration
cd secmon
sudo python3 secmon_manager.py deploy

# Create password for database user 'secmon' during installation

# Default login credentials user:secmon, password:password
# !!! Change password after first login !!!
https://<host_machine_IP_address>:8443/secmon/web

After successful installation configure logs forwarding on clients using rsyslog service.


CentOS 8

# System Update
sudo yum clean all
sudo yum -y update

# Install git, firewall & rsyslog
sudo yum install -y git firewalld rsyslog

# Install python packages
sudo pip3.6 install -U configparser

# Setting up firewall
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --permanent --add-port=8443/tcp
sudo firewall-cmd --permanent --add-port=514/tcp
sudo firewall-cmd --reload

# Download SecMon repository
git clone https://github.com/jlasti/secmon.git secmon

# Start deployment process with configuration
cd secmon
sudo python3 secmon_manager.py deploy

# Create password for database user 'secmon' during installation

# Default login credentials user:secmon, password:password
# !!! Change password after first login !!!
https://<host_machine_IP_address>:8443/secmon/web

After successful installation configure logs forwarding on clients using rsyslog service.


Rocky 9

# System Update
sudo yum clean all
sudo yum -y update

# Install git, firewall & rsyslog
sudo yum install -y git firewalld rsyslog

# Install python packages
sudo yum install python3-pip
sudo pip install -U configparser

# Setting up firewall
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --permanent --add-port=8443/tcp
sudo firewall-cmd --permanent --add-port=514/tcp
sudo firewall-cmd --reload

# Download SecMon repository
git clone https://github.com/jlasti/secmon.git secmon

# Start deployment process with configuration
cd secmon
sudo python3 secmon_manager.py deploy

# Create password for database user 'secmon' during installation

# Default login credentials user:secmon, password:password
# !!! Change password after first login !!!
https://<host_machine_IP_address>:8443/secmon/web

Installation of Docker on Rocky Linux 9: installation help.

After successful installation configure logs forwarding on clients using rsyslog service.


Ubuntu 22.04

# System Update
sudo apt clean all
sudo apt -y update

# Install git, firewall & rsyslog
sudo apt install -y git ufw rsyslog

# Install python packages
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev \
libgdbm-dev libnss3-dev libedit-dev libc6-dev
wget https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz
sudo tar -xzf Python-3.6.15.tgz
cd Python-3.6.15
sudo ./configure --enable-optimizations  -with-lto  --with-pydebug
sudo make altinstall

# Setting up firewall
sudo ufw allow 8080/tcp
sudo ufw allow 8443/tcp
sudo ufw allow 514/tcp

# Download SecMon repository
git clone https://github.com/jlasti/secmon.git secmon

# Start deployment process with configuration
cd secmon
sudo python3 secmon_manager.py deploy

# Create password for database user 'secmon' during installation

# Default login credentials user:secmon, password:password
# !!! Change password after first login !!!
https://<host_machine_IP_address>:8443/secmon/web

After successful installation configure logs forwarding on clients using rsyslog service.


How to Use

SecMon Manager

SecMon manager (secmon_manager.py) is a python script located in root directory of SecMon repository. It is used for managing SecMon services as docker containers.

# Show list of all available parameters
python3 secmon_manager.py help

# Stop running SecMon system
python3 secmon_manager.py stop

# Start stopped SecMon system
python3 secmon_manager.py start

# Restart running/stopped SecMon system
python3 secmon_manager.py restart

# Remove SecMon enrichment containers
python3 secmon_manager.py remove

# Manually run configuration script
python3 secmon_manager.py config

# Deploy SecMon system on a host machine
python3 secmon_manager.py deploy

# Update standard rules set
python3 secmon_manager.py update-rules

Configuration

Turn on/off enrichment module

Set value true /false in the file ./config/secmon_config.ini for a particular enrichment module which you want to turn on/off:

[ENRICHMENT]
correlation = true
geoip = true
network_model = true

After any changes in configuration or rule states, restart the SecMon system with the command:

python3 secmon_manager.py restart

How to configure clients for logs forwarding

To redirect logs from client machine to the SecMon add the following line at the end of the /etc/rsyslog.conf file, where <secmon_machine_IP_address> is the IP address of the remote server (SecMon), you will be writing your logs to:

*.* @@<secmon_machine_IP_address>:514

Save your changes and restart the rsyslog service on the client with the command:

sudo systemctl restart rsyslog

Development

SecMon UI is written in php Yii2 framework. More information about this framework can be found here or here ;)

Directory structure

SecMon root directory contains a few important directories:

Docker commands

Run command inside container:

Run bash inside container:

Run composer update/install:

Database migrations: official guide

Run migration:

Refreshing migration:

Create new migration:

Run psql:

System Update

Local changes:

Remote changes:

Debug

SecMon logs are located in file /var/log/docker/secmon.log