14

CIA Hive测试指南——源代码获取与简要分析

 3 years ago
source link: https://3gstudent.github.io/3gstudent.github.io/CIA-Hive%E6%B5%8B%E8%AF%95%E6%8C%87%E5%8D%97-%E6%BA%90%E4%BB%A3%E7%A0%81%E8%8E%B7%E5%8F%96%E4%B8%8E%E7%AE%80%E8%A6%81%E5%88%86%E6%9E%90/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

0x00 前言


11月9日维基解密公布一个代号为Vault8的文档,包含服务器远程控制工具Hive的源代码和开发文档。本文仅站在技术角度,介绍测试方法,简要分析工具特点。

维基解密地址:

https://wikileaks.org/vault8/

0x01 简介


本文将要介绍以下内容:

  • 源代码获取方法
  • 框架流程分析
  • 工具具体说明

0x02 源代码获取


下载地址:

https://wikileaks.org/vault8/document/repo_hive/

代码库中的文件创建于在2013年8月和2015年10月之间,但工具Hive的开发时间应该更早

维基解密以git的方式公布该代码,包含以下几个分支:

  • armv5
  • autotools
  • debug
  • makemods
  • master(默认)
  • polar-0.14.3
  • polar-1.1.8
  • polar-1.2.11
  • polar-1.3.4
  • solarisbug
  • ubiquiti

下载后发现并不包含相关源代码,需要使用git释放源代码

注:

这种方式能够减小源代码体积(下载文件大小95.5MB,实际文件大小170MB)

1、安装git

kali2默认安装,未安装的Linux系统使用以下安装命令:

sudo yum install git

Windows系统下载地址:

https://git-for-windows.github.io/

使用如下图

Alt text

2、常用git命令

查看所有分支,当前分支会被星号标示出:

git branch

当前分支为master,如下图

Alt text

查看历史版本:

git log

查看git状态,能够列出被修改但还未提交的文件:

git status
Alt text

切换分支:

git checkout -b (branchname)

由于当前操作并未提交,所以恢复删除的文件使用.即可,命令如下:

git checkout .

成功释放出master分支下的代码,如下图

Alt text

补充切换版本的方法:

查看版本号:

git reflog

切换版本至polar-1.3.4:

git checkout polar-1.3.4

0x03 框架分析


结合框架图对Hive进行分析

原图片来自\hive\infrastructure\documentation\Hive Operating Environment.odp

我在原图片的基础上做了标记,便于分析,如下图

Alt text

(1) Client

相当于木马的被控端,通过hive-patcher生成

支持以下系统:

  • mt-x86
  • mt-mips
  • mt-mipsel
  • mt-ppc
  • linux-x86
  • sol-x86
  • sol-sparc

可使用以下目录的不同版本:

  • hive\snapshot_20141217-1052\clientDirectory
  • hive\snapshot_20141107-1345\clientDirectory
  • hive\snapshot_20141017-1409\clientDirectory

测试使用hive\snapshot_20141107-1345\clientDirectory

用法如下:

./hive-patcher -a address [-d b_delay] [-i interval] (-k idKey | -K idKeyFile) [-I interface] [-p port] [-t t_delay] [-m OS] 

该工具的详细说明可参考用户文档,位于\hive\documentation\UsersGuide\UsersGuide.odt, 2.3 (S) Patcher

./hive-patcher -a 192.168.81.192 -p 4567 -i 3600 -j 5 -m linux-x86 -k "Testing Testing"

生成过程会显示配置信息,如下图

Alt text

(2) 端口转发

VPS Redirector,第一跳板,实现流量转发功能

详细配置可参考:

\hive\infrastructure\documentation\Infrastructure Configuration Guide.odt6 (S//NF) VPS Redirector

(3) 中转服务器

Blot Proxy,第二跳板,实现流量分发功能。使用OpenVPN同VPS Redirector进行通信,对Client的证书进行校验,若证书有效,流量转发至Honeycomb服务器,若证书存在问题,流量转发至CoverServer

详细说明可参考:

\hive\infrastructure\documentation\Infrastructure Configuration Guide.odt5 (S//NF) Blot Proxy

需要安装Blot-4.3 sinnertwin-blot-beastbox-1.3-1

具体功能通过Switchblade实现

Switchblade:

通过开源Web服务器Nginx和LinuxIP路由策略实现流量分发

详细配置可参考:

\hive\infrastructure\documentation\Switchblade.odt

(4) Server

控制端,分为CoverServer和Honeycomb

CoverServer:

提供正常的网页功能,可根据不同端口返回不同的域名信息

详细配置可参考:

\hive\infrastructure\documentation\Infrastructure Configuration Guide.odt3 (S//NF) Cover Server

Honeycomb:

实际控制端,该部分的详细配置说明缺失

提供给用户操作的界面程序为Cutthroat

Cutthroat:

相当于木马控制端,发送控制命令

可使用以下目录的不同版本:

  • hive\snapshot_20141217-1052\clientDirectory
  • hive\snapshot_20141107-1345\clientDirectory
  • hive\snapshot_20141017-1409\clientDirectory

启动方式:

./cutthroat hive

如果控制台回显success,代表加载成功

详细配置可参考:

\hive\documentation\UsersGuide\UsersGuide.odt, 3.4 (U) Command and Control Client

使用版本snapshot_20141217-1052\clientDirectory会报错,返回

./hive: undefined symbol: debug_print_buffer
[local failure] Failed to load hive [load]
Alt text

换另一个测试版本snapshot_20141107-1345/ctDirectory

[success] Successfully loaded hive [load]
Alt text

按下Tab键能够获得可用的命令

通信上分为两种模式:

主动连接:

ilm connect <triggerFileName>

用于主动连接服务器上的后门

被动连接:

ilm listen <port>

当成功与Client建立连接后,支持如下操作:

  • cmd exec
  • file put
  • file get
  • ilm exit
  • shutdown now
  • shell open

0x04 其他工具


1、hiveReset_v1_0.py

位于\hive\ilm-client\resetTimer_v1.0\delivery_1Oct2012

用于更新木马客户端

2、Chimay-Red

针对MikroTik MIPS RouterOS 6.x的远程利用工具,能够远程植入Hive

相关说明:

https://wikileaks.org/ciav7p1/cms/page_16384604.html

3、Mealybug

针对AVTech Network Video Recorders的远程利用工具,能够远程植入Hive

0x05 综合分析


对于维基解密这次公布的Vault8文档,不包含漏洞利用工具和相关POC

Hive作为一款远程控制工具,支持多个操作系统,包括Windows(Server 2003)、Linux(x86/x64)、Solaris(sparc/x86)、MikroTik(MIPS/PowerPC/Intelx86)、Ubiquiti (MIPS)和AVTech NVRs(AVTech ARM)

在隐蔽性上下足了功夫,通过流量分发的方式隐蔽实际的控制服务器地址,使用伪造的卡巴斯基实验室证书进行通信


LEAVE A REPLY


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK