1.1 编写目的
本文主要介绍开源IVRE项目的安装、部署和配置。目的是提供给IVRE项目学习、研究人员,利于他们更快的搭建和部署IVRE。
1.2 背景
IVRE(又名DRUNK)是一款网络侦查框架,包括两个基于p0f和Bro的被动侦查模块和一个基于Nmap&Zmap的主动侦查模块,其功能类似于国内知道创宇公司推出的一款网络空间搜索引擎ZoomEye(钟馗之眼)。
1.3 定义
Docker:一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口(类似 iPhone 的 app)。几乎没有性能开销,可以很容易地在机器和数据中心中运行。最重要的是,他们不依赖于任何语言、框架包括系统。
1.4 参考资料
安装Docker:
http://www.cnblogs.com/MicroTeam/p/see-docker-run-in-debian-with-aliyun-ecs.html
IVRE官方网站:
GitHub
https://github.com/cea-sec/ivre
2 系统配置
2.1 运行环境
Ubuntu Server 14.4 64位
Docker
IVRE
2.2 系统依赖
Python 2, version 2.6 minimum
the Crypto module
the pymongo module, version 2.7.2 minimum.
Nmap & ZMap
Bro & p0f
MongoDB, version 2.6 minimum
web服务器(在Apache、Nginx下测试通过)
web浏览器(在FireFox和Chromum下测试通过)
Maxmind GeoIP免费数据库
Tesseract(可选,可对Nmap扫描结果增加快照)
Docker & Vagrant (version 1.6 minimum,可选)
安装缺失Python模块
apt-get update apt-get install bison cmake gcc gcc+ flex g++ gdb make libmagic-dev libgeoip-dev libssl-dev python-dev swig2.0 zlib1g-dev libgmp3-dev libpcap-dev gengetopt apt-get install python-pip apt-get install python-dev apt-get install libkrb5-dev pip install python-krbv python3-dev python3-setuptools libtiff5-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev tcl8.6-dev tk8.6-dev python3-tk pip install Pillow python -m pip install pymongo wget https://github.com/zmap/zmap/archive/v1.0.3.tar.gz #为了方便识别,重命名一下 mv v1.0.3.tar.gz zmap-v1.0.3.tar.gz tar -zxvf zmap-v1.0.3.tar.gz cd zmap-1.0.3/ cd src make make install
安装npm 首先,需要安装PPA以获取对它的内容的访问权限:
curl -sL https://deb.nodesource.com/setup_9.x | sudo bash -
然后
apt-get install -y nodejs
安装用于安装nodejs的模块n
npm install -g n
安装Bro及nmap
git clone --recursive git://git.bro.org/bro
cd bro
./configure
make
make install
export PATH=/usr/local/bro/bin:$PATH
apt-get install nmap
apt-get install zmap
apt-get install p0f
详细部署内容见 https://www.howtoing.com/how-to-install-bro-on-ubuntu-16-04
2.3 前端组件
AngularJS
Twitter Bootstrap
jQuery
D3.js
flag-icon-css
Passive recon
程序部署
3.1 安装Docker
快速安装Docker方法有2种:
第一种方法:
wget -qO- https://get.docker.com/ | sh
第二种方法:
curl -sSL https://get.docker.com/ | sh
3.2 验证Docker安装是否成功(可忽略)
运行 hello world:
docker run hello-world
如果前面步骤都没有问题的话,能看到 hello-world 启动了。
Hello from Docker.
This message shows that your installation appears to be working correctly.
3.3 把非管理员用户添加到docker组
useradd -G docker 登陆系统用户名
3.4 安装Vagrant
apt-get install rubygems-integration apt-get -y install ruby rubygems
具体的安装Vagrant参考 https://blog.csdn.net/thone00/article/details/80482529
安装IVRE方法有以下:
第一种方法:(推荐使用)
wget https://releases.hashicorp.com/vagrant/1.7.4/vagrant_1.7.4_x86_64.deb dpkg -i vagrant_1.7.4_x86_64.deb
第二种方法:
apt-get install -y vagrant
3.5 安装IVRE
$ mkdir -m 1777 var_lib_mongodb var_log_mongodb ivre-share $ wget -q https://ivre.rocks/Vagrantfile $ vagrant up --no-parallel $ docker attach ivreclient
我自己搭建的IVRE分为三个部分,ivre/web、ivre/db、ivre/client,前面的部署环境和依赖包一样,输入以下命令在线进行镜像的拉取【注意root权限】:
安装docker
sudo apt-get install apt-transport-https sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 sudo bash -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" sudo apt-get update sudo apt-get install lxc-docker
镜像拉取
for img in agent base client db web ; do
docker pull "ivre/$img"
done
完成以后就可以运行,我们先创建几个目录来存取MongoDB的数据
$ mkdir -m 1777 var_{lib,log}_{mongodb,neo4j}
运行一个MongoDB的实例ivre/db,这个是对数据库进行管理的:
$ docker run -d --name ivredb --hostname ivredb \
--volume "`pwd`/var_lib_mongodb":/var/lib/mongodb \
--volume "`pwd`/var_log_mongodb":/var/log/mongodb \
ivre/db
运行一个Web Server(默认是80端口,可以自己修改),也就是ivre/web,是配置网页的
$ docker run -d --name ivreweb --hostname ivreweb \
--link ivredb:ivredb --publish 80:80 ivre/web
最后运行ivre/client,我们的扫描等大部分设置在这个命令下完成,就是一个shell:
$ docker run -i -t --name ivreclient --hostname ivreclient \
--link ivredb:ivredb --volume "`pwd`/ivre-share":/ivre-share \
ivre/client
进行数据库的初始化
ivre ipinfo --init
This will remove any passive information in your database. Process ? [y/N] y
ivre ipdata --init
This will remove any country/AS information in your database. Process ? [y/N] y
ivre scancli --init
This will remove any scan result in your database. Process ? [y/N] y
ivre runscansagentdb --init
This will remove any agent and/or scan in your database and files. Process ? [y/N] y
ivre ipdata --download --import-all --no-update-passive-db
扫描结果为0时 手动执行
# ivre runscans --routable --limit 1000 --output=XMLFork
$ ivre nmap2db -c ROUTABLE-CAMPAIGN-001 -s MySource -r scans/ROUTABLE/up
这个执行完需要很长的时间,跟网络有很大关系。
到此基本搭建完成,大家访问地址就能看到web页面了~~通过Docker装好的IVRE是没有数据的。
首先开启ivre/db:
sudo docker start -i YOUR CONTAINER ID FOR IVRE/DB
然后开启ivre/web:
sudo docker start -i YOUR CONTAINER ID FOR IVRE/WEB
最后开启ivre/client:
sudo docker start -i YOUR CONTAINER ID FOR IVRE/CLIENT
docker容器开启完毕。你可以在ivre/client中进行扫描~~~~
进入到ivre/client容器中以后,输入以下命令:
ivre runscans --range 192.168.0.1 192.168.0.254 --output=XML
扫描器就会自己开始扫描IP从192.168.0.1到192.168.0.254之间的所有的主机,当然,会扫的慢,这取决于你的带宽还有你的配置~扫描结束以后,你需要把.xml的结果导入到数据库中
cd scans/
scans# cd RANGE-192.168.0.1-192.168.0.254
scans/RANGE-192.168.0.1-192.168.0.254 # cd up
scans/RANGE-192.168.0.1-192.168.0.254/up# (一直cd进去,直到看到.xml的文件,一般有很多)
最后执行
ivre scan2db -c ROUTABLE,ROUTABLE-001 -s MySource -r scans/RANGE-(你那个很长的路径)/
结果就被导入了!(ROUTABLE和ROUTABLE-001都是自己定的名字,方便自己识别,那个MySource也是自己起的名字)
这时候,刷新你的web页面就能看到扫描的结果~
3.6IVRE运行和停止
查看docker有那些容器,命令:
docker ps –a
开启IVRE分三步,
第一步要开启database server,命令:
sudo docker start ivredb
第二步开启web,命令:
sudo docker start ivreweb
第三步开启客户端,命令:
sudo docker start ivreclient
然后通过attach命令进入ivreclient
sudo docker attach ivreclient
3.7 IVRE扫描并导入数据
通过attach命令进入ivreclient
sudo docker attach ivreclient
3.8运行如下初始化命令:(前4步可忽略)
ipinfo --init This will remove any passive information in your database. Process ? [y/N] y ipdata --init This will remove any country/AS information in your database. Process ? [y/N] y scancli --init This will remove any scan result in your database. Process ? [y/N] y runscans-agentdb --init This will remove any agent and/or scan in your database and files. Process ? [y/N] y ipdata --download --import-all --dont-feed-ipdata-cols [...] The latest command will take a long time. Then we can integrate the Nmap results to the database: nmap2db -r -s MySource -c MyCategory /ivre-share You can then exit the shell (`C-d`), this will stop the container.
或者忽略5.1步骤执行如下命令:
ipdata --download
在说扫描之前,我还是啰嗦一下吧,我们使用docker搭建完成以后,其实是有三个容器在里面,分别就是ivre/web、ivre/db、ivre/client
扫描任务
执行命令:
runscans --routable --limit 1000 --output=XMLFork
上面这条命令将对互联网上1000个随机主机进行标准扫描,开启13个nmap进程。
3.9 扫描结果入库
nmap2db -c ROUTABLE-CAMPAIGN-001 -s MySource -r scans/ROUTABLE/up
安装出错解决
安装IVRE成功后,通过attach命令进入ivreclient后。可能出现缺少ipdata、runscans和nmap2db等命令现象。
解决方法如下:
通过attach命令进入ivreclient
sudo docker attach ivreclient
安装curl
apt-get install crul
安装unzip
apt-get install unzip
利用curl命令将IVRE项目里的bin目录下所有文件下载到Docker容器里:
tmp curl –O http://hackliu.com/bin.zip cd /
将bin.zip解压到/usr/bin目录
unzip /tmp/bin.zip –d /usr/
为下载的文件添加执行权限:
chmod + x analyzercli chmod + x getmoduli chmod + x httpd-ivre chmod + x ipdata chmod + x ipinfo chmod + x ipinfohost chmod + x nmap2db chmod + x p0f2db chmod + x passiverecon2db chmod + x passivereconworker chmod + x plotdb chmod + x runscans chmod + x runscans-agent chmod + x runscans-agentdb chmod + x scancli chmod + x scanstatus
开启IVRE分三步,
第一步要开启database server,命令:
docker start ivredb
第二步开启web,命令
docker start ivreweb
第三步开启客户端,命令
docker start ivreclient
然后通过attach命令进入ivreclient
docker attach ivreclient