一个Linux eBPF rootkit工具,后门、C2等多功能——TripleCross

作者:Sec-Labs | 发布时间:

TripleCross

简介

具有后门、C2、库注入、执行劫持、持久性和隐身功能的 Linux eBPF rootkit

介绍

TripleCross是一个Linux eBPF rootkit,展示了eBPF技术的攻击能力。

TripleCross的灵感来自于该领域以前的植入设计,特别是Jeff Dileo在DEFCON 271上的作品,Pat Hogan在DEFCON 292上的作品,Guillaume Fournier和Sylvain Afchain也在DEFCON 293上的作品,以及Kris Nóva的Boopkit4。我们重新使用并扩展了这些以前对eBPF技术的进攻能力的探索所开创的一些技术。

这个rootkit是为我在UC3M的学士论文而创建的。有关其设计的更多细节,请见论文文件

免责声明

这个rookit纯粹是为了教育和学术目的。该软件 "按原样 "提供,作者对使用过程中可能发生的任何损坏或误操作不负责任。

不要试图使用TripleCross来违反法律。滥用所提供的软件和信息可能导致刑事指控。

 

特点

  • 一个库注入模块,通过在进程的虚拟内存中写入来执行恶意代码。
  • 一个执行劫持模块,修改传递给内核的数据以执行恶意程序。
  • 一个本地权限升级模块,允许以root权限运行恶意程序。
  • 一个具有C2功能的后门,可以监控网络并执行从远程rootkit客户端发送的命令。它结合了多个激活触发器,从而使这些行动被隐蔽地传送。
  • 一个rootkit客户端,允许攻击者建立3种不同类型的类似shell的连接,以发送远程控制rootkit状态的命令和行动。
  • 一个持久性模块,确保即使在重启事件后,rootkit仍然保持安装,并保持完全的权限。
  • 一个隐蔽模块,对用户隐藏与rootkit相关的文件和目录。

 

TripleCross概述

下图显示了TripleCross的结构及其模块。

db8eb34ded173450

用于rootkit传输的原始套接字库RawTCP_Lib是我的作品,有自己的仓库

下表描述了主要的源代码文件和目录,以方便其导航。

目录 命令
docs Original thesis document
src/client Source code of the rootkit client
src/client/lib RawTCP_Lib shared library
src/common Constants and configuration for the rootkit. It also includes the implementation of elements common to the eBPF and user space side of the rootkit, such as the ring buffer
src/ebpf Source code of the eBPF programs used by the rootkit
src/helpers Includes programs for testing the functionality of several rootkit modules, and also the malicious program and library used at the execution hijacking and library injection modules, respectively
src/libbpf Contains the libbpf library integrated with the rootkit
src/user Source code of the userland programs used by the rootkits
src/vmlinux Headers containing the definition of kernel data structures (this is the recommended method when using libbpf)

构建和安装

编译

rootkit的源代码是用两个Makefile编译的。

# Build rootkit
cd src
make all
# Build rootkit client
cd client
make

下表详细描述了每个Makefile的目的。

MAKEFILE COMMAND DESCRIPTION RESULTING FILES
src/client/Makefile make Compilation of the rootkit client src/client/injector
src/Makefile make help Compilation of programs for testing rootkit capabilities, and the malicious program and library of the execution hijacking and library injection modules, respectively src/helpers/simple_timer, src/helpers/simple_open, src/helpers/simple_execve, src/helpers/lib_injection.so, src/helpers/execve_hijack
src/Makefile make kit Compilation of the rootkit using the libbpf library src/bin/kit
src/Makefile make tckit Compilation of the rootkit TC egress program src/bin/tc.o

安装

一旦rootkit文件在src/bin/下生成,tc.o和kit程序就必须依次加载。在下面的例子中,rootkit后门将在网络接口enp0s3中运行。

// TC egress program
sudo tc qdisc add dev enp0s3 clsact
sudo tc filter add dev enp0s3 egress bpf direct - action obj bin/tc.o sec classifier/egress
// Libbpf-powered rootkit
sudo ./bin/kit -t enp0s3

攻击方案脚本

有两个脚本,packager.sh和deployer.sh,可以自动编译和安装rootkit,就像攻击者在真实的攻击场景中所做的那样。

  • 执行 packager.sh 将生成 apps/ 目录下的所有 rootkit 文件。
  • 执行 deployer.sh 将安装 rootkit 并创建持久性文件。

这些脚本必须首先配置以下参数,以使持久性模块正常运行。

SCRIPT CONSTANT DESCRIPTION
src/helpers/deployer.sh CRON_PERSIST Cron job to execute after reboot
src/helpers/deployer.sh SUDO_PERSIST Sudo entry to grant password-less privileges

项目地址

更多模块介绍和使用教程请参考项目地址

https://github.com/h3xduck/TripleCross

标签:工具分享