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 レビュー済み

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有

Kernel-exploitation

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 syscall

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 by @andreyknvl
  • カーネルエクスプロイトに有用な構造体集 by @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
ツールをダウンロード