Moloch是一个开源,大规模,完整的数据包捕获,索引和数据库系统,以标准PCAP格式存储和索引网络流量,提供快速的索引访问,允许用户直接下载PCAP数据和JSON格式的会话数据。
1 、安装前准备
(1)关闭防火墙
[root@centos ~]#systemctl stop firewalld.service #关闭防火墙
[root@centos ~]#systemctl disable firewalld.service #禁止重启后启动防火墙
(2)关闭SELINUX
[root@centos ~]#setenforce 0 #关闭SELINUX
[root@centos ~]#sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config #禁止重启后SELINUX启动
(3)检查Moloch和ES组件是否安装
# 检查是否已经安装ES
[root@centos ~]#rpm -qa | grep elasticsearch
#检查moloch是否安装
[root@centos ~]#rpm -qa | grep moloch
2.下载离线安装包及依赖
在外网centos机器上,下载jdk1.8、ES、Moloch及依赖安装包。
[root@centos ~]#mkdir -p /home/rpms #创建依赖包缓存目录
[root@centos ~]#yum reinstall --downloadonly --downloaddir=/home/rpms wget curl perl-JSON perl-libwww-perl libyaml-devel #下载依赖包
[root@centos ~]#cd /home
[root@centos home]#wget http://iso.epoint.com.cn/JDK/jdk-8u65-linux-x64.rpm #下载jdk1.8
[root@centos home]#wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.6.rpm #下载elasticsearch
[root@centos home]#wget https://s3.amazonaws.com/files.molo.ch/builds/centos-7/moloch-2.4.0-1.x86_64.rpm # Moloch下载
[root@centos home]#wget https://linuxnet.ca/ieee/oui.txt #下载MAC组织信息
[root@centos home]#wget http://www.iana.org/assignments/ipv4-recovered-address-space/ipv4-recovered-address-space-2.csv #下载IP注册地址信息
3.安装离线安装包及依赖包
拷贝外网centos机器home目录下的,jdk1.8、ES、Moloch及依赖安装包到内网服务器home目录。安装步骤如下:
(1)安装jdk和Moloch依赖包
[root@centos ~]#cd /home/rpms
[root@centos rpms]#rpm -Uvh ./*.rpm --nodeps --force #安装依赖包
[root@centos rpms]#cd /home
[root@centos home]#rpm -ivh jdk-8u65-linux-x64.rpm #安装jdk1.8
(2)安装elasticsearch
安装ES离线包
[root@centos home]#rpm -ivh elasticsearch-6.8.0.rpm
修改配置文件
[root@centos home]#vi /etc/elasticsearch/elasticsearch.yml修改配置项如下:
#-----node------
namenode= node-1
#-----paths-----
path.data: /home/esdata/data
path.logs: /home/esdata/logs
#-----network----
network.host: 0.0.0.0
discovery.seed_hosts: ["0.0.0.0"]
http.port: 9200
#-----Discovery------
cluster.initial_master_nodes: ["node-1"]
#-----Various-------
http.cors.enabled : true
http.cors.allow-origin : "*"
http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type, Content-Length
修改esdata目录权限
[root@centos home]#chmod 777 /home/esdata
启动ES服务
[root@centos home]#systemctl daemon-reload #重载配置文件
[root@centos home]#systemctl enable elasticsearch.service #设置开机启动elasticsearch
[root@centos home]#systemctl start elasticsearch.service #启动elasticsearch服务
检测ES状态
[root@centos home]#systemctl status elasticsearch.service #查看启动状态
在浏览器上测试,查看https://服务器IP:9200能否访问到,及https://服务器IP:9200/_cluster/health是否返回正常。

(3)安装Moloch
安装Moloch离线包
[root@centos home]#rpm -ivh moloch-2.4.0-1.x86_64.rpm
配置moloch
执行/data/moloch/bin/Configure配置文件,配置如下:

Moloch抓包网卡设置优化
[root@centos home]#ethtool -g eno1
Ring parameters for eth0:
Pre-set maximums:
RX: 4096
RX Mini: 0
RX Jumbo: 0
TX: 4096
Current hardware settings:
RX: 256
RX Mini: 0
RX Jumbo: 0
TX: 256
[root@centos home]#ethtool -G eno1 rx 4096 tx 4096
[root@centos home]#ethtool -K rx off tx off tso off gso off
添加IP和MAC区域配置
cp /home/ipv4-address-space.csv /data/moloch/etc/
cp /home/oui.txt /data/moloch/etc/
初始化Moloch
/data/moloch/db/db.pl http://服务器IP:9200 init
/data/moloch/db/db.pl http://服务器IP:9200 upgrate
添加Moloch登录用户
/data/moloch/bin/moloch_add_user.sh admin "Admin User" admin --admin
开启Moloch服务
systemctl enable molochcapture.service #添加开机启动Capture服务
systemctl start molochcapture.service #启动Capture服务
systemctl enable molochviewer.service #添加开机启动Viewer服务
systemctl start molochviewer.service #启动Viewer服务
登录moloch
浏览器访问http://服务器IP:8005,输入前面创建的Moloch用户名和密码登录。

上传pcap包离线解析
创建目录/data/pcaps,将test.pcap包上传到该目录下,执行以下命令进行离线解析。
/data/moloch/bin/moloch-capture --copy -n 192.168.1.85 -r /data/pcaps/test.pcap
网友评论