Ossec 配置執行個體

來源:互聯網
上載者:User

監控檔案/目錄

修改ossec.conf設定檔,加入以下內容:

/opt/web < /directories > #檢測目錄

/var/web/upload < /ignore > #忽略upload目錄檢測

/var/web/config .conf< /ignore > #忽略config.conf檔案檢測

< /syscheck >

監控web日誌

修改ossec.conf設定檔,加入以下內容:

apache< /log_format > #日誌格式

/var/log/nginx/error .log< /location > #web日誌路徑

< /localfile >

入侵檢測

修改ossec.conf設定檔標籤定義的規則檔案,達到入侵檢測的目的。

比如某種後門會在/tmp目錄下產生mcrootkit檔案,在/var/ossec/etc/shared/rootkit_files.txt檔案中添加如下內容:

tmp/mcrootkit ! Bash door ::/rootkits/bashdoor.php

郵件通知資訊

OSSEC HIDS Notification. 2015 Jul 07 18:19:14 Received From: (web-10-10-51-51) 10.10.51.51->rootcheck

Rule: 510 fired (level 7) -> "Host-based anomaly detection event (rootcheck)."

Portion of the log(s):

Rootkit 'Bash' detected by the presence of file '/tmp/secrootkit' .

--END OF NOTIFICATION

自動響應

添加ddos_rules.xml檔案到ossec.conf設定檔中

ddos_rules.xml < /include >

< /rules >

建立防CC攻擊規則

# cat /var/ossec/rules/ddos_rules.xml

#定義rule id

31108< /if_sid > #判斷rule id 31108

^/*.php< /url > #匹配URL地址中包含任何php檔案

CC ATTACKS URL < /description > #描述

< /rule >

31177< /if_matched_sid >

CC ATTACKS< /description >

DDOS< /group >

< /rule >

說明:

60秒內同一IP訪問php檔案超過10次,觸發指令碼

匹配urle id 為31108的日誌中URL包含任何php檔案

關於rule id 31108 規則詳細定義,請查看web_rules.xml檔案。

31100< /if_sid >

< id >^2|^3< /id >

is_simple_http_request< /compiled_rule >

Ignored URLs (simple queries).< /description >

< /rule >

說明:rule id 31108是匹配web日誌2x,3x存取碼。有效過濾了404,403等錯誤頁面

配置自動響應

在ossec.conf設定檔中,添加如下內容:

< command >

firewall-drop< /name > #命令名稱

firewall-drop.sh< /executable > #執行指令碼

srcip< /expect > #指令碼參數,用戶端IP

yes < /timeout_allowed > #允許逾時

< /command >

< command >firewall-drop< /command > #自動響應命令名稱,上面定義

local < /location > #指令碼執行位置,local表示agent端

31178< /rules_id > #觸發rule id

600< /timeout > #逾時時間

< /active-response >

自訂規則

在日誌中過濾字串,比如日誌中出現admin_backdoor,觸發警示

添加test_rules.xml檔案到ossec.conf設定檔中

test_rules.xml < /include >

< /rules >

建立過濾規則

#vi /var/ossec/rules/test_rules.xml

admin_backdoor< /decoded_as > #decode名稱

admin_backdoor access< /description >

< /rule >

< /group >

配置decoder.xml檔案

# cat /var/ossec/etc/decoder.xml

#decoder名稱,與test_rules.xml名稱匹配

^admin_backdoor< /prematch > #匹配字串admin_backdoor

< /decoder >

警示資訊:

[root@ossec-server-10-10-51-50 /var/ossec]# ./bin/ossec-logtest

2015 /07/07 19:48:20 ossec-testrule: INFO: Reading local decoder file .

2015 /07/07 19:48:20 ossec-testrule: INFO: Started (pid: 16189).

ossec-testrule: Type one log per line.

admin_backdoor #輸入字串

**Phase 1: Completed pre-decoding.

full event: 'admin_backdoor'

hostname : 'ossec-server-10-10-51-50'

program_name: '(null)'

log: 'admin_backdoor'

**Phase 2: Completed decoding.

decoder: 'admin_backdoor'

**Phase 3: Completed filtering (rules).

Rule id : '7777' #匹配到rule id 8888

Level: '7'

Description: 'admin_backdoor access' #描述,上面定義好的

**Alert to be generated.
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.