hacker白帽知识分享
6.35K subscribers
100 photos
1 video
1 file
8 links
Download Telegram
(6) 当系统对木马相关文件访问的时候,会由fake_filldir处理,根据判断调用者是否木马操作来决定是否返回正确结果;

翻译
(6) When the system accesses Trojan-related files, it will be handled by fake_filldir, which will determine whether to return the correct result based on whether the caller is performing a Trojan operation.
(7) 在内核模块链表中删除自己,kobject_del删除自己的内核对象;

翻译;
(7) Remove itself from the kernel module list; kobject_del removes its own kernel object.
(8) kthread_create创建内核线程dot_thread
创建内核模块自启动
/etc/sysconfig/modules/ati_remote3.modules

写入内核模块文件
/lib/modules/%s/kernel/drivers/input/misc/ati_remote3.ko

释放rmgr_fake_libc.so文件到磁盘

释放rmgr_daemon文件到磁盘,并以“[khelper]”进程名通过call_usermodehelper_exec运行它。
2. rmgr__fake_libc.so
此共享库文件,由内核rootkit释放写入磁盘,路径为/tmp/.tmp_{21个随机字母数字},用于木马的用户态进程的行为隐藏。
subhook前缀的函数摘抄自开源代码(附录2),详细功能请移步github围观,本文不赘述。

fake前缀的函数主要用于对抗常见HIDS的进程和命令记录,fork和execve直接通过syscall调用,而不使用glibc的封装,避开了hook glibc方式的HIDS。

翻译;
The functions with the `subhook` prefix are excerpted from open-source code (Appendix 2). For detailed functionality, please visit GitHub; this article will not elaborate further.

The functions with the `fake` prefix are primarily used to combat common HIDS processes and command logging. `fork` and `execve` are called directly via syscalls, bypassing glibc wrappers and thus avoiding hooking glibc-based HIDS.
fake_bash_add_history则让bash命令审计功能失效。

翻译;
fake_bash_add_history disables the bash command auditing feature.
3. rmgr_daemon
此进程由rmgr.ko释放写入磁盘,路径为/tmp/.tmp_{21个随机字母数字}。由C++开发,编译后upx加壳压缩,直接用开源软件upx -d rmgr_daemon即可脱壳,并无特殊处理。

它主要有的功能有:

(1) 监控内核模块状态,与内核rootkit信息交互;

翻译;
3. rmgr_daemon
This process is released and written to disk by rmgr.ko, at path /tmp/.tmp_{21 random alphanumeric characters}. Developed in C++, it is compressed using UPX after compilation. It can be unpacked directly using the open-source software `upx -d rmgr_daemon` without any special processing.

Its main functions include:

(1) Monitoring kernel module status and interacting with kernel rootkit information;
(2) 更新;
(3) 生成rmgr_fake_sshd,并patchELF,修改依赖的动态库,也就是加入rmgr_fake_libc.so,功能如前述;
从内核获取路径
返回路径
patch ELF

(4) 连接C2 hm2.yrnykx.com;

翻译;
patch ELF

(4) Connect to C2
hm2.yrnykx.com;
(5) 管理rmgr_fake_sshd;

其中patchELF代码摘抄自GitHub - NixOS/patchelf (附录3)

4. rmgr_fake_sshd
文件由rmgrdaemon写入磁盘,路径为/tmp/.tmp{21个随机字母数字},它的运行均由rmgr_daemon管理。
作为后门它硬编码了PRIVATE KEY ,如下图:

因为通过patchELF hook了部分函数,实现了ssh登录之后的命令执行等行为的隐匿。而rmgr_fake_sshd本身,以及ssh登录派生的子进程均通过rmgr.ko根据前述分析通过patch内核调用实现隐匿。

rmgr_fake_sshd启动时加载了硬编码的sshd_config,请注意其中几个关键配置。
监听在本地的26657端口,rmgr_daemon连接此端口转发来至C2的ssh指令。这里实现了拟合业务环境常用网络协议,使得常规的NIDS的检测逻辑被绕过。

第三步:消除
这里主要是指加固,避免被攻击者以同样的手法攻击。具体手段如下:

突破口加固,补丁更新,ACL加固。
运维通道,停用旧账户,修改攻击链路中服务器账户,并上双因素认证。
根据用户角色限定可访问系统范围。
受害系统dump保存虚机镜像,待查。
重装受害系统,重新发布部署业务环境。
新系统内核模块加载要求签名校验。
第四步:利用
完成应急响应工作,分析完事件现场和文件之后,整个事件中提取到的关键信息将沉淀为威胁情报。本文将威胁情报金字塔模型的内容缩减到iocs和ttps两部分,ttps用att&ck矩阵模型做归纳。

翻译;
Step 4: Utilizing the completed emergency response work, after analyzing the incident scene and documents, the key information extracted from the entire incident will be condensed into threat intelligence. This article reduces the content of the threat intelligence pyramid model to two parts: IOCs and TTPS. TTPS is summarized using the ATT&CK matrix model.
威胁情报金字塔模型

1. iocs
(1) md5:

7d859a22f38f0bcd55a46bc8b67c40df

fa73b2fd914a0cfd5e7d3161af903b6c

(2) c2:

hm2.yrnykx.com

2. ttps
第五步:分析
从上节ttps可以看出来,att&ck矩阵并不能完全覆盖此次木马用于对抗安全系统的全部隐匿手段。

粗略的分类其隐匿(进程、网络、文件)手段有:

C2通过fake_sshd避开NIDS的检测;
通过patchELF绕开hook libc的命令审计HIDS;
通过fake_bash_add_history让shell审计失效;
通过patch seq_show修改系统对/proc下文件信息读取的返回,实现对木马相关的文件、进程、网络连接信息的隐匿;
通过patch vfs_readdir实现隐藏木马文件;
通过摘除内核进程、模块链表信息,避免被rookit检测工具发现内核中木马痕迹;

可见,此款木马套装存在大量技术细节来对抗安全系统,不过它主要针对市面上已知的一些旧款HIDS和事后取证调查工具。内核态的进程派生syscall hook和inotify+云查杀还是可以发现它的。
木马与安全系统的对抗维度

一套完整的木马系统不可能仅仅因为一次渗透入侵而开发,必然会借鉴很多开源或者家族代码。所以从溯源角度来说,可以做代码“考古”工作,同时将相关代码风格和木马行为纳入安全系统特征库。限于篇幅,暂不在此赘述。
总结
事实上,实际的事件响应处置过程顺序不可能完全跟上述流程一致。但走完整套流程,笔者认为才能算是一个安全事件处置圆满的结束。其实,F3EAD流程比较重视情报从分析到应用(改进安全对抗能力),特别是在“分析”阶段的反复迭代。

翻译:
In conclusion, the actual sequence of incident response and handling may not perfectly align with the above process. However, completing the entire process is considered a successful conclusion to a security incident. The F3EAD process places significant emphasis on the transition from intelligence analysis to application (improving security countermeasures), particularly the iterative process within the "analysis" phase.