作者:
RipZ
·
2016/05/30 10:36
0x00 前言
本文將以連載的形式分享splunk在實戰中的運用:從索引器&轉發器的安裝部署開始,到普通搜尋&欄位提取,再到報表&儀表盤定製以及告警等,詳細的寫出作者在實戰中的經驗(其實是遇到的坑),讓大家看完之後可以少走些彎路。
0x01 Splunk簡述
什麼是Splunk?
Splunk是機器資料的引擎。使用 Splunk 可收集、索引和利用所有應用程式、伺服器和裝置(物理、虛擬和雲中)生成的快速移動型計算機資料,隨時從一個位置搜尋並分析所有實時和歷史資料。使用 Splunk可以在幾分鐘內(而不是幾個小時或幾天)解決問題和調查安全事件,關聯並分析跨越多個系統的複雜事件,從而獲取新層次的安全運營以及業務運營可見性。

Splunk的強大之處
Splunk 可以從任何源實時索引任何型別的計算機資料,由下圖可見,透過埠監聽來收集各類伺服器或者網路裝置的日誌,還可以透過指令碼來獲取系統指標等。

同時,可以透過在各個作業系統安裝部署轉發器(forwarder),來實現將各個agent端日誌目錄檔案傳送到splunk索引器(indexer)中。下圖最底層為forwarder,中間層為indexer。

簡要介紹了一下整體架構,下面我們進入實戰環節。
0x02 環境準備
Splunk索引器
6.3.3版本,IP為10.2.1.157
Splunk轉發器
Linux&windows的6.3.3版本
0x03 索引器配置
索引器端需要配置監聽埠,以便接收從轉發器端發來的日誌檔案等。在“設定——轉發和接收——接收資料”中配置監聽9997埠


另外索引器預設的管理埠是8089,無需配置。

0x04 Windows轉發器配置
準備工作
- splunk轉發器下載地址
https://www.splunk.com/page/previous_releases/universalforwarder
需要在windows server上將”本地安全策略——本地策略——稽核策略”中的所有稽核策略均配置為”成功“和失敗”

安裝過程
首先複製轉發器到相應的伺服器上

雙擊執行該檔案,如下圖所示,勾選接受協議,之後選擇“Customize Options”即自定義安裝

路徑預設即可

勾選上“windows Event Logs”以及“Performance Monitor”的全部選項,但不用勾選”AD monitoring”(否則如果在域環境下,索引器會收到大量域內無用訊息,極為佔用資源),如下圖。

這個步驟預設即可。

(重要!)配置排程伺服器(這一步是為了讓indexer可以識別到forwarder,並且可以從管理端下發日誌採集指令)。 這一步中的IP填寫為10.2.1.157,埠填寫為8089,如下圖。

(重要!)這一步中配置接收索引器(這一步是為了讓indexer可以接收到forwarder發來的日誌),IP填寫為10.2.1.157,埠填寫為9997。

執行安裝過程完畢後,點選Finish結束。

最後在索引器中可以看到該轉發器已連線上

0x05 Linux轉發器配置
安裝過程
首先檢視當前IP。

從內網伺服器下載壓縮包:
#!shell
wget http://10.2.24.66/splunkforwarder-Linux.tgz

解壓。

進入%splunkforwarder%/bin

輸入./splunk start
進行安裝

輸入y,等待安裝完成。

輸入./splunk enable boot-start
,配置為開機啟動

(重要!)配置排程伺服器(這一步是為了讓indexer可以識別到forwarder,並且可以從管理端下發日誌採集指令)。
遇到的坑:6.3.3的轉發器安裝貌似沒法透過輸入命令來指定對端索引器,如果不搞配置檔案的話,索引器是無法感知到這個轉發器的。
隨後在%splunkforwarder%/etc/system/local/
配置deploymentclient.conf
其檔案內容格式為:
[target-broker:deploymentServer]
targetUri = 10.2.1.157:8089
如下配置即為成功

(重要!)這一步中配置接收索引器(這一步是為了讓indexer可以接收到forwarder發來的日誌)
另外需要在%splunkforwarder%/etc/system/local/
配置outputs.conf
[tcpout]
defaultGroup = defau;lt-autolb-group
[tcpout:default-autolb-group]
server = 10.2.1.157:9997
[tcpout-server://10.2.1.157:9997]
如下配置即為成功

配置完conf檔案後需要重啟splunk服務

另外,還需要配置/etc/rsyslog.conf
,設定接收syslog條目為:(為了實現索引分類,這裡我將linux的syslog指定發到索引器的516埠)
* @10.2.1.157:516


配置完畢後儲存退出,並且重啟rsyslog服務。

至此,linux端轉發器配置完畢。
隨後可看到在server端伺服器列表中,該轉發器已連線上。

0x06 新增轉發器中的資料
首先選擇“設定——資料匯入“

選擇新增來自於轉發器的資料——windows事件日誌

新建一個伺服器組

由於目前只關心安全日誌,只選security即可,如下圖。

將這些轉發器的上述配置好的日誌均傳送到自己新建的windows索引中,以免在超大的main索引裡查詢導致效率下降。

同理,在”新增資料——檔案和目錄”功能中,可以直接匯入轉發器的IIS或tomcat等日誌目錄所在的路徑,配置完畢後由轉發器自動將日誌發到索引器上來(好像遠控有木有)

再將不同類別的日誌存放到相應的索引中即可。

最後在搜尋時輸入index=windows或者index=iis,即可搜到所有轉發器發來的日誌了。

另外,在上一章節中所配置的linux syslog已經傳送到了516埠,所以在這裡我們新建一個監聽UDP:516的規則

並建立一個單獨的linux索引來儲存發到516埠的UDP資料(即syslog),屆時直接搜尋index=linux即可。
0x07 簡單的報表示例
統計暴力破解SSH的源IP
先透過linux登入失敗的特徵欄位“failed password”來查詢,同時,linux的日誌均在名為linux的索引表中,故應該搜尋:index=linux failed password。如下圖

之後想要統計來源的IP都有哪些,此時點選左側的“Src_ip”,選擇”上限值”,即為發生次數最多的前20個。

可以自動生成統計圖,直觀展示哪些源IP的次數最多。

之後將Src_ip改為Dst_ip,可以觀察哪些linux伺服器正遭受暴力破解的威脅。

至於上面說的Src_ip和Dst_ip是怎麼分割出來的,且聽下回分解《搜尋技巧&欄位提取》。
本文章來源於烏雲知識庫,此映象為了方便大家學習研究,文章版權歸烏雲知識庫!