這几天在玩MHN
感覺還不錯
不過有些地方要注意
試了好久
首先裝server
依照官網的說明沒什麼問題
我是用 ubuntu 18.04
再來是佈署 sensor
網頁介面上有提供deploy的script
官網上有提到有些sensor可以裝在centos
不過網頁介面上的都是for ubuntu跟 respberry pi
有很多sensor可以選擇
不同sensor有不同的功能
不過不是每個都可以用
這地方試了好久
最後我選了 Dionaea
官網上是說只能裝在 Ubuntu 14.04/Centos 7
其他版本有問題
不過我裝在ubuntu 18.04是ok的
只是安裝過程中碰到以下的問題
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/libe/libemu/libemu2_0.2.0+git20120122-1.2build1_amd64.deb 403 Forbidden [IP: 91.189.88.173 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
最後解決的方法是直接下載這個檔然後 dpkg -i
之後就沒問題了
介面還可以接受
資料是放在mongodb裡
也提供 rest可以撈
不過沒找到完整文件
另外就是直接使用mongoexport把資料撈出來
要注意的是mongodb時間是ISODate
如果用bash shell要記得轉換時間
date -u -Ins
每十分鐘從mongodb撈出資料
#!/bin/bash
date -d '10 mins ago' -u -Ins |cut -d ',' -f 1 > /tmp/time
echo "DBQuery.shellBatchSize = 3000000" > /tmp/get10min.js
echo "use mnemosyne" >> /tmp/get10min.js
echo 'db.session.find({"timestamp":{$gt:ISODate("'`cat /tmp/time`'")}})' >> /tmp/get10min.js
mongo < /tmp/get10min.js > /tmp/mhn_10min_data
https://github.com/pwnlandia/mhn
https://github.com/pwnlandia/mhn/wiki/List-of-Supported-Sensors
https://github.com/pwnlandia/mhn/wiki/MHN-REST-APIs
https://github.com/pwnlandia/mhn/wiki/Exporting-Honeypot-Data-from-MHN
https://www.itread01.com/content/1545640216.html
2019/11/22
2019/11/21
2019/11/13
今天在使用mutt時一直出現以下的錯誤
找了半天還是沒有答案
mutt -s 'test' abc@de.com -a /tmp/test < test
SMTP session failed: 500 5.5.2 Error: bad UTF-8 syntax
Could not send the message.
改用
/usr/bin/mail -a /tmp/test1 -a /tmp/test2 -S smtp="10.0.0.1:25" -r "from@dde.com" -s 'test' to@de.com < test
https://www.binarytides.com/linux-mailx-command/
找了半天還是沒有答案
mutt -s 'test' abc@de.com -a /tmp/test < test
SMTP session failed: 500 5.5.2 Error: bad UTF-8 syntax
Could not send the message.
改用
/usr/bin/mail -a /tmp/test1 -a /tmp/test2 -S smtp="10.0.0.1:25" -r "from@dde.com" -s 'test' to@de.com < test
https://www.binarytides.com/linux-mailx-command/
2019/11/06
2019/11/01
今天模擬在一台graylog server 三個ES node的環境
然後當有一台ES fail時要怎麼處理
首先我們先看一下目前ES的狀況
有三個node
status也是green
curl -XGET http://192.168.12.201:9200/_cluster/health?pretty
{
"cluster_name" : "graylog",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 3,
"number_of_data_nodes" : 3,
"active_primary_shards" : 11,
"active_shards" : 14,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
再來看一下目前所有shards的狀況
curl -XGET 192.168.12.203:9200/_cat/shards
gl-events_0 3 p STARTED 0 230b 192.168.12.202 es-node-02
gl-events_0 2 p STARTED 0 230b 192.168.12.201 es-node-1
gl-events_0 1 p STARTED 0 230b 192.168.12.203 es-node-03
gl-events_0 0 p STARTED 0 230b 192.168.12.202 es-node-02
graylog_3 2 r STARTED 1 7kb 192.168.12.203 es-node-03
graylog_3 2 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 1 r STARTED 1 7kb 192.168.12.202 es-node-02
graylog_3 1 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 0 p STARTED 1 7kb 192.168.12.202 es-node-02
graylog_3 0 r STARTED 1 7kb 192.168.12.203 es-node-03
gl-system-events_0 3 p STARTED 0 230b 192.168.12.203 es-node-03
gl-system-events_0 2 p STARTED 0 230b 192.168.12.202 es-node-02
gl-system-events_0 1 p STARTED 0 230b 192.168.12.201 es-node-1
gl-system-events_0 0 p STARTED 0 230b 192.168.12.203 es-node-03
我們關掉其中一個ES node 192.168.12.202 模擬故障
查看整個cluster狀況
nodes變成2
status也變為red
curl -XGET http://192.168.12.201:9200/_cluster/health?pretty
{
"cluster_name" : "graylog",
"status" : "red",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 2,
"active_primary_shards" : 8,
"active_shards" : 9,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 5,
"delayed_unassigned_shards" : 5,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 64.28571428571429
}
再來看一下shards的狀況
192.168.12.202這個node己經不見了
而且上面的shards 變成 UNASSIGNED
curl -XGET 192.168.12.203:9200/_cat/shards
gl-system-events_0 3 p STARTED 0 261b 192.168.12.203 es-node-03
gl-system-events_0 2 p UNASSIGNED
gl-system-events_0 1 p STARTED 0 261b 192.168.12.201 es-node-1
gl-system-events_0 0 p STARTED 0 261b 192.168.12.203 es-node-03
graylog_3 2 r STARTED 1 7kb 192.168.12.203 es-node-03
graylog_3 2 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 1 r STARTED 1 7kb 192.168.12.203 es-node-03
graylog_3 1 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 0 p STARTED 1 7kb 192.168.12.203 es-node-03
graylog_3 0 r STARTED 1 7kb 192.168.12.201 es-node-1
gl-events_0 3 p UNASSIGNED
gl-events_0 2 p STARTED 0 261b 192.168.12.201 es-node-1
gl-events_0 1 p STARTED 0 261b 192.168.12.203 es-node-03
gl-events_0 0 p UNASSIGNED
找一台机器重裝ES後並重新加入cluster
先看一下狀況
nodes己經回來變成3了
可是status還是red
curl -XGET http://192.168.12.201:9200/_cluster/health?pretty
{
"cluster_name" : "graylog",
"status" : "red",
"timed_out" : false,
"number_of_nodes" : 3,
"number_of_data_nodes" : 3,
"active_primary_shards" : 8,
"active_shards" : 11,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 3,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 78.57142857142857
}
再來看shards的狀況
還是 UNASSIGNED 並沒有復原
curl -XGET 192.168.12.203:9200/_cat/shards
gl-system-events_0 3 p STARTED 0 261b 192.168.12.203 es-node-03
gl-system-events_0 2 p UNASSIGNED
gl-system-events_0 1 p STARTED 0 261b 192.168.12.201 es-node-1
gl-system-events_0 0 p STARTED 0 261b 192.168.12.203 es-node-03
graylog_3 2 r STARTED 1 7kb 192.168.12.203 es-node-03
graylog_3 2 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 1 r STARTED 1 7kb 192.168.12.203 es-node-03
graylog_3 1 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 0 p STARTED 1 7kb 192.168.12.203 es-node-03
graylog_3 0 r STARTED 1 7kb 192.168.12.201 es-node-1
gl-events_0 3 p UNASSIGNED
gl-events_0 2 p STARTED 0 261b 192.168.12.201 es-node-1
gl-events_0 1 p STARTED 0 261b 192.168.12.203 es-node-03
gl-events_0 0 p UNASSIGNED
查了資料說可以 reroute share
但實作上有問題無法執行
目前試出來的做法是先關掉graylog server
systemctl stop graylog-server.service
接下來把所有的 UNASSIGNED 砍了
curl -XDELETE '192.168.12.201:9200/gl-system-events_0/'
curl -XDELETE '192.168.12.201:9200/gl-events_0'
砍完後再去看shards
curl -XGET 192.168.12.203:9200/_cat/shards
graylog_3 2 r STARTED 1 7kb 192.168.12.203 es-node-03
graylog_3 2 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 1 r STARTED 1 7kb 192.168.12.202 es-node-02
graylog_3 1 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 0 r STARTED 1 7kb 192.168.12.202 es-node-02
graylog_3 0 p STARTED 1 7kb 192.168.12.203 es-node-03
這個是原本的資料檔
而且有設定 Index replicas
重啟graylog server
graylog會把剛剛砍掉的 gl-system-events_0 gl-events_0 建回來
收集的資料是放在 graylog_* 所以不會有影響
再看一次shards
全部都正常了
curl -XGET 192.168.12.203:9200/_cat/shards
gl-system-events_0 3 p STARTED 0 230b 192.168.12.203 es-node-03
gl-system-events_0 2 p STARTED 0 230b 192.168.12.202 es-node-02
gl-system-events_0 1 p STARTED 0 230b 192.168.12.201 es-node-1
gl-system-events_0 0 p STARTED 0 230b 192.168.12.203 es-node-03
graylog_3 2 r STARTED 1 7kb 192.168.12.203 es-node-03
graylog_3 2 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 1 r STARTED 1 7kb 192.168.12.202 es-node-02
graylog_3 1 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 0 r STARTED 1 7kb 192.168.12.202 es-node-02
graylog_3 0 p STARTED 1 7kb 192.168.12.203 es-node-03
gl-events_0 3 p STARTED 0 230b 192.168.12.202 es-node-02
gl-events_0 2 p STARTED 0 230b 192.168.12.201 es-node-1
gl-events_0 1 p STARTED 0 230b 192.168.12.203 es-node-03
gl-events_0 0 p STARTED 0 230b 192.168.12.202 es-node-02
所以記得 Configure Index Set 要設定Index replicas 至少為1
Index shards的數量就根据你ES node的數量來設定
如果ES node 有三個 就設定為3
訂閱:
文章 (Atom)