Skip to content

Intrusion Detection System based on eBPF , use libbpf-bootstrip

License

Notifications You must be signed in to change notification settings

SimplycoderCC/HIDS-eBPF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eBPF-HIDS

Intrusion Detection System based on eBPF

为什么是eBPF?

稳定:通过验证器,防止用户编写的程序导致内核崩溃。相比内核模块,eBPF更稳定

免安装:eBPF内置于Linux内核,无需安装额外依赖,开箱即用。

内核编程:支持开发者插入自定义的代码逻辑(包括数据采集、分析和过滤)到内核中运行

高效的信息交流机制:通过Map(本质上是一种共享内存的方式)进行数据传输,实现各个hook点、用户态与内核态的高效信息交互。

eBPF-HIDS source code

# hids source code
./hids/config.h  
./hids/utils.h  
./hids/hids.h  
./hids/hids.bpf.c  
./hids/hids.c  
./hids/hids.h 
./hids/com_funaddr.c 
# bpftrace 跟踪各种系统调用序列的脚本
./demo/*.c #bpftrace跟踪脚本
./demo/*.txt #得到的系统调用序列

Documents

Other

容器加固学习文档

docker容器运行时安全早期学习文档

ebpf rootkit初步探索

Branches

  • main ------主分支,仅实现检查功能
  • lsm -------基于KRSI内核运行时检测,基于LSM hook点实现函数级的入侵阻断
  • send_signal ------基于bpf_send_signal()辅助函数发送信号,实现进程级的入侵阻断

Usage

# Enter the folder
cd hids 
# Compile
make hids   # 或者 make all  
# 运行hids
sudo ./hids

# clear
make clear  # 或者 make clean

Hook points

项目目前支持 19 种 Hook,足以实现本项目所需功能。这些hook点的选取主要基于本人的实践,存在优化空间

项目使用的 eBPF Hook point 详情

Hook Status & Description
tracepoint/module/module_load ON & 提取*.ko文件相关信息
tracepoint/syscalls/sys_exit_finit_module ON & 触发系统调用表检查
tracepoint/syscalls/sys_enter_mount ON
tracepoint/syscalls/sys_exit_mount ON
tracepoint/syscalls/sys_enter_open ON
tracepoint/syscalls/sys_exit_open ON
tracepoint/syscalls/sys_enter_openat ON
tracepoint/syscalls/sys_exit_openat ON
tracepoint/syscalls/sys_enter_execve ON
tracepoint/syscalls/sys_enter_execveat ON
tracepoint/syscalls/sys_enter_kill ON & 基于信号系统实现功能分发
tracepoint/syscalls/sys_enter_memfd_create ON & 无文件攻击相关
kprobe/kprobe_lookup_name ON & kprobe framework相关函数
kprobe/arm_kprobe ON & kprobe framework相关函数
kprobe/insn_init ON & 篡改内存代码行为相关函数
kprobe/insn_get_length ON & 篡改内存代码行为相关函数
kprobe/security_file_permission ON & file_operations checks
lsm/cred_prepare OFF(only ON in lsm branch) & 基于lsm阻断insmod
lsm/kernel_read_file OFF(only ON in lsm branch) & 基于lsm阻断无文件加载攻击

todo

todolist

  • 检测中断向量表idt_table 0X80号软中断系统调用服务表项的修改。和系统调用表检查类似,检查idt_table[0X80]的地址值是否变化或者超出范围
  • [√] 容器逃逸相关检测。示例截图、完善原理文档
  • [√] Nofile attack 无文件攻击文档工作。示例截图、完善原理文档
  • [√] 完善文件的fop检查,相关内容bpftrace-hook-demo仓库kern_hook_demo中的security_file_permission
  • fop-check示例寻找(注意相关注释中的链接),运行结果验证

Complete documentation...

About

Intrusion Detection System based on eBPF , use libbpf-bootstrip

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors