本站已运行

攻城狮论坛

作者: 合肥清默
查看: 3959|回复: 28

主题标签Tag

more +今日重磅推荐Recommend No.1

所有IT类厂商认证考试题库下载所有IT类厂商认证考试题库下载

more +随机图赏Gallery

【新盟教育】2023最新华为HCIA全套视频合集【网工基础全覆盖】---国sir公开课合集【新盟教育】2023最新华为HCIA全套视频合集【网工基础全覆盖】---国sir公开课合集
【新盟教育】网工小白必看的!2023最新版华为认证HCIA Datacom零基础全套实战课【新盟教育】网工小白必看的!2023最新版华为认证HCIA Datacom零基础全套实战课
原创_超融合自动化运维工具cvTools原创_超融合自动化运维工具cvTools
重量级~~30多套JAVA就业班全套 视频教程(请尽快下载,链接失效后不补)重量级~~30多套JAVA就业班全套 视频教程(请尽快下载,链接失效后不补)
链接已失效【超过几百G】EVE 国内和国外镜像 全有了 百度群分享链接已失效【超过几百G】EVE 国内和国外镜像 全有了 百度群分享
某linux大佬,积累多年的电子书(约300本)某linux大佬,积累多年的电子书(约300本)
乾颐堂现任明教教主Python完整版乾颐堂现任明教教主Python完整版
乾颐堂 教主技术进化论 2018-2019年 最新31-50期合集视频(各种最新技术杂谈视频)乾颐堂 教主技术进化论 2018-2019年 最新31-50期合集视频(各种最新技术杂谈视频)
Python学习视频 0起点视频 入门到项目实战篇 Python3.5.2视频教程 共847集 能学102天Python学习视频 0起点视频 入门到项目实战篇 Python3.5.2视频教程 共847集 能学102天
约21套Python视频合集 核心基础视频教程(共310G,已压缩)约21套Python视频合集 核心基础视频教程(共310G,已压缩)
最新20180811录制 IT爱好者-清风羽毛 - 网络安全IPSec VPN实验指南视频教程最新20180811录制 IT爱好者-清风羽毛 - 网络安全IPSec VPN实验指南视频教程
最新20180807录制EVE开机自启动虚拟路由器并桥接物理网卡充当思科路由器最新20180807录制EVE开机自启动虚拟路由器并桥接物理网卡充当思科路由器

[资料] ossec规则设置,以及常规问题释疑

  [复制链接]
查看: 3959|回复: 28
开通VIP 免金币+免回帖+批量下载+无广告
Syscheck是OSSEC内部完整性检测进程的名称。它周期性检查是否有任何配置文件(或者windows注册表)发生改变。
配置文件地址为
[root@logserver etc]# pwd
/var/ossec/etc
[root@logserver etc]# vim ossec.conf
它的工作方法是:“代理每几个小时扫描一次系统,并发送所有的校验和到server端。Server端存储这些校验和文件并查找他们的不同。如果发现任何改变将会发送报警。
基本概况
多长时间运行一次
默认每6小时运行一次,但是这个频率可以自己设定
数据存放位置
在server端的/var/ossec/queue/syscheck
CPU使用情况
慢慢地进行扫描,以避免使用过多的CPU /内存。
如何处理误报
文件能够通过手工指定配置文件或使用规则到忽略不记,默认一个文件修改超过3次会自动忽略。
配置选项
    下面的配置选项可以指定在每一个代理的ossec.conf文件,除了应用到manager和本地安装类型的auto_ignore 和 alert_new_file. 如果ignore选项指定在manage,所有代理都会使用相同的设置。
目录
    使用这个选项增加或者移除被监控的目录(目录这间用逗号分开)所有的文件和子目录也会被监控。没有目录的驱动器字母是无效的。至少“。”应包括(D:\.)。
默认:/etc,/sur/bin,/usr/sbin,/bin,/sbin
Attributes: 属性
realtime: Value=yes
This will enable realtime/continuous monitoring on Linux (using the inotify system calls) and Windows systems. (启用实时、连续的监控)
report_changes: Value=yes
Report diffs of file changes. This is limited to text files at this time. (文件改变比较报告,只能用文本文件)
check_all: Value=yes
All the following check_* options are used together. (所有下面的check_*选项共同起作用)
check_sum: Value=yes
Check the md5 and sha1 hashes of the of the files will be checked.
This is the same as using both check_sha1sum=”yes” and check_md5sum=”yes”
check_sha1sum: Value=yes
When used only the sha1 hash of the files will be checked.
check_md5sum: Value=yes
The md5 hash of the files will be checked.
check_size: Value=yes
The size of the files will be checked. (检查文件大小)
check_owner: Value=yes
Check the owner of the files selected. (文件所有者检查)
check_group: Value=yes
Check the group owner of the files/directories selected. (文件和目录所属的用户组检查)
check_perm: Value=yes
Check the UNIX permission of the files/directories selected. On windows this will only check the POSIX permissions. 文件和目录权限检查
restrict: Value=string
A string that will limit checks to files containing that string in the file name. (文件内容中包含文件名的字符串将限制检查。
Allowed: Any directory or file name
ignore
List of files or directories to be ignored (one entry per element).列出的文件和目录将不被检查Default: /etc/mtab
Attributes:
type: Value=sregex
This is a simple regex pattern to filter out files so alerts are not generated. 这个简单的表达式过虑掉输出文件,所以报警不会生成。
Allowed: Any directory or file name
frequency
Frequency that the syscheck is going to be executed (in seconds).(syscheck多长时间执行一次,默认是21600秒,也就是6个小时)
The default is 6 hours or 21600 seconds
Default: 21600
Allowed: Time in seconds
scan_time
Time to run the scans (can be in the formats of 21pm, 8:30, 12am, etc) 扫描系统的时间格式(21pm晚上9点),8:30,(12am上午12点)。
Allowed: Time to run scan
scan_day
Day of the week to run the scans (can be in the format of sunday, saturday, monday, etc)
在每周的那一天执行扫描
Allowed: Day of the week
auto_ignore
Specifies if syscheck will ignore files that change too often (after the third change)指定忽略频繁改变的文件
Default: no
Allowed: yes/no
alert_new_files
Specifies if syscheck should alert on new files created.指定新文件被创建时是否报警
Default: no
Allowed: yes/no
scan_on_start
Specifies if syscheck should do the first scan as soon as it is started.(syscheck启动后是否立即做第一次扫描。
Default: yes
Allowed: yes/no
windows_registry
Use this option to add Windows registry entries to be monitored (Windows-only).增加windows注册表监控
Default: HKEY_LOCAL_MACHINESoftware
Allowed: Any registry entry (one per element)
registry_ignore
List of registry entries to be ignored.(不监控列出的注册表条目)
Default: ..CryptographyRNG
Allowed: Any registry entry (one per element)
配置例子
配置 syscheck,提供一个要被监控的目录和文件列表,check_all 选项会检查文件的md5, sha1,owner,和权限。例如:
   /etc,/usr/bin,/usr/sbin
/root/users.txt,/bsd,/root/db.html
如果不想监控某些文件和目录,可以用ignore选项(或者registry_ignore 为windows注册表输入)
   /etc/random-seed
/root/dir
.log$|.tmp
??在ignore选项,这个类型属性可以设置sregex指定一个正则表达式语法。
   ^/opt/application/log
一个本地规则可以更严格的修改你想要更改的指定文件和目录。
     
   syscheck
/var/www/htdocs
在上边的例子中,当htdocs directory目录中的文件有改变时将会产生一个高严重级别的报警。
实时监控
在linux 和windows中OSSEC支持实时监控文件完整性检查(linux内核2.6.13以上板本支持)
配置很简单,在directories选项那里你可以指定要监控那些文件和目录,增加realtime=”yes”到启用。
   /etc,/usr/bin,/usr/sbin
/bin,/sbin
在这个例子中,目录/etc, /usr/bin and /usr/sbin会被实时监控,同样的方法也实用与windows.
提示:实时监控并不会立即开始。首先ossec-syscheckd需要扫描文件系统并添加每一个了目录到实时队列。要完成这些工作需要30分钟时间。(等待log文件出现如下信息:“ossec-syscheckd: INFO: Starting real time file monitoring”)
注解:实时监控仅对目录有效,所以你可以监控 /etc 或者c:\program files 目录,但不能是个别的文件,像/etc/file.txt。
比较不同并生成报告
    在linux 和unix系统比较所后的改变生成一个文本文件,OSSEC支持发送比较报告,
配置syscheck显示文件比较的不同很简单,添加report_changes=”yse”到directories选项。
/etc
/bin,/sbin
二、F&Q
Question 1.当按照上一篇安装之后web端后访问出现:
Unable to retrieve alerts.
请查看/var/ossec/logs/alerts/alerts.log 权限是否有web服务器能访问的权限
Question 2
我smtp server设置正确,但为何我收不到ossec主机所发的邮件,在邮件日志中老显示连接超时。
A: ossec原则上不要求在本地架设mta服务器,但我们知道,为了防止垃圾,基本上所有邮件服务器都关闭了open relay,然我们的ossec并没有为smtp认证提供username与password设置选项,这就使我们在选择其它smtp 服务器时无法指定用户名与密码,因此我的做法是设置ossec发信给root@localhost,然后在本地邮件服务器别名列表中,将所有转发给 root的信件再转发给我所希望的email地址。
Question 3
如何设置ossec同时去监检多个日志文件
A:有时,我们同时有多个日志文件希望被监测,但又不想一个个输入ossec.conf配置文中。其实我可以利用ossec的posix规则表达示来达到你的目的。如假如你有如下几个日志文件:
/var/log/host1/xx.log,yy.log,zz.log
/var/log/host2/xx.log,aa.log
/var/log/host3/zz.log,abc.log
/var/log/hostn/bb.log,xyz.log
我们可以这样设置
   syslog
   /var/log/host*/*.log
   
Question 4
我采用的是S/C安装方式,并且巳按正确方法在服务器上注册的客户机,但ossec服务器与客户无法还是无法通信
A:针对这个问题,a.首先我们要确定安装顺序是否正确,一般我们是先安装server,然后是agent,并且在服务器给agent生成密匙,再在agent上导入密匙,注意在server上生成密匙时agent的ip地址千万不能写错,否则无法通信。
       b.使用netstat -ntlup查看本机是否开启了514,1514端口接受agent连接,如果端口还没有打开,先/etc/init.d/syslog restart再查看。请随时查阅/var/ossec/logs/ossec.conf日志文件中的是志。
       c.如果你启了防火墙,请一定要将514,1514的数据放行,否则agent无法与server正常通信。
以上是我们个人使用ossec来一点实际经验,欢迎大家继续加精
Question 5
如何检测apache日志
我们可以这样设置
   apache
   你的apache日志目录
   
Question 6 代理和服务器见的连接不畅通,怎么办
日志出现
2012/10/16 16:40:56 ossec-agentd(1218): ERROR: Unable to send message to server.
2012/10/16 16:41:08 ossec-agentd(1218): ERROR: Unable to send message to server.
请查看agent 和server是否有防火墙,以及是否方形了1514 和514端口
以及查看服务器端是否开启了1514端口

Question 6 启动了ossec 没有监听1514
查看ossec-remoted是否启动,查看日志能否看到ossec-remoted相关信息.
可能需要开启debug模式

    ./ossec-control enable debug
  • ./ossec-control restart  

看日志

    [root@logserver logs]# tail -f ossec.log |grep remo 2012/10/18 16:36:15 ossec-remoted: DEBUG: Starting ... 2012/10/18 16:36:15 ossec-remoted: INFO: Started (pid: 9246). 2012/10/18 16:36:15 ossec-remoted: DEBUG: Forking remoted: '0'. 2012/10/18 16:36:15 ossec-remoted: Remote syslog allowed from: '10.10.10.0/24' 2012/10/18 16:36:15 ossec-remoted: Remote syslog allowed from: '10.10.10.0/24' 2012/10/18 16:36:15 ossec-remoted: DEBUG: Forking remoted: '1'.
  • 2012/10/18 16:36:15 ossec-remoted(1206): ERROR: Unable to Bind port '514'

很明显是因为514端口被rsyslog 占用,所以需要修改端口.
查看ossec.conf是不是添加了一下内容

    <</span>remote>    <</span>connection>secure</</span>connection>    <</span>allowed-ips>10.10.10.0/24</</span>allowed-ips>    <</span>port>1514</</span>port>    <</span>local_ip>10.10.10.137</</span>local_ip>
  • </</span>remote>
Question 7如果还是启动不来,查看ossec.log
有如下日志

    2012/10/17 13:51:11 ossec-remoted: INFO: Started (pid: 4477). 2012/10/17 13:51:11 ossec-remoted: Remote syslog allowed from: '10.10.10.0/24'
  • 2012/10/17 13:51:11 ossec-remoted(1206): ERROR: Unable to Bind port '514'
因为514被rsyslog占用,先停掉rsyslog再启动ossec-control restart
Question 7
agent的消息不能发送到server
1.检查$OSSEC_HOME/queue/agent-info/下面是否有文件
2.检查ossec的服务器日志cat /$OSSEC_HOME/logg/ossec.log | grep remote

    [root@logserver etc]# cat /var/ossec/logs/ossec.log |grep remote 2012/10/17 14:46:21 ossec-remoted: INFO: Started (pid: 7850). 2012/10/17 14:46:21 ossec-remoted(1501): ERROR: No IP or network allowed in the access list for syslog. No reason for running it. Exiting. 2012/10/17 14:46:21 ossec-remoted: INFO: Started (pid: 7853). 2012/10/17 14:46:22 ossec-remoted(4111): INFO: Maximum number of agents allowed: '256'. 2012/10/17 14:46:22 ossec-remoted(1410): INFO: Reading authentication keys \
  • file.  
CCNA考试 官方正规报名 仅需1500元
回复 论坛版权

使用道具 举报

cool-co [Lv8 技术精悍] 发表于 2013-10-10 14:03:47 | 显示全部楼层
掌声鼓励!:lol
回复 支持 反对

使用道具 举报

w10 [Lv8 技术精悍] 发表于 2013-10-11 09:14:28 | 显示全部楼层
回复 支持 反对

使用道具 举报

伊達政宗 [Lv8 技术精悍] 发表于 2013-10-11 13:53:59 | 显示全部楼层
帮帮顶顶!!
回复 支持 反对

使用道具 举报

microfish [Lv8 技术精悍] 发表于 2013-10-17 16:14:40 | 显示全部楼层
路过,学习下,感谢攻城狮论坛
回复 支持 反对

使用道具 举报

cxvzwa [Lv8 技术精悍] 发表于 2013-12-3 15:19:29 | 显示全部楼层
相当不错,感谢无私分享精神!
回复 支持 反对

使用道具 举报

skyii [Lv8 技术精悍] 发表于 2013-12-4 21:42:56 | 显示全部楼层
路过,学习下,感谢攻城狮论坛
回复 支持 反对

使用道具 举报

bestshot [Lv8 技术精悍] 发表于 2013-12-7 09:42:20 | 显示全部楼层
有道理。。。感谢攻城狮论坛
回复 支持 反对

使用道具 举报

违法者 [Lv8 技术精悍] 发表于 2013-12-7 16:31:36 | 显示全部楼层
帮你顶下哈!!
回复 支持 反对

使用道具 举报

我啊 [VIP@钻石] 发表于 2014-9-6 10:19:30 | 显示全部楼层
我是来刷分的,嘿嘿
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|无图浏览|手机版|网站地图|攻城狮论坛

GMT+8, 2026-5-3 05:41 , Processed in 0.132329 second(s), 16 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4 © 2001-2013 Comsenz Inc.

Designed by ARTERY.cn