栏目头部广告

CentOS7部署开源网络流量回溯分析系统Moloch

一、Moloch 简介

Moloch是一个由AOL开源,大规模,完整的数据包捕获,索引和数据库系统。 Moloch扩展了当前的安全基础架构,以标准PCAP格式存储和索引网络流量,提供快速的索引访问。为PCAP浏览,搜索和导出提供了直观简单的Web界面。 Moloch公开了API,允许直接下载和使用PCAP数据和JSON格式的会话数据。 Moloch以标准PCAP格式存储和导出所有数据包,使您在分析工作流程中也可以使用PCAP摄取工具,例如: Wireshark。

Moloch由以下三个部分组成

1)capture:绑定interface运行的单线程C语言应用

2)viewer:运行在capture主机上的node.js web应用

3)elasticsearch:moloch的数据检索驱动

官网下载地址:https://arkime.com/downloads

CentOS7部署开源网络流量回溯分析系统Moloch(图1)

二、安装部署

1、下载Moloch和elasticsearch安装包

Moloch官网:https://arkime.com/downloads

CentOS7部署开源网络流量回溯分析系统Moloch(图2)



[root@10-27-0-224 ~]# wget https://s3.amazonaws.com/files.molo.ch/builds/centos-7/moloch-2.4.1-1.x86_64.rpm

Elasticsearch官网:https://www.elastic.co/downloads/elasticsearch

CentOS7部署开源网络流量回溯分析系统Moloch(图3)

[root@10-27-0-224 ~]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.1-x86_64.rpm

2、安装并配置JDK环境变量

JDK下载地址

链接:https://pan.baidu.com/s/1wEBh1gMkXtJUNJGxsJXa3g 

提取码:ktfg 

[root@10-27-0-224 ~]# tar -zxvf jdk-8u181-linux-x64.tar.gz -C /usr/local/
[root@10-27-0-224 ~]# cd /usr/local/
[root@10-27-0-224 local]# mv jdk1.8.0_181/ jdk
[root@10-27-0-224 local]# echo "export JAVA_HOME=/usr/local/jdk" >>  /etc/profile.d/java8.sh
[root@10-27-0-224 local]# echo "export PATH=\$PATH:\$JAVA_HOME/bin" >>  /etc/profile.d/java8.sh
[root@10-27-0-224 local]# echo "export CLASSPATH=.:\$JAVA_HOME/jre/lib:\$JAVA_HOME/lib:\$JAVA_HOME/lib/tools.jar" >>  /etc/profile.d/java8.sh
[root@10-27-0-224 local]# source /etc/profile.d/java8.sh

3、安装并配置Elasticsearch

(1)安装elasticsearch,调整JVM内存大小

[root@10-27-0-224 ~]# rpm -ivh elasticsearch-7.9.1-x86_64.rpm 
[root@10-27-0-224 ~]# cd  /etc/elasticsearch/
[root@10-27-0-224 elasticsearch]# vim jvm.options

CentOS7部署开源网络流量回溯分析系统Moloch(图4)

CentOS7部署开源网络流量回溯分析系统Moloch(图5)

(2)修改elasticsearch配置文件

[root@10-27-0-224 elasticsearch]# cd /data
[root@10-27-0-224 data]# mkdir /data/elasticsearch
[root@10-27-0-224 data]# mkdir -p /data/log/elasticsearch
[root@10-27-0-224 data]# chown -R elasticsearch:elasticsearch elasticsearch
[root@10-27-0-224 data]# chown -R elasticsearch:elasticsearch log

[root@10-27-0-224 ~]# vim /etc/elasticsearch/elasticsearch.yml
path.data: /data/elasticsearch
path.logs: /data/log/elasticsearch
network.host:10.27.0.224
http.port:9200
discovery.seed_hosts: ["10.27.0.224"]

(3)启动elasticsearch

[root@10-27-0-224 ~]# systemctl daemon-reload
[root@10-27-0-224 ~]# systemctl enable elasticsearch.service
[root@10-27-0-224 ~]# systemctl start elasticsearch.service

[root@10-27-0-224 ~]# curl http://10.27.0.224:9200
{
  "name" : "10-27-0-224",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "_na_",
  "version" : {
    "number" : "7.9.1",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "083627f112ba94dffc1232e8b42b73492789ef91",
    "build_date" : "2020-09-01T21:22:21.964974Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

3、安装配置Moloch

安装Moloch,初始化配置

[root@10-27-0-224 ~]# yum localinstall moloch-2.4.1-1.x86_64.rpm
[root@10-27-0-224 ~]# cd /data/moloch/bin
[root@10-27-0-224 bin]# ./Configure
Found interfaces: eth0;lo
Semicolon ';' seperated list of interfaces to monitor [eth1] eth0 #监控的网卡也就是镜像流量对应的网卡
Install Elasticsearch server locally for demo, must have at least 3G of memory, NOT recommended for production use (yes or no) [no] no
Elasticsearch server URL [http://localhost:9200] http://10.27.0.224:9200
Password to encrypt S2S and other things [no-default] moloch
Moloch - Creating configuration files
Installing systemd start files, use systemctl
Moloch - Installing /etc/logrotate.d/moloch to rotate files after 7 days
Moloch - Installing /etc/security/limits.d/99-moloch.conf to make core and memlock unlimited
Download GEO files? (yes or no) [yes] yes
Moloch - Downloading GEO files
2021-04-10 10:12:28 URL:https://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.csv [23328/23328] -> "/tmp/tmp.zU5VX6yoFl" [1]
2021-04-10 10:12:28 URL:https://raw.githubusercontent.com/wireshark/wireshark/master/manuf [1831086/1831086] -> "/tmp/tmp.6Xl3O1mgqQ" [1]
Received Error -21 (Sanity check database_info string failed) when attempting to update GeoIP Database
Received Error -21 (Sanity check database_info string failed) when attempting to update GeoIP Database

Moloch - Configured - Now continue with step 4 in /data/moloch/README.txt

      /sbin/start elasticsearch # for upstart/Centos 6/Ubuntu 14.04
      systemctl start elasticsearch.service # for systemd/Centos 7/Ubuntu 16.04
 5) Initialize/Upgrade Elasticsearch Moloch configuration
  a) If this is the first install, or want to delete all data
      /data/moloch/db/db.pl http://ESHOST:9200 init
  b) If this is an update to moloch package
      /data/moloch/db/db.pl http://ESHOST:9200 upgrade
 6) Add an admin user if a new install or after an init
      /data/moloch/bin/moloch_add_user.sh admin "Admin User" THEPASSWORD --admin
 7) Start everything
   a) If using upstart (Centos 6 or sometimes Ubuntu 14.04):
      /sbin/start molochcapture
      /sbin/start molochviewer
   b) If using systemd (Centos 7 or Ubuntu 16.04 or sometimes Ubuntu 14.04)
      systemctl start molochcapture.service
      systemctl start molochviewer.service
 8) Look at log files for errors
      /data/moloch/logs/viewer.log
      /data/moloch/logs/capture.log
 9) Visit http://MOLOCHHOST:8005 with your favorite browser.
      user: admin
      password: THEPASSWORD from step #6

If you want IP -> Geo/ASN to work, you need to setup a maxmind account and the geoipupdate program.
See https://molo.ch/faq#maxmind

Any configuration changes can be made to /data/moloch/etc/config.ini
See https://molo.ch/faq#moloch-is-not-working for issues

Additional information can be found at:
  * https://molo.ch/faq
  * https://molo.ch/settings

出现如下报错时 Couldn't GET

[root@10-27-0-224 ~]# /data/moloch/db/db.pl http://10.27.0.224:9200 init
Couldn't GET http://10.27.0.224:9200/_cluster/health  the http status code is 503 are you sure elasticsearch is running/reachable? at
 /data/moloch/db/db.pl line 280.

解决方案

[root@10-27-0-224 ~]# vim /etc/elasticsearch/elasticsearch.yml
node.name: es-node-stargao
cluster.initial_master_nodes: ["es-node-stargao"]
[root@10-27-0-224 ~]# systemctl restart elasticsearch.service

继续初始化配置

[root@10-27-0-224 ~]# /data/moloch/db/db.pl http://10.27.0.224:9200 init
It is STRONGLY recommended that you stop ALL moloch captures and viewers before proceeding.  Use 'db.pl http://10.27.0.224:9200 backup' to backup db first.
There is 1 elastic search data node, if you expect more please fix first before proceeding.
This is a fresh Moloch install
Erasing
Creating
Finished

[root@10-27-0-224 ~]# vim /etc/elasticsearch/elasticsearch.yml
node.name: es-node-stargao
cluster.initial_master_nodes: ["es-node-stargao"]
[root@10-27-0-224 ~]# systemctl restart elasticsearch.service

[root@10-27-0-224 ~]# /data/moloch/bin/moloch_add_user.sh admin "Admin User" admin --admin
Added
[root@10-27-0-224 ~]# systemctl start molochcapture.service
[root@10-27-0-224 ~]# systemctl start molochviewer.service
[root@10-27-0-224 ~]# netstat -anp | grep 8005
tcp6       0      0 :::8005                 :::*                    LISTEN      3403/node

4、web登录并体验Moloch

http://IP:8005/

CentOS7部署开源网络流量回溯分析系统Moloch(图6)

CentOS7部署开源网络流量回溯分析系统Moloch(图7)

CentOS7部署开源网络流量回溯分析系统Moloch(图8)

5、开启镜像网卡的混杂模式

[root@10-27-0-224 ~]# ifconfig eth0 promisc

CentOS7部署开源网络流量回溯分析系统Moloch(图9)

作者:UStarGao
链接:https://www.starcto.com/safetool/126.html
来源:STARCTO
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处

UCloud云平台推荐


UCloud新用户专属注册连接

UCloud CDN超值特惠专场

UCloud全球云主机(UHost/VPS)大促页面

UCloud快杰云主机大促页面

加载中~
文章详情页广告

随便看看

底部广告
`