Linux下安裝ossec

安裝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 [email protected] (or [email protected]).
  - 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引文!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章