Skip to content

dzh05/rootkit

Repository files navigation

Kernel Rootkit

环境要求

# 检查内核版本
uname -r

# 安装必要的开发工具
sudo apt update
sudo apt install -y build-essential linux-headers-$(uname -r)

# 验证内核头文件
ls /lib/modules/$(uname -r)/build

编译和测试

# 1. 编译模块
make setuid_backdoor
make file_hide

# 编译成功后会生成 rootkit.ko 文件
ls -lh setuid_backdoor.ko

# 2. 查看模块信息
make info

# 3. 加载模块(需要 root)

insmod setuid_backdoor.ko
insmod file_hide.ko


# 测试
# 首先登陆非root账户,运行命令


id

# 验证当前用户非root
# 运行下面命令提权

mkdir("/tmp/.rootkit") 

# 再次运行
id
# 观察权限变化

# hide file模块会隐藏如下文件
	"secret",
	"hide_me"


# 4. 查看内核日志
make log
# 或直接使用 dmesg
dmesg -wH

# 5. 检查模块状态
make status
# 或使用 lsmod
lsmod | grep setuid_backdoor

# 6. 卸载模块

rmmod setuid_backdoor.ko
rmmod file_hide.ko

预期输出

加载模块后,使用 dmesg 应该看到:

[rootkit] Module loaded successfully
[rootkit] Kernel version: 5.15.0-161-generic

内核模块生命周期

insmod rootkit.ko  →  module_init()  →  模块运行
                                          ↓
rmmod rootkit      ←  module_exit()  ←   模块清理

查看详细日志

# 实时监控内核日志
sudo dmesg -wH

# 查看所有 rootkit 相关日志
dmesg | grep rootkit

About

这是基于kprobe内核探针技术的hook后门,实现了文件隐藏和内核态提权功能

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors