Git Product home page Git Product logo

fabian-hk / nano_siem Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 6.51 MB

A minimalist SIEM designed to analyse Traefik access logs and check service availability.

Home Page: https://hub.docker.com/r/fabianhk/nano-siem

License: GNU Affero General Public License v3.0

Python 71.20% Dockerfile 0.81% HTML 27.17% Shell 0.82%
docker log-analysis log-analytics security-tools siem traefik traefik2 availability-monitor uptime-monitor event-notifications

nano_siem's Introduction

Nano SIEM

The Nano SIEM project is a minimalist Security Information and Event Management (SIEM) system designed for private home servers.

Nano SIEM has two main functionalities: One is to monitor the uptime of services and send an email notification if a service is unavailable. The second functionality is to provide insight into the access log file of a Traefik reverse proxy. It does this by resolving IPs into coordinates and displaying them on different map views. In the screenshot below you can see an example of the detailed map. On this map, you can click on locations and see the requests that have been made from that location. The requests are ranked according to their likelihood of being a hacking attempt. There is also a second view which specifically lists hacking attempts. A screenshot of this view can also be seen below. These features help to get a better understanding of the security risks on the server.

The software is easy to set up and configure. A pre-built, ready-to-use Docker container can be pulled from Docker Hub. If you need to parse a different log file format feel free to write a new module and open a pull request. Look at the development.md document to get started.

Detailed Map View Screenshot Detailed Map

Event View Screenshot of Event View

Overwatch View Screenshot of Overwatch View

Demo

If you want to check out the implementation with example data you can go to the doc/demo/ folder. Further instructions how to run the application can be found there.

Configuration

Running the application on your own server is quite easy. You just have to follow the instruction below and / or look at the docker-compose file in this repository. You can pull the ready to use Docker image from docker pull fabianhk/nano-siem.

[Required] Django Settings

DJANGO_SECRET_KEY=<strong secret key with at least 50 characters>
DOMAIN_NAME=<domain name of the server>
URL=<full url e.g. https://www.example.com>

# If you are behind a reverse proxy, you have to set this variable
USE_X_FORWARDED_HOST=True

Only for debugging: If you want to see the logs of the cronjob you have to mount a log file to: /home/ubuntu/.nano_siem/crontab.log.

Database

MYSQL_DB_NAME=NanoSiem
MYSQL_USER=NanoSiem
MYSQL_PASSWORD=1234
MYSQL_HOST=127.0.0.1
# Run migrations from command line
docker exec -it <container name> python3 manage.py migrate

Authentication

OpenID Connect

The OpenID Connect login is tested with the Keycloak and Authentik. In the authorization server you have to create a new client with the redirect URI https://<DOMAIN_NAME>/oidc/callback/.

OIDC_CLIENT_ID=<CLIENT_ID>
OIDC_CLIENT_SECRET=<CLIENT_SECRET>

OIDC_AUTHORIZATION_ENDPOINT=
OIDC_TOKEN_ENDPOINT=
OIDC_USER_ENDPOINT=
# If OIDC_JWKS_ENDPOINT variable is set and the document can be retrieved with
# a 200 status code, the OIDC login is enabled.
OIDC_JWKS_ENDPOINT=
OIDC_END_SESSION_ENDPOINT=

In the Keycloak admin console you have to create a new confidential client (enable Client authentication) with the following configuration:

# Valid redirect URIs
https://<DOMAIN_NAME>/oidc/callback/

# Valid post logout redirect URIs
https://<DOMAIN_NAME>/oidc/authenticate/

ALTERNATIVE or FALLBACK: Default Django Authentication

If you don't use OpenID Connect for authentication you have to create a superuser account. You can do this by running the following command in the container:

docker exec -it <container name> python3 manage.py createsuperuser

Notification Settings

NOTIFICATION_EMAIL=<email address>
NOTIFICATION_EMAIL_PASSWORD=<email password>
# The SMTP server has to support STARTTLS
NOTIFICATION_EMAIL_SMTP_SERVER=<smtp server>

Traefik Module

  1. Mount Traefik access log to: /var/log/traefik_access.log
  2. Setup GeoLite2 Free database:
    1. Create an account at MAXMIND
    2. Create License file: GeoIP.conf
    3. Mount license file to: /etc/GeoIP.conf

[Optional] IP Address to Coordinate Config

# Set default values for private IP addresses (can't be resolved by GeoLite2 db)
PRIVATE_IP_LOCATION_INFO=65.01236,25.46816,Oulu,Finland,DNA 

Overwatch Module

The Overwatch module checks whether a service is available or not every minute. If a service is not available the module will send an email notification to the configured email address (Requires the notification settings to be configured). You can configure as many services as you want by increasing the numbers at the end of the environment variable. The pair of name and type has to be unique. The type can be one of the following: http, tcp, ping or disk.

# HTTP example
OVERWATCH_0=Name,http,https://example.com
OVERWATCH_{i}=Name,http,<url>

# TCP example
OVERWATCH_1=Name,tcp,example.com,22
OVERWATCH_{i}=Name,tcp,<domain/ip>,<port>

# Ping
OVERWATCH_2=Name,ping,example.com
OVERWATCH_{i}=Name,ping,<domain/ip>

# Disk
OVERWATCH_3=Name,disk,/dev/sda1,/media/usb,58d775d2-1fcb-4d10-aee5-cb956a86abd3
OVERWATCH_{i}=Name,disk,<device>,<mount point>,<uuid>

Notes on the disk availability check: You have to mount the root filesystem to /mnt/rootfs as a read-only filesystem.

All Configuration Options

You can find all configuration options in the file configuration.md.

nano_siem's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nano_siem's Issues

Find IDS Rules

Search for scientific articles on intrusion detection and which patterns indicate hacking attempts. The goal is to find a list of URL paths that indicate hacking attempts. Example: /loadImage?filename=../../../etc/passwd

Convert IPs to Coordinates

Write a Python function that takes an IP address as a string and outputs the corresponding coordinates as a tuple: (Longitude, Latitude). The tuple should have the data type (float, float). The conversion should be done locally with the GeoLite2 database. You can use the python-geoip package for this.

Update: There is a newer version of the library geoip2 that you should use. But I think therefore you have to manually download the GeoLite2 database. Don't use the web service.

Please develop this feature in the feature/geoip-lookup branch. You should complete the function in this file.

Database attributes documentation: https://dev.maxmind.com/static/pdf/GeoLite2-IP-MetaData-Databases-Comparison-Chart.pdf

Check if IP is Tor Exit Node

Write a function that takes an IP address as the input and returns true if the IP is in the list of Tor exit nodes. Since downloading this file from the internet every time would be to time and network consuming the function should download it once and save it in the user's home folder: ~/.nano_siem/tor_exit_nodes.txt.
But since the file can change you should update the file if the downloaded file is older than a day.

Please develop this function in the feature/check-tor-exit branch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.