Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
Kernel-exploitation — 用于 CTF 挑战赛的 Linux 内核漏洞利用开发笔记与脚本,涵盖 initramfs 提取、msg_msg/ldt_struct 滥用以及权限提升的实用漏洞利用技术。 | Kitploit
工具/GitHubGitHub/ameetsaahu/kernel-exploitation
权限提升漏洞利用CTF学习与教育精选资源二进制利用
GitHubameetsaahu/kernel-exploitation

Kernel-exploitation

用于 CTF 挑战赛的 Linux 内核漏洞利用开发笔记与脚本,涵盖 initramfs 提取、msg_msg/ldt_struct 滥用以及权限提升的实用漏洞利用技术。

查看仓库
3751年前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

内核利用

decompress.sh

从 CPIO 归档中提取文件

root@kitploit:~
#!/bin/sh
mkdir fs
cd fs
cp ../initramfs.cpio.gz ./initramfs.cpio.gz
gunzip ./initramfs.cpio.gz
cpio -idm < ./initramfs.cpio
rm initramfs.cpio
cd ..

compress.sh

编译漏洞利用程序,将其添加到 fs,然后运行。

root@kitploit:~
#!/bin/sh
gcc -w -o exploit -static exploit.c -pthread -lrt &&\
# musl-gcc -w -s -static -o3 exploit.c -o exploit -masm=intel &&\
mv exploit ./fs/ &&\
cd fs &&\
find . -print0 | cpio --owner root --null -ov --format=newc | gzip -9 > ../initramfs.cpio.gz &&\
cd .. &&\
# gunzip -f initramfs.cpio.gz &&\
./run.sh

如果是 ext4 文件系统归档

root@kitploit:~
mount ./initramfs.cpio.gz ./fs/

extract-image.sh

实用结构

ldt_struct - modify_ldt 系统调用

0x20 大小的结构体,对 copy_to_user 调用不包含任何检查

  • https://elixir.bootlin.com/linux/v4.19.98/source/arch/x86/kernel/ldt.c#L553
  • https://github.com/ameetsaahu/Kernel-exploitation/tree/main/0ctffinal2021-kernote

msg_msg

root@kitploit:~
struct msg_msg {
    struct list_head m_list;
    long m_type;
    size_t m_ts;        /* message text size */
    struct msg_msgseg *next;
    void *security;
    /* the actual message follows immediately */
};

用户消息紧跟在 msg_msg 结构体之后存储,直到 0x1000 - 0x30,之后是存储在 struct msg_msgseg *next 中的块的单向链表,每次分配的大小最多 0x1000,该链表是并且应该是 NULL 终止的。 对于任意读: 覆盖 next 和 m_ts,使其从被覆盖的 next 指针处读取。

对于任意写:

root@kitploit:~
msgsnd()        // Userland
    do_msgsnd() // Kernel land
        load_msg()  
            alloc_msg()         // Allocate all the necessary chunks
            copy_from_user()    // Race here to replace `struct msg_msgseg *next` before its used to copy userdata. Maybe use userfaultfd ;)

msg_msg do_msgsnd load_msg copy_msg

  • https://github.com/ameetsaahu/Kernel-exploitation/tree/main/corctf2021-fire_of_salvation
  • https://syst3mfailure.io/wall-of-perdition

杂项

将进程限制在特定 CPU 上运行

root@kitploit:~
cpu_set_t cpu_set;
CPU_ZERO(&cpu_set);
CPU_SET(0,&cpu_set);
ret=sched_setaffinity(0,sizeof(cpu_set),&cpu_set);

参考资料

  • https://github.com/xairy/linux-kernel-exploitation 作者:@andreyknvl
  • 对内核利用有用的结构体集合 作者:@ptr-yudai
  • https://blog.hacktivesecurity.com/index.php/2022/06/13/linux-kernel-exploit-development-1day-case-study
  • https://duasynt.com/blog/linux-kernel-heap-feng-shui-2022
  • https://googleprojectzero.blogspot.com/2019/11/bad-binder-android-in-wild-exploit.html
  • https://cloudfuzz.github.io/android-kernel-exploitation
下载工具