设为首页 加入收藏

TOP

针对Linux 文件完整性监控的实现(二)
2019-09-02 23:05:36 】 浏览:129
Tags:针对 Linux 文件 完整性 监控 实现

2. 1. 1配置osquery访问系统日志

修改操作系统的syslog应用程序,以允许osquery使用和查询系统日志。在centos7上,这需要修改Rsyslog配置文件。需要进行的唯一修改是在配置文件中附加几行代码。

首先,打开/etc/rsyslog. conf文件:sudo vim /etc/rsyslog. conf

添加一些配置行来告诉Rsyslog要写入哪个管道,以及要写入该管道的syslog参数。在默认情况下,管道为/var/osquery/syslog_pipe。然后,osquery从写入该管道的信息中填充其syslog表。

将以下行附加到文件:如图2-7所示。

/etc/rsyslog. conf

template(

  name="OsqueryCsvFormat"

  type="string"

  string="%timestamp:::date-rfc3339,csv%,%hostname:::csv%,%syslogseverity:::csv%,%syslogfacility-text:::csv%,%syslogtag:::csv%,%msg:::csv%\n"

)

*. * action(type="ompipe" Pipe="/var/osquery/syslog_pipe" template="OsqueryCsvFormat")

 

图2-7 添加管道配置

保存并关闭文件。要应用更改,重新启动syslog守护程序:

sudo systemctl restart rsyslog

2. 2 配置与管理osquery

 

 

 

2.2.1 修改配置文件

创建配置文件可以更容易地运行osqueryi。osqueryi可以从/etc/osquery/osquery. conf中的配置文件中读取这些选项,而不必传递大量命令行选项。当然,配置文件也可供守护进程使用。

配置文件还包含需要按计划执行的查询。但是,可以按计划运行的大多数查询都将作为所谓的packs发送。软件包packs是位于/usr/share/osquery/packs目录中的文件。

osquery没有配置文件,但是有一个示例配置文件可以复制到/etc/osquery并修改。但是,该文件没有在Ubuntu等Linux发行版上运行它所需的所有选项,因此创建自己的文件。

  1. 使用以下命令创建并打开配置文件:

sudo vim /etc/osquery/osquery. conf

使用JSON格式配置文件。将以下内容复制到配置文件中:如图2-8所示。

/etc/osquery/osquery. conf

  "options": {

    "config_plugin": "filesystem",

    "logger_plugin": "filesystem",

    "logger_path": "/var/log/osquery",

    "disable_logging": "false",

    "log_result_events": "true",

    "schedule_splay_percent": "10",

    "pidfile": "/var/osquery/osquery. pidfile",

    "events_expiry": "3600",

    "database_path": "/var/osquery/osquery. db",

    "verbose": "false",

    "worker_threads": "2",

    "enable_monitor": "true",

    "disable_events": "false",

    "disable_audit": "false",

    "audit_allow_config": "true",

    "host_identifier": "hostname",

    "enable_syslog": "true",

    "audit_allow_sockets": "true",

    "schedule_default_interval": "3600"

  },

 

图2-8 修改配置文件

配置文件的下一部分是调度部分。每个查询都由一个键或名称标识,该键或名称在文件中必须是唯一的,然后是要运行的查询以及运行查询的间隔如图以秒为单位。

  1. 添加一个每300秒查看crontab表的预定查询,将这些行添加到配置文件中:如图2-9所示。

/etc/osquery/osquery. conf

  "schedule": {

    "crontab": {

      "query": "SELECT * FROM crontab;",

      "interval": 300

    }

  },

 

图2-9 添加配置

3. 编写任意数量的查询。只需保持正确的格式。如果不这样做,该文件将无法通过验证。例如,要添加更多查询,请添加以下行:如图2-10所示。

/etc/osquery/osqu

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 2/8/8
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇linux添加软件的service start/st.. 下一篇Kali无法使用Chrome原因及解决方法

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目