日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
OSSEC日志泛化及告警規(guī)則配置

OSSEC是一款開源的多平臺的入侵檢測系統(tǒng),可以運(yùn)行于Windows, Linux, OpenBSD/FreeBSD, 以及 MacOS等操作系統(tǒng)中。包括了日志分析,全面檢測,root-kit檢測。

10年的南皮網(wǎng)站建設(shè)經(jīng)驗(yàn),針對設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整南皮建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)從事“南皮網(wǎng)站設(shè)計(jì)”,“南皮網(wǎng)站推廣”以來,每個客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

1. 測試和驗(yàn)證OSSEC泛化及告警規(guī)則

OSSEC默認(rèn)具有一個ossec-logtest工具用于測試OSSEC的泛化及告警規(guī)則。該工具一般默認(rèn)安裝于目錄 /var/ossec/bin 中。

使用示例:

 
 
 
 
  1. /var/ossec/bin/ossec-logtest
  2. 2014/06/1113:15:36 ossec-testrule: INFO: Reading local decoder file.
  3. 2014/06/11 13:15:36 ossec-testrule: INFO: Started (pid: 26740).
  4. ossec-testrule: Type one log per line.
  5. Jun 10 21:29:33 172.16.25.122/172.16.24.32 sshd[24668]: Accepted publickey for root from 172.16.24.121 port 38720 ssh2
  6. **Phase 1: Completed pre-decoding.
  7.        full event: 'Jun 10 21:29:33 172.16.25.122/172.16.24.32 sshd[24668]: Accepted publickey for root from 172.16.24.121 port 38720 ssh2'
  8.        hostname: '172.16.25.122/172.16.24.32'
  9.        program_name: 'sshd'
  10.        log: 'Accepted publickey for root from 172.16.24.121 port 38720 ssh2'
  11. **Phase 2: Completed decoding.
  12.        decoder: 'sshd'
  13.        dstuser: 'root'
  14.        srcip: '172.16.24.121'
  15. **Phase 3: Completed filtering (rules).
  16.        Rule id: '10100'
  17.        Level: '4'
  18.        Description: 'First time user logged in.'
  19. **Alert to be generated.

如上文所示,當(dāng)輸入日志內(nèi)容:

Jun 1021:29:33 172.16.25.122/172.16.24.32 sshd[24668]: Accepted publickey for rootfrom 172.16.24.121 port 38720 ssh2

該條日志經(jīng)過三步處理,生成了一條4級告警,規(guī)則ID為10100,內(nèi)容為“First time user logged in.”

使用ossec-logtest–v命令,可獲取更詳細(xì)的日志分析邏輯。

 
 
 
 
  1. /var/ossec/bin/ossec-logtest  -v
  2. 2014/06/11 13:44:52 ossec-testrule: INFO: Reading local decoder file.
  3. 2014/06/11 13:44:52 ossec-testrule: INFO: Started (pid: 27091).
  4. ossec-testrule: Type one log per line.
  5. Jun 11 21:44:41 172.16.25.122/172.16.24.32 sshd[27743]: Did not receive identification string from 172.16.24.121
  6. **Phase 1: Completed pre-decoding.
  7.        full event: 'Jun 11 21:44:41 172.16.25.122/172.16.24.32 sshd[27743]: Did not receive identification string from 172.16.24.121'
  8.        hostname: '172.16.25.122/172.16.24.32'
  9.        program_name: 'sshd'
  10.        log: 'Did not receive identification string from 172.16.24.121'
  11. **Phase 2: Completed decoding.
  12.        decoder: 'sshd'
  13.        srcip: '172.16.24.121'
  14. **Rule debugging:
  15.     Trying rule: 1 - Generic template for all syslog rules.
  16.        *Rule 1 matched.
  17.        *Trying child rules.
  18.     Trying rule: 5500 - Grouping of the pam_unix rules.
  19.     Trying rule: 5700 - SSHD messages grouped.
  20.        *Rule 5700 matched.
  21.        *Trying child rules.
  22.     Trying rule: 5709 - Useless SSHD message without an user/ip and context.
  23.     Trying rule: 5711 - Useless/Duplicated SSHD message without a user/ip.
  24.     Trying rule: 5721 - System disconnected from sshd.
  25.     Trying rule: 5722 - ssh connection closed.
  26.     Trying rule: 5723 - SSHD key error.
  27.     Trying rule: 5724 - SSHD key error.
  28.     Trying rule: 5725 - Host ungracefully disconnected.
  29.     Trying rule: 5727 - Attempt to start sshd when something already bound to the port.
  30.     Trying rule: 5729 - Debug message.
  31.     Trying rule: 5732 - Possible port forwarding failure.
  32.     Trying rule: 5733 - User entered incorrect password.
  33.     Trying rule: 5734 - sshd could not load one or more host keys.
  34.     Trying rule: 5735 - Failed write due to one host disappearing.
  35.     Trying rule: 5736 - Connection reset or aborted.
  36.     Trying rule: 5707 - OpenSSH challenge-response exploit.
  37.     Trying rule: 5701 - Possible attack on the ssh server (or version gathering).
  38.     Trying rule: 5706 - SSH insecure connection attempt (scan).
  39.        *Rule 5706 matched.
  40. **Phase 3: Completed filtering (rules).
  41.        Rule id: '5706'
  42.        Level: '6'
  43.        Description: 'SSH insecure connection attempt (scan).'
  44. **Alert to be generated.

2. 自定義日志泛化規(guī)則

2.1 添加日志源

添加日志源的方式很簡單,通過修改/var/ossec/etc/ossec.conf 即可實(shí)現(xiàn)。

如果日志源是本地文件,可通過添加如下配置實(shí)現(xiàn)。

 
 
 
 
  1.   syslog
  2.   /path/to/log/file

如果日志源是遠(yuǎn)程syslog,可通過添加如下配置實(shí)現(xiàn)。

 
 
 
 
  1. syslog
  2. udp
  3. 2514
  4. 172.16.24.0/24

2.2 創(chuàng)建自定義的日志泛化規(guī)則

假如有兩條日志如下文:

Jun 11 22:06:30172.17.153.38/172.16.24.32 /usr/bin/auditServerd[25649]: 
User blackrat loginSUCEESS from 172.17.153.36 to 172.17.153.38 distport 3333 .
Jun 11 22:06:30172.17.153.38/172.16.24.32 /usr/bin/auditServerd[25649]:
User blackrat login PWD_ERRORfrom 172.17.153.36 to 172.17.153.38 distport 3333 .

該日志使用ossec-logtest分析之后結(jié)果如下:

Jun 11 22:06:30 172.17.153.38/172.16.24.32 /usr/bin/auditServerd[25649]: User blackrat login SUCEESS from 172.17.153.36 to 172.17.153.38 distport 3333 .

**Phase 1: Completed pre-decoding.
       full event: 'Jun 11 22:06:30 172.16.25.130/172.16.24.32 /usr/bin/auditServerd[25649]: User blackrat login SUCEESS from 172.17.153.36 to 172.17.153.38 distport 3333 .'
       hostname: '172.17.153.38/172.16.24.32'
       program_name: '/usr/bin/auditServerd'
       log: 'User blackrat login SUCEESS from 172.17.153.36 to 172.17.153.38 distport 3333 .'

**Phase 2: Completed decoding.
       No decoder matched

由此可知OSSEC在分析日志的時(shí)候,經(jīng)過了兩個泛化過程:pre-decoding和 decoding。

pre-decoding過程是ossec內(nèi)置的,只要是標(biāo)準(zhǔn)的syslog日志,都可以解析出如下4個基本信息。

Timestamp:Jun 11 22:06:30
Hostname: 172.17.153.38/172.16.24.32
Programe_name: /usr/bin/auditServerd
Log: User blackrat login SUCEESS from 172.17.153.36 to 172.17.153.38 distport 3333.

在decoding過程,用戶可以通過修改/var/ossec/etc/decoder.xml,實(shí)現(xiàn)自定義的泛化。例如在該文件中添加如下規(guī)則:

 
 
 
 
  1.   /usr/bin/auditServerd

再次執(zhí)行/var/ossec/bin/ossec-logtest

 
 
 
 
  1. **Phase 1: Completed pre-decoding.
  2.        full event: 'Jun 11 22:06:30 172.17.153.38/172.16.24.32 /usr/bin/auditServerd[25649]: User blackrat login SUCEESS from 172.17.153.36 to 172.17.153.38 distport 3333 .'
  3.        hostname: '172.17.153.38/172.16.24.32'
  4.        program_name: '/usr/bin/auditServerd'
  5.        log: 'User blackrat login SUCEESS from 172.17.153.36 to 172.17.153.38 distport 3333 .'
  6. **Phase 2: Completed decoding.
  7.        decoder: 'auditServerd'

發(fā)現(xiàn),該條日志成功命中了名為auditServerd的規(guī)則,該條規(guī)則可以準(zhǔn)確的將日志定位為是程序auditServerd所發(fā)出的。

除此之外,基于auditServerd這條規(guī)則,我們還可以添加更多的子規(guī)則,來識別出更多的信息。如:

 
 
 
 
  1.                                
  2.   /usr/bin/auditServerd                        
  3.                                       
  4.   auditServerd                           
  5.   ^User (\S+) login (\S+) from (\S+) to (\S+) distport (\S+) \.$  
  6.   user,status,srcip,dstip,dstport                                

再次執(zhí)行/var/ossec/bin/ossec-logtest,可獲取更多的信息,如下:

 
 
 
 
  1. **Phase 1: Completed pre-decoding.
  2.       full event: 'Jun 11 22:06:30 172.17.153.38/172.16.24.32/usr/bin/auditServerd[25649]: User blackrat login SUCEESS from 172.17.153.36 to172.17.153.38 distport 3333 .'
  3.       hostname: '172.17.153.38/172.16.24.32'
  4.       program_name: '/usr/bin/auditServerd'
  5.       log: 'User blackrat login SUCEESS from 172.17.153.36 to 172.17.153.38distport 3333 .'
  6.  
  7. **Phase 2: Completed decoding.
  8.       decoder: 'auditServerd'
  9.        dstuser: 'blackrat'
  10.       status:'SUCEESS'
  11.       srcip: '172.17.153.36'
  12.        dstip: '172.17.153.

用戶通過配置上述正則表達(dá)式,獲取特定字段,用于后續(xù)的關(guān)聯(lián)分析。OSSEC一共內(nèi)置了14個用戶可解析的字段:

 - location – where the log came from (only on FTS)
   - srcuser  - extracts the source username
   - dstuser  - extracts the destination (target) username
   - user     – an alias to dstuser (only one of the two can be used)
   - srcip    - source ip
   - dstip    - dst ip
   - srcport  - source port
   - dstport  - destination port
   - protocol – protocol
   - id       – event id
   - url      - url of the event
   - action   – event action (deny, drop, accept, etc)
   - status   – event status (success, failure, etc)
   - extra_data     – Any extra data

3. 自定義日志告警規(guī)則

3.1 規(guī)則文件路徑配置

OSSEC的規(guī)則配置文件默認(rèn)路徑為/var/ossec/rules/,要加載規(guī)則文件,需要在/var/ossec/etc/ossec.conf 中配置,默認(rèn)的配置如下:

 
 
 
 
  1.   
  2.   
  3.     rules_config.xml
  4.     pam_rules.xml
  5.     sshd_rules.xml
  6.     telnetd_rules.xml
  7.     syslog_rules.xml
  8.     arpwatch_rules.xml
  9.      ......  
  10.     clam_av_rules.xml 
  11.     bro-ids_rules.xml
  12.     dropbear_rules.xml
  13.     local_rules.xml 
  14.  
  15.   

其實(shí)通過下列配置,可以實(shí)現(xiàn)加載/var/ossec/rules 下的所有規(guī)則文件:

 
 
 
 
  1.  
  2.     
  3.         rules
  4.     

于泛化規(guī)則,也可以通過配置decoder_dir域來實(shí)現(xiàn),如:

 
 
 
 
  1.     
  2.         rules/plugins/decoders
  3.     

上述配置可將/var/ossec/rules/plugins/plugins/decoders目錄下所有的xml文件都添加為OSSEC日志泛化規(guī)則。

對于更詳細(xì)的配置及語法,可參考下列文檔:

http://ossec-docs.readthedocs.org/en/latest/syntax/head_ossec_config.rules.html#element-rule_dir

3.2 OSSEC告警規(guī)則配置

例如,我們需要增加對程序auditServerd的告警規(guī)則,我們需要針對auditServerd程序新建一個規(guī)則文件,對于OSSEC中已經(jīng)存在的規(guī)則文件如sshd, openbsd, vsftpd等,我們只需要在對應(yīng)的文件中進(jìn)行新增或修改。

首先我們新建文件

/var/ossec/rules/auditServerd_rules.xml

添加如下內(nèi)容:

 
 
 
 
  1.    
  2.     auditServerd
  3.     Grouping for the auditServerd rules.
  4.   
  5.   
  6.     80000
  7.     blackrat
  8.     172.17.153.36
  9.     User blackrat is not allowed login from 172.17.153.36!
  10.   

上述規(guī)則中,規(guī)則id 80000 用于對日志進(jìn)行分組計(jì)數(shù),假如日志中出現(xiàn)了泛化為auditServerd的日志,則對該日志分組為auditServer,且狀態(tài)機(jī)計(jì)數(shù)加1.

規(guī)則80001描述了假如user為blackrat,srcip為172.17.153.36 則命中,并發(fā)出“User blackrat is not allowed login from 172.17.153.36!”的告警。

將該文件路徑加入到文件/var/ossec/etc/ossec.conf中

 
 
 
 
  1.  …
  2. dropbear_rules.xml 
  3. local_rules.xml 
  4. auditServerd_rules.xml 

執(zhí)行/var/ossec/bin/ossec-logtest,結(jié)果如下:

 
 
 
 
  1. **Phase 1: Completed pre-decoding.
  2.        full event: 'Jun 11 22:06:30 172.17.153.38/172.16.24.32 /usr/bin/auditServerd[25649]: User blackrat login SUCEESS from 172.17.153.36 to 172.17.153.38 distport 3333 .'
  3.        hostname: '172.17.153.38/172.16.24.32'
  4.        program_name: '/usr/bin/auditServerd'
  5.        log: 'User blackrat login SUCEESS from 172.17.153.36 to 172.17.153.38 distport 3333 .'
  6. **Phase 2: Completed decoding.
  7.        decoder: 'auditServerd'
  8.        dstuser: 'blackrat'
  9.        status: 'SUCEESS'
  10.        srcip: '172.17.153.36'
  11.        dstip: '172.17.153.38'
  12.        dstport: '3333'
  13. **Phase 3: Completed filtering (rules).
  14.        Rule id: '80001'
  15.        Level: '10'
  16.        Description: 'User blackrat is not allowed login from 172.17.153.36!'
  17. **Alert to be generated.

3.3 關(guān)聯(lián)分析告警規(guī)則

OSSEC可以實(shí)現(xiàn)基于因果關(guān)系、事件頻次的關(guān)聯(lián)分析告警,具體實(shí)現(xiàn)方式如下。

假如我們想要實(shí)現(xiàn)當(dāng)來自同一IP的用戶登陸auditServerd,在1分鐘內(nèi)達(dá)到5次登錄失敗時(shí),進(jìn)行告警,我們可以配置規(guī)則如下:

 
 
 
 
  1.    
  2.     auditServerd
  3.     Grouping for the auditServerd rules.
  4.   
  5.   
  6.     80000
  7.     SUCEESS
  8.     blackrat
  9.     172.17.153.36
  10.     User blackrat is not allowed login from 172.17.153.36!
  11.   
  12.   
  13.     80000
  14.     PWD_ERROR
  15.     authServer_login_failures,
  16.     login auditServerd password error.
  17.   
  18.    
  19.     authServer_login_failures
  20.     auditServerd brute force trying to get access to        
  21.     the audit system.
  22.     
  23.     authentication_failures,
  24.   

執(zhí)行/var/ossec/bin/ossec-logtest,連續(xù)五次輸入日志:

結(jié)果如下:

 
 
 
 
  1. **Phase 1: Completed pre-decoding.
  2.        full event: 'Jun 11 22:06:30 172.17.153.38/172.16.24.32 /usr/bin/auditServerd[25649]: User blackrat login PWD_ERROR from 172.17.153.36 to 172.17.153.38 distport 3333 .'
  3.        hostname: '172.17.153.38/172.16.24.32'
  4.        program_name: '/usr/bin/auditServerd'
  5.        log: 'User blackrat login PWD_ERROR from 172.17.153.36 to 172.17.153.38 distport 3333 .'
  6. **Phase 2: Completed decoding.
  7.        decoder: 'auditServerd'
  8.        dstuser: 'blackrat'
  9.        status: 'PWD_ERROR'
  10.        srcip: '172.17.153.36'
  11.        dstip: '172.17.153.38'
  12.        dstport: '3333'
  13. **Phase 3: Completed filtering (rules).
  14.        Rule id: '80003'
  15.        Level: '15'
  16.        Description: 'auditServerd brute force trying to get access to the audit system.'
  17. **Alert to be generated.

對于OSSEC日志告警規(guī)則更詳細(xì)的語法,參見:

http://ossec-docs.readthedocs.org/en/latest/syntax/head_rules.html

對于OSSEC中正則表達(dá)式的語法,參加:

http://ossec-docs.readthedocs.org/en/latest/syntax/regex.html


標(biāo)題名稱:OSSEC日志泛化及告警規(guī)則配置
網(wǎng)頁網(wǎng)址:http://www.5511xx.com/article/cdscjph.html