Suricata +Scirius

一.安装Suricata(通过 Debian 官方仓库)
1.更新系统包索引 
  sudo apt update
2.安装 Suricata
  sudo apt install suricata -y

3.验证安装:执行 suricata -V,若显示版本信息则安装成功。

4.启动 Suricata 并设置开机自启:

  sudo systemctl start suricata
  sudo systemctl enable suricata

二 安装 Scirius

 1.安装依赖包

  sudo apt install python3-pip python3-venv postgresql nginx -y

 2.配置 PostgreSQL 数据库

  启动数据库并创建专用用户 / 数据库:

  sudo systemctl start postgresql
  sudo -u postgres psql  # 进入PostgreSQL命令行
  postgres=# CREATE DATABASE scirius;  # 创建数据库
  postgres=# CREATE USER scirius WITH PASSWORD 'your_password';  # 设置密码

  postgres=# GRANT ALL PRIVILEGES ON DATABASE scirius TO scirius ;  # 授权

  postgres=# GRANT ALL PRIVILEGES ON SCHEMA public TO scirius;  # 授予对 public 模式的权限
  postgres=# ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO scirius; # 授予对未来创建表的权限   或 ALTER DATABASE your_database_name OWNER TO your_user;
  postgres=# \q  # 退出

 3.获取 Scirius 代码

   git clone https://github.com/StamusNetworks/scirius.git
   cd scirius

 

 4.安装 Python 依赖

 

  python3 -m venv scirius-env
  source scirius-env/bin/activate
  pip install --upgrade pip
  pip install -r requirements.txt
  pip install pyinotify
  pip install gitdb

 5.编辑配置文件,设置数据库连接:

  vim  scirius/settings.py
  添加以下内容:

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql',
            'NAME': 'scirius',
            'USER': 'scirius',
            'PASSWORD': 'your_password',
            'HOST': 'localhost',
            'PORT': '5432',
        }
    }

  6.初始化数据库

    ./manage.py migrate
    ./manage.py collectstatic --noinput
    ./manage.py createsuperuser  # 创建管理员账户

    注:出现错误信息 FileNotFoundError: [Errno 2] No such file or directory: '/var/log/scirius/elasticsearch.log' 这表明系统在指定路径下找不到该日志文件

      解决方式:在对应的目录下创建对应的路径与文件

      错误信息:RuntimeError: Incompatible `csp` decorator arguments. This decorator now takes a single dict argument. See the django-csp 4.0 migration guide for more information.这个错误是由于 django-csp 库在 4.0 版本中对 csp 装饰器的使用方式进行了重大更改导致的。旧版本中允许的参数格式在新版本中不再支持,现在要求该装饰器只能接受一个字典类型的参数。

      解决方式:项目中搜索 @csp,找出问题处进行修改,此处的我问题文件为 scirius/views.py 107行

      原语句  @csp({DEFAULT_SRC:=["'self'"], SCRIPT_SRC:=[], STYLE_SRC:=["'self'", "'unsafe-inline'"], IMG_SRC:=["'self'", "data:", '*']})

      改后: @csp({'DEFAULT_SRC':["'self'"], 'SCRIPT_SRC':[], 'STYLE_SRC':["'self'", "'unsafe-inline'"], 'IMG_SRC':["'self'", "data:", '*']})

 7.配置系统服务

    创建 systemd 服务文件:

      sudo vim /etc/systemd/system/scirius.service

    添加以下内容:

      [Unit]
      Description=Scirius service
      After=network.target postgresql.service

      [Service]
      User=your_username
      Group=your_group
      WorkingDirectory=/path/to/scirius
      ExecStart=/path/to/scirius_venv/bin/gunicorn scirius.wsgi:application --bind 127.0.0.1:8000
      Restart=on-failure

      [Install]
      WantedBy=multi-user.target

  8.启动服务:

    sudo systemctl daemon-reload
    sudo systemctl start scirius
    sudo systemctl enable scirius

  9.配置 Nginx 反向代理

    sudo vim /etc/nginx/sites-available/scirius

   添加以下内容:

    server {
        listen 80;
        server_name your_domain_or_ip;

        location /static/ {
            alias /path/to/scirius/static/;
        }

        location / {
            proxy_pass http://127.0.0.1:8000;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }
    }

  10.启用站点并重启 Nginx:

    sudo ln -s /etc/nginx/sites-available/scirius /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl restart nginx

完成以上步骤后,你可以通过浏览器访问服务器的 IP 地址或域名来使用 Scirius,使用之前创建的管理员账户登录即可。

posted @ 2025-09-03 13:49  Awakenedy  阅读(29)  评论(0)    收藏  举报