Linux下安装ossec

来源:互联网 发布:好听的网络翻唱 编辑:程序博客网 时间:2024/05/14 23:33
安装OSSEC小结:linux_server+xp_agent

 

安装过程中报编译错误,比如"Error Making analysisd"等,此时要看清报错的位置及原因,定位问题的根源。
我的这个"Error Making analysisd"是因为analysisd文件夹里面的某个configure文件没有权限执行(permission denied)
所以提升对应文件的权限即可sudo chmod 777 ....


自己安装过程:
1. 安装ossec server
2. 解压缩tar -zxsf
3. 运行sudo sh install.sh
4. 提示判断有没有c编译器,可终端里输入gcc查看
5. 没有的话:sudo apt-get install build-essential
6. 继续安装,位置,我选了默认:/var/ossec
7. 建立快捷方式:ln -s /var/ossec /home/mean 【如果你的用户没有root权限,常规用户无法查看ossec文件夹】
8. 为了进入这个目录,需要root权限,提升:sudo passwd root,设置新密码
9. 使用su命令,输入密码即可。
10. 启动服务/var/ossec/bin/ossec-control start
11. 关闭:/var/ossec/bin/ossec-control stop
12. 要修改配置,但是需要提高权限:sudo chmod 777 /var/ossec/etc/ossec.conf
13. cat /var/ossec/etc/ossec.conf 查看内容
14. 修改内容: vi /var/ossec/etc/ossec.conf
*****************************************
vi是Unix/Linux系统最常用的编辑器之一,我习惯使用":x"命令来保存文件并退出,不愿意使用":wq"命令是因为它得多敲一个字母,但是,今天我才知道":x"和":wq"的真正区别,如下:
:wq   强制性写入文件并退出。即使文件没有被修改也强制写入,并更新文件的修改时间。
:x    写入文件并退出。仅当文件被修改时才写入,并更新文件修改时间,否则不会更新文件修改时间。
这两者一般情况下没什么不一样,但是在编程方面,对编辑源文件可能会产生重要影响。因为文件即使没有修改,":wq"强制更新文件的修改时间,这样会让make编译整个项目时以为文件被修改过了,然后就得重新编译链接生成可执行文件。这可能会产生让人误解的后果,当然也产生了不必要的系统资源花销。
补充:要插入东西,按i,返回esc,x删除当前字符。
******************************************
开始的那个stmp填的不对,改为:127.0.0.1, 邮箱添:root@localhost,why?参考下文给出的引用文章。
再次开始:ok了。
按照下文的方式安装客户端(在xp)并根据服务端创造的agent的id和key来进行连接。
截图:



如何配置要检测的日志文件还没有做,下一步进行。

引用文章:http://zhangzhenting.javaeye.com/blog/703552
一、服务端安装
1. 上传ossec-hids-2.4.1.tar.gz至/home目录
2. 安装ossec
#tar -zxvf ossec-hids-2.4.1.tar.gz#cd ossec-hids-2.4.1#./install.sh

1)选择语言类型:  ** Para instalação em português, escolha [br].  ** 要使用中文进行安装, 请选择 [cn].  ** Fur eine deutsche Installation wohlen Sie [de].  ** Για εγκατάσταση στα Ελληνικά, επιλέξτε [el].  ** For installation in English, choose [en].  ** Para instalar en Español , eliga [es].  ** Pour une installation en français, choisissez [fr]  ** Per l'installazione in Italiano, scegli [it].  ** 日本語でインストールします.選択して下さい.[jp].  ** Voor installatie in het Nederlands, kies [nl].  ** Aby instalować w języku Polskim, wybierz [pl].  ** Для инструкций по установке на русском ,введите [ru].  ** Za instalaciju na srpskom, izaberi [sr].  ** Türkçe kurulum için seçin [tr].  (en/br/cn/de/el/es/fr/it/jp/nl/pl/ru/sr/tr) [en]:en

2)按回车继续: OSSEC HIDS v2.4.1 Installation Script - http://www.ossec.net
You are about to start the installation process of the OSSEC HIDS. You must have a C compiler pre-installed in your system. If you have any questions or comments, please send an e-mail to dcid@ossec.net (or daniel.cid@gmail.com).
  - System: Linux linux 2.6.5-7.308-smp  - User: root  - Host: linux
  -- Press ENTER to continue or Ctrl-C to abort. --

3)选择安装的为服务器端:1- What kind of installation do you want (server, agent, local or help)? server
  - Server installation chosen.
2- Setting up the installation environment.
- Choose where to install the OSSEC HIDS [/var/ossec]: /var/ossec
    - Installation will be made at  /var/ossec .

4)配置OSSEC的邮件通知、response及remote syslog
3- Configuring the OSSEC HIDS.
  3.1- Do you want e-mail notification? (y/n) [y]: y   - What's your e-mail address? root@localhost
   - We found your SMTP server as: 127.0.0.1   - Do you want to use it? (y/n) [y]: y
   --- Using SMTP server:  127.0.0.1
  3.2- Do you want to run the integrity check daemon? (y/n) [y]: y
   - Running syscheck (integrity check daemon).
  3.3- Do you want to run the rootkit detection engine? (y/n) [y]: y
   - Running rootcheck (rootkit detection).
  3.4- Active response allows you to execute a specific       command based on the events received. For example,       you can block an IP address or disable access for       a specific user.       More information at:       http://www.ossec.net/en/manual.html#active-response
   - Do you want to enable active response? (y/n) [y]: y
     - Active response enabled.
   - By default, we can enable the host-deny and the     firewall-drop responses. The first one will add     a host to the /etc/hosts.deny and the second one     will block the host on iptables (if linux) or on     ipfilter (if Solaris, FreeBSD or NetBSD).   - They can be used to stop SSHD brute force scans,     portscans and some other forms of attacks. You can     also add them to block on snort events, for example.
   - Do you want to enable the firewall-drop response? (y/n) [y]: y
     - firewall-drop enabled (local) for levels >= 6
   - Default white list for the active response:      - 10.30.18.100      - 10.30.1.10
   - Do you want to add more IPs to the white list? (y/n)? [n]: y   - IPs (space separated): 10.16.26.199 10.16.26.66
  3.5- Do you want to enable remote syslog (port 514 udp)? (y/n) [y]: y
   - Remote syslog enabled.
  3.6- Setting the configuration to analyze the following logs:    -- /var/log/messages    -- /var/log/mail.info
- If you want to monitor any other file, just change   the ossec.conf and add a new localfile entry.   Any questions about the configuration can be answered   by visiting us online at http://www.ossec.net .
   --- Press ENTER to continue ---
5)按回车开始安装

3. 启动服务器
#/var/ossec/bin/ossec-control start
启动成功之后提示:
Starting OSSEC HIDS v2.4.1 (by Trend Micro Inc.)...Started ossec-maild...Started ossec-execd...Started ossec-analysisd...Started ossec-logcollector...Started ossec-remoted...Started ossec-syscheckd...Started ossec-monitord...Completed.

4. 停止服务器
#/var/ossec/bin/ossec-control stop

二、客户端安装
1. 安装ossec,双击ossec-agent-win32-2.4.1.exe进行安装2. 安装过程中所有选择都采用默认方式进行安装3. 配置客户端在ip中输入server的ip地址Key需要在服务器上生成

4. 在服务器端添加agent1) 进入OSSEC的安装目录并添加agent#cd /var/ossec/bin#./manage_agents2) 选择添加一个Agent***************************************** OSSEC HIDS v2.4.1 Agent manager. ** The following options are available: ***************************************** (A)dd an agent (A). (E)xtract key for an agent (E). (L)ist already added agents (L). (R)emove an agent (R). (Q)uit.Choose your action: A,E,L,R or Q: A3) 填写Agent的名称、ip地址及序号- Adding a new agent (use '/q' to return to the main menu). Please provide the following: * A name for the new agent: zzt * The IP Address of the new agent: 10.16.26.199 * An ID for the new agent[001]: 001Agent information: ID:001 Name:zzt IP Address:10.16.26.199
Confirm adding it?(y/n): yAgent added.
5 生成key在服务器端生成key***************************************** OSSEC HIDS v2.4.1 Agent manager.     ** The following options are available: *****************************************   (A)dd an agent (A).   (E)xtract key for an agent (E).   (L)ist already added agents (L).   (R)emove an agent (R).   (Q)uit.Choose your action: A,E,L,R or Q: E
Available agents:   ID: 001, Name: zzt, IP: 10.16.26.199Provide the ID of the agent to extract the key (or '/q' to quit): 001
Agent key information for '001' is:MDAxIHp6dCAxMC4xNi4yNi4xOTkgOWI4YTY1NWI3ZjhkY2Y5MDJmZmI2ZGQxZmY4YzgyOGY4YzA5ZmQ3ZTBmMDY4NTVlNDI4Y2VkZDI4OTUzOTBhMQ==
** Press ENTER to return to the main menu.
6. 拷贝key文件到客户端并点击保存并确定
7. 运行客户端点击Manage - Start OSSEC

三、配置服务器端的远程日志
1. 配置remote syslog 服务器1)停止ossec服务器#/var/ossec/bin/ossec-control stop2)修改/var/ossec/etc/ossec.conf在/var/ossec/etc/ossec.conf文件中添加  <global>    ……  </global>    <syslog_output>    <server>10.16.13.213</server>      </syslog_output>
如果需要将不同级别的警告信息添加到不同的服务器上,可以做如下配置  <global>    ……  </global>    <syslog_output>    <server>10.16.13.213</server>      </syslog_output>  <syslog_output>    <level>10</level>    <server>10.16.13.213</server>      </syslog_output>3)配置syslog并启动ossec# /var/ossec/bin/ossec-control enable client-syslog# /var/ossec/bin/ossec-control start启动后会看到在配置的远程syslog日志文件中看到如下信息:
Jul  1 07:54:35 10.16.26.66 ossec: Alert Level: 3; Rule: 501 - New ossec agent connected.; Location: (zzt) 10.16.26.199->ossec;  ossec: Agent started: 'zzt->10.16.26.199'.

说明:在安装OSSEC之前请确定已经安装了GCC。

附件给出了与安装相关文件,包括GCC的安装包(按以下顺序进行安装):
glibc-2.3.3-98.94.i586.rpmglibc-devel-2.3.3-98.94.i586.rpmgcc-3.3.3-43.54.i586.rpm gcc-info-3.3.3-43.54.i586.rpmlibstdc++-3.3.3-43.54.i586.rpmlibstdc++-devel-3.3.3-43.54.i586.rpmgcc-c++-3.3.3-43.54.i586.rpm

评论
1 楼 zhangzhenting 2010-08-25   引用
路径:jboss-4.0.5.GA/server/default/deploy/jbossweb-tomcat55.sar/server.xml 12:      <Connector port="80" address="0.0.0.0" URIEncoding="UTF-8" 原端口号 8080 路径:jboss-4.0.5.GA/server/default/conf/jboss-service.xml 203:      <attribute name="Port">8084</attribute> 原端口号8083 234:      <attribute name="Port">8099</attribute> 原端口号1099 240:      <attribute name="RmiPort">8098</attribute> 原端口号1098 371:      <attribute name="RMIObjectPort">8444</attribute> 原端口号4444 395:      <attribute name="ServerBindPort">8445</attribute> 原端口号4445

文章二:http://doc.chinaunix.net/linux/201003/465709.shtml

ossec主机入侵检查系统架设
  概念

  rootkit含义:

  rootkit基本是由几个独立程序组成,一个典型rootkit包括:以太网嗅探器程序,用于获得网络上传输的用户名和密码等信息。特洛伊木马程序,为攻击者提供后门。隐藏攻击者目录和进程的程序。还包括一些日志清理工具,攻击者用其删除wtmp、utmp和lastlog等日志文件中有关自己行踪的条目。复杂的rootkit还可以向攻击者提供telnet、shell和 finger等服务。还包括一些用来清理/var/log和/var/adm目录中其它文件的脚本。

  这种可恶的程序是一批工具集,黑客用它来掩饰对计算机网络的入侵并获得管理员访问权限。一旦黑客获得管理员访问权限,就会利用已知的漏洞或者破解密码来安装rootkit。然后rootkit会收集网络上的用户ID和密码,这样黑客就具有高级访问权限了。

  Rootkit扫描是专门针对rootkit进行的一种优化式的扫描方式。

  一.OSSEC简要介绍:

  OSSEC 是一款开源的入侵检测系统,包括了日志分析,全面检测,rook-kit检测。作为一款HIDS,OSSEC应该被安装在一台实施监控的系统中。另外有时候不需要安装完全版本得OSSEC,如果有多台电脑都安装了OSSEC,那么就可以采用客户端/服务器模式来运行。客户机通过客户端程序将数据发回到服务器端进行分析。在一台电脑上对多个系统进行监控对于企业或者家庭用户来说都是相当经济实用的。

  对我来说OSSEC最大的优势在于它几乎可以运行在任何一种操作系统上,比如Windows, Linux, OpenBSD/FreeBSD, 以及 MacOS。不过运行在Windows上的客户端无法实现root-kit检测,而其他系统上的客户端都没有问题。OSSEC的手册上说OSSEC目前还不支持Windows系统下得root-kit检测

  二.安装

  1. 安装所需软件:Basically, for Unix systems, ossec just requires gcc and glibc.

  下载软件:从http://www.ossec.net 上下载最新的OSSEC

  源代码包;

  2. 安装服务器:

  1). 选择一台服务器作为OSSEC服务器;

  2). 将OSSEC源代码包拷贝到该服务器并解压;

  3). 进入OSSEC目录并运行install.sh开始安装(如果想让ossec支持mysql,则在安装前先需入src目录下执行make setdb命令,如果想让ossec支持更多代理,在src目录下执行make setmaxagents命令,ossec目前最大只支持2048个客户端,并且大多数系统对最大文件数有限制,我们可以通过ulimit -n 2048来增加系统支持的最大文件数(或者sysctl -w kern.maxfiles=2048;

  4). 在提示输入安装类型时,输入server;

  5). 在提示输入安装路径时,输入/opt/ossec;

  6). 在提示是否希望接收E-MAIL通告时, 接受默认值, 并在接下来的提示中依次输入用来接收OSSEC 通告的E-MAIL地址, 邮件服务器的名字或IP地址,我这里是选择localhost作为smtp,,然后通过设置/etc/alias别名列表来将邮件转发到我指定的邮箱;

  7). 其它提示接受默认值;

  3. 安装代理:

  1). 将OSSEC源代码包拷贝到某台欲在其上安装OSSEC代理的linux服务器上并解压;

  2). 进入OSSEC目录并运行install.sh开始安装;

  3). 在提示输入安装类型时,输入agent;

  4). 在提示输入安装路径时,输入/opt/ossec;

  5). 在提示输入服务器IP地址时输入我们的OSSEC服务器的IP地

  址;

  6). 其它提示接受默认值;

  在欲在其上安装OSSEC代理的所有linux服务器执行1) – 6)

  三.配置

  1.       在OSSEC服务器上运行 /opt/ossec/bin/manage-agents;

  2.       在某个OSSEC代理上运行 /opt/ossec/bin/manage-agents;

  3.       在OSSEC服务器的主菜单下输入A/a 增加一个代理, 为该代理输入一个容易区别的名字(比如其hostname), 并输入其IP 地址;

  4.       在主菜单下输入E/e 为该代理生成密钥;

  5.       在该OSSEC代理的主菜单下输入I/i 准备导入OSSEC服务器生成的密钥;

  6.       将OSSEC服务器生成的密钥复制到OSSEC代理;

  7.       按Q/q键退出OSSEC服务器和代理, 并重新启动OSSEC服务器和代理(分别在OSSEC服务器和代理所在的服务器上执行/etc/init.d/ossec restart)

  在欲在其上配置OSSEC代理的所有linux服务器执行2) – 7)

  OSSEC安装

  8.    ossec安装完后,默认会在$directory生成如下几个目录:active-response,bin,etc,logs,queue, rules,stats,tmp,var,主要配置文件为/$directory/etc/ossec.conf,$directory为你ossec安装目录,每个选项的详细说明请见:http://www.ossec.net/en/manual.html#installorder。规则文件目录为 /$directory/rules



  四.FAQ

  Question 1:

  如何配置ossec在主动响应中不阻止特定ip

  A:将特定ip列表加入etc/ossec.conf中的<white-list>ips</white-list>

  如我们不想让192.168.10.0/24网段的所有主机触发ossec主动响应的命令,编辑/var/ossec/etc/ossec.conf,按如下方式填写即可

  <global>

  <white-list>127.0.0.1</white-list>

  <white-list>192.168.10.0/24</white-list>

  </global>

  Question 2

  如何使ossec支持mysql

  A:要使用ossec支持mysql,首先编译时我们需进入src目录下执行:make setdb命令,然后cd ..返回上一级目录,再执行package/install.sh按上面所列方法安装

  Question 3

  我smtp server设置正确,但为何我收不到ossec主机所发的邮件,在邮件日志中老显示连接超时。

  A: ossec原则上不要求在本地架设mta服务器,但我们知道,为了防止垃圾,基本上所有邮件服务器都关闭了open relay,然我们的ossec并没有为smtp认证提供username与password设置选项,这就使我们在选择其它smtp 服务器时无法指定用户名与密码,因此我的做法是设置ossec发信给root@localhost,然后在本地邮件服务器别名列表中,将所有转发给 root的信件再转发给我所希望的email地址。

  Question 4

  如何设置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

  我们可以这样设置

  <localfile>

  <log_format>syslog</log_format>

  <localtion>/var/log/host*/*.log</location>

  </localfile>

  Question 5

  我采用的是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 6

  如何检测apache日志

  我们可以这样设置

  <localfile>

  <log_format>apache</log_format>

  <localtion>你的apache日志目录</location>

  </localfile>

  Question 7

  我公司是动态ip上网,经常被布署有ossec入侵检测系统的外网维护服务器将其加入/etc/hosts.deny与iptables中

    针对这个问题,我有专门写一个脚本,你可以参照它针对自己的网络环境修改,目前我的有了它之后一切运行良好。】
****************************************************
    thx2引文!

原创粉丝点击