溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

怎么通過(guò)Kibana、Wazuh和Bro IDS提高中小企業(yè)的威脅檢測(cè)能力

發(fā)布時(shí)間:2021-12-23 10:50:10 來(lái)源:億速云 閱讀:222 作者:柒染 欄目:網(wǎng)絡(luò)安全

這篇文章給大家介紹怎么通過(guò)Kibana、Wazuh和Bro IDS提高中小企業(yè)的威脅檢測(cè)能力,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

近來(lái),我們一直都在通過(guò)一些開(kāi)源免費(fèi)的工具,來(lái)幫助中小企業(yè)提升其網(wǎng)絡(luò)威脅檢測(cè)能力。我們將手把手的教大家通過(guò)Kibana,Wazuh和Bro IDS來(lái)提高自身企業(yè)的威脅檢測(cè)能力。

什么是Wazuh?

Wazuh是一款以O(shè)SSEC作為引擎的基于主機(jī)的入侵檢測(cè)系統(tǒng)。通過(guò)與ELK的結(jié)合,便于管理員通過(guò)日志平臺(tái)查看系統(tǒng)日志信息,告警信息,規(guī)則配置信息等。

安裝ELK & Wazuh

這里有份非常詳細(xì)的Wazuh官方文檔,你可以參考該文檔進(jìn)行安裝。安裝成功后,你可以通過(guò)http://your_server:5601訪問(wèn)Kibana和Wazuh。

怎么通過(guò)Kibana、Wazuh和Bro IDS提高中小企業(yè)的威脅檢測(cè)能力

安裝Bro

BRO是一個(gè)開(kāi)源的IDS項(xiàng)目。它的安裝相對(duì)容易,但使用Kibana進(jìn)行設(shè)置就會(huì)復(fù)雜許多。我們嘗試了好幾個(gè)網(wǎng)上的安裝教程,但都沒(méi)有成功。所以,我們創(chuàng)建了我們自己的安裝指南,你只需重復(fù)我們的安裝步驟即可(避免在此過(guò)程浪費(fèi)時(shí)間)。

Ubuntu 安裝

默認(rèn)情況下,Ubuntu上已安裝了Git。因此,你可以使用以下命令克隆存儲(chǔ)庫(kù)。這些文件將被放入名為bro的目錄中。

git clone --recursive git://git.bro.org/bro

切換到項(xiàng)目目錄

cd bro

運(yùn)行Bro的配置(這個(gè)過(guò)程應(yīng)該不到一分鐘就能完成)。

./configure
make

在運(yùn)行時(shí),你會(huì)在大多數(shù)輸出行的開(kāi)頭看到完成百分比。

完成后,安裝Bro(這也應(yīng)該用不到一分鐘的時(shí)間)。

sudo make install

Bro將被安裝在/usr/local/bro目錄中。

現(xiàn)在我們需要將/usr/local/bro目錄添加到$PATH中。要確保它在全局可用,最好的方法是在/etc/profile.d目錄下指定文件中的路徑。我們將該文件稱(chēng)為3rd-party.sh。

export PATH=$PATH:/usr/local/bro/bin

現(xiàn)在,我們已經(jīng)安裝了Bro,接下來(lái)我們還需要對(duì)它進(jìn)行一些配置更改才能正常運(yùn)行。

配置Bro

這里我們需要對(duì)一些Bro的配置文件進(jìn)行修改。這些文件都位于/usr/local/bro/etc目錄中,主要包含以下三個(gè)文件:

node.cfg,用于配置要監(jiān)視的節(jié)點(diǎn)。

networks.cfg,包含節(jié)點(diǎn)本地的CIDR表示法網(wǎng)絡(luò)列表。

broctl.cfg,郵件,日志記錄和其他設(shè)置的全局BroControl配置文件。

讓我們看看每個(gè)文件中需要修改的地方。

配置要監(jiān)控的節(jié)點(diǎn)

要配置Bro的監(jiān)視節(jié)點(diǎn),我們需要修改node.cfg文件。

開(kāi)箱即用,Bro被配置為在獨(dú)立模式下運(yùn)行。因?yàn)檫@是獨(dú)立安裝的,所以你不需要修改此文件,但最好是檢查下其中的值是否正確。

打開(kāi)文件進(jìn)行編輯。

sudo nano /usr/local/bro/etc/node.cfg

在bro部分,我們找到interface參數(shù)。這里的默認(rèn)值為eth0,這應(yīng)該與你的Ubuntu 16.04服務(wù)器的公共接口相匹配。如果不一致的話(huà),你就要進(jìn)行修改。

/usr/local/bro/etc/node.cfg

[bro]
type=standalone
host=localhost
interface=eth0

完成后保存并關(guān)閉文件。接下來(lái),我們將配置該節(jié)點(diǎn)所屬的專(zhuān)用網(wǎng)絡(luò)。

你可以在networks.cfg文件中,配置節(jié)點(diǎn)所屬的IP網(wǎng)絡(luò)(即你希望監(jiān)視的服務(wù)器接口的IP網(wǎng)絡(luò))。

我們打開(kāi)該文件。

sudo nano /usr/local/bro/etc/networks.cfg

默認(rèn)情況下,該文件附帶三個(gè)專(zhuān)用IP地址塊示例。

/usr/local/bro/etc/networks.cfg
# List of local networks in CIDR notation, optionally followed by a
# descriptive tag.
# For example, "10.0.0.0/8" or "fe80::/64" are valid prefixes.

10.0.0.0/8          Private IP space
172.16.0.0/12       Private IP space
192.168.0.0/16      Private IP space

刪除現(xiàn)有的三個(gè)條目,然后添加我們自己的條目。你可以通過(guò)ip addr show命令來(lái)檢查服務(wù)器接口的網(wǎng)絡(luò)地址。你的networks.cfg文件最終應(yīng)該看起來(lái)像下面這樣:

示例 /usr/local/bro/etc/networks.cfg

192.168.1.0/24          Public IP space
172.16.100.0/24         Private IP space

完成編輯后保存并關(guān)閉文件。接下來(lái),我們將配置郵件和日志記錄設(shè)置。

使用BroControl管理Bro

BroControl用于管理Bro的安裝 - 啟動(dòng)和停止服務(wù),部署B(yǎng)ro以及執(zhí)行其他管理任務(wù)。它既是命令行工具又是一個(gè)交互式的shell。

如果使用sudo /usr/local/bro/bin/broctl調(diào)用broctl,它將啟動(dòng)一個(gè)交互式shell:

Welcome to BroControl 1.5-21

Type "help" for help.

[BroControl] >

你也可以使用exit命令退出交互式shell。

在shell中,你可以運(yùn)行任何有效的Bro命令。你也可以直接從命令行運(yùn)行相同的命令,而無(wú)需調(diào)用shell。在命令行運(yùn)行命令的一大優(yōu)勢(shì)就是,允許你將broctl命令的輸出通過(guò)管道,傳輸?shù)綐?biāo)準(zhǔn)Linux命令中。在接下來(lái)的部分,我們都將在命令行中調(diào)用broctl命令。

首先,我們使用broctl deploy啟動(dòng)Bro。

sudo /usr/local/bro/bin/broctl deploy

將Bro日志轉(zhuǎn)換為JSON

默認(rèn)情況下,Bro日志是TSV(制表符分隔值)文件! 但對(duì)于ElasticSearch而言,使用JSON文件可以更高效地運(yùn)行。

我們只需在/usr/share/bro/share/site/bro.local文件的末尾添加以下內(nèi)容即可:

@load tuning/json-logs
redef LogAscii::json_timestamps = JSON::TS_ISO8601;
redef LogAscii::use_json = T;

接著,我們重啟Bro?,F(xiàn)在,我們所有的日志文件都應(yīng)該已經(jīng)轉(zhuǎn)換為了JSON格式。

sudo /usr/local/bro/bin/broctl restart

Filebeat

首先,我們將原始的wazuh filebeat配置移動(dòng)到一個(gè)新創(chuàng)建的目錄conf.d。你只需復(fù)制以下命令即可:

cd /etc/filebeat
mkdir conf.d
mv filebeat.yml conf.d/
cat << EOF > filebeat.yml
filebeat:
  config_dir: /etc/filebeat/conf.d
output:
 logstash:
   # The Logstash hosts
   hosts: ["127.0.0.1:5000"]
EOF

然后,在/etc/filebeat/conf.d/filebeat_bro.yml中創(chuàng)建我們的bro filebeat配置:

filebeat:
 prospectors:
  - input_type: log
    paths:
     - "/usr/local/bro/spool/bro/conn.log"
    document_type: json
    json.message_key: log
    json.keys_under_root: true
    json.overwrite_keys: true

  - input_type: log
    paths:
     - "/usr/local/bro/spool/bro/dns.log"
    document_type: json
    json.message_key: log
    json.keys_under_root: true
    json.overwrite_keys: true

  - input_type: log
    paths:
     - "/usr/local/bro/spool/bro/http.log"
    document_type: json
    json.message_key: log
    json.keys_under_root: true
    json.overwrite_keys: true

  - input_type: log
    paths:
     - "/usr/local/bro/spool/bro/intel.log"
    document_type: json
    json.message_key: log
    json.keys_under_root: true
    json.overwrite_keys: true

# copy inputs to add additional bro logs as needed

output:
 logstash:
   # The Logstash hosts
   hosts: ["127.0.0.1:5001"]

Logstash

我們的Logstash配置/etc/logstash/conf.d/bro.conf:

input {
    beats {
        port => 5001
        codec => "json_lines"
    }
}

filter {

  #Let's get rid of those header lines; they begin with a hash
  if [message] =~ /^#/ {
    drop { }
  }

  #Now, using the csv filter, we can define the Bro log fields
  if [type] == "bro-conn_log" {
    csv {
      columns => ["ts","uid","id.orig_h","id.orig_p","id.resp_h","id.resp_p","proto","service","duration","orig_bytes","resp_bytes","conn_state","local_orig","missed_bytes","history","orig_pkts","orig_ip_bytes","resp_pkts","resp_ip_bytes","tunnel_parents"]

      #If you use a custom delimiter, change the following value in between the quotes to your delimiter. Otherwise, insert a literal <tab> in between the two quotes on your logstash system, use a text editor like nano that doesn't convert tabs to spaces.
      separator => "	"
    }

    #Let's convert our timestamp into the 'ts' field, so we can use Kibana features natively
    date {
      match => [ "ts", "UNIX" ]
    }

    # add geoip attributes
    geoip {
      source => "id.orig_h"
      target => "orig_geoip"
    }
    geoip {
      source => "id.resp_h"
      target => "resp_geoip"
    }

    #The following makes use of the translate filter (logstash contrib) to convert conn_state into human text. Saves having to look up values for packet introspection
    translate {
      field => "conn_state"

      destination => "conn_state_full"

      dictionary => [
                    "S0", "Connection attempt seen, no reply",
                    "S1", "Connection established, not terminated",
                    "S2", "Connection established and close attempt by originator seen (but no reply from responder)",
                    "S3", "Connection established and close attempt by responder seen (but no reply from originator)",
                    "SF", "Normal SYN/FIN completion",
                    "REJ", "Connection attempt rejected",
                    "RSTO", "Connection established, originator aborted (sent a RST)",
                    "RSTR", "Established, responder aborted",
                    "RSTOS0", "Originator sent a SYN followed by a RST, we never saw a SYN-ACK from the responder",
                    "RSTRH", "Responder sent a SYN ACK followed by a RST, we never saw a SYN from the (purported) originator",
                    "SH", "Originator sent a SYN followed by a FIN, we never saw a SYN ACK from the responder (hence the connection was 'half' open)",
        "SHR", "Responder sent a SYN ACK followed by a FIN, we never saw a SYN from the originator",
                    "OTH", "No SYN seen, just midstream traffic (a 'partial connection' that was not later closed)"
                    ]
    }

    mutate {
      convert => [ "id.orig_p", "integer" ]
      convert => [ "id.resp_p", "integer" ]
      convert => [ "orig_bytes", "integer" ]
      convert => [ "duration", "float" ]
      convert => [ "resp_bytes", "integer" ]
      convert => [ "missed_bytes", "integer" ]
      convert => [ "orig_pkts", "integer" ]
      convert => [ "orig_ip_bytes", "integer" ]
      convert => [ "resp_pkts", "integer" ]
      convert => [ "resp_ip_bytes", "integer" ]
      rename =>  [ "id.orig_h", "id_orig_host" ]
      rename =>  [ "id.orig_p", "id_orig_port" ]
      rename =>  [ "id.resp_h", "id_resp_host" ]
      rename =>  [ "id.resp_p", "id_resp_port" ]
    }
  }
}

output {
  #stdout { codec => rubydebug }
  elasticsearch {  
        hosts => ["localhost:9200"]
        index => "bro-conn-%{+YYYY.MM.dd}"
        document_type => "bro"
        template => "/etc/logstash/bro.json"
        template_name => "bro"
        template_overwrite => true
  }
}

我們的bro.json文件你可以在這里獲取到:https://gist.github.com/netscylla/27ac9e1472d89dffa5a8267a6af9c9be

最后,我們重啟logstash。

systemctl restart logstash

并檢查你的Kibana儀表板:

首先,我們轉(zhuǎn)到管理面板,然后單擊索引模式(index patterns),這將告訴kibana你的bro文件的位置,如下所示:

怎么通過(guò)Kibana、Wazuh和Bro IDS提高中小企業(yè)的威脅檢測(cè)能力

然后回到discover,你應(yīng)該能夠看到你的bro日志!

怎么通過(guò)Kibana、Wazuh和Bro IDS提高中小企業(yè)的威脅檢測(cè)能力

提取 - Bro和威脅情報(bào)

首先,我們?cè)谶@里進(jìn)行注冊(cè)以獲取免費(fèi)威脅情報(bào)源。

選擇你的Container,feeds 和 sensor(見(jiàn)以下的feeds截圖)。

怎么通過(guò)Kibana、Wazuh和Bro IDS提高中小企業(yè)的威脅檢測(cè)能力

你將看到一個(gè)api code,我們將其復(fù)制到剪貼板或記事本中。

遵循critical-stack-intel二進(jìn)制文件的客戶(hù)端安裝說(shuō)明進(jìn)行安裝:

然后使用api code(需要聯(lián)網(wǎng))將二進(jìn)制文件連接到feed,此時(shí)它應(yīng)該下載已訂閱的威脅情報(bào)源。

critical-stack-intel api [api_code_here]

并重啟bro

sudo /usr/local/bro/bin/broctl restart

使用以下命令列出feeds:

critical-stack-intel list

關(guān)于怎么通過(guò)Kibana、Wazuh和Bro IDS提高中小企業(yè)的威脅檢測(cè)能力就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI