Skip to content
KitploitKITPLOIT
도구블로그
제출
도구블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
Kernel-exploitation — CTF 챌린지를 위한 Linux 커널 익스플로잇 개발 노트 및 스크립트로, initramfs 추출, msg_msg/ldt_struct 악용, 그리고 권한 상승을 위한 실전 익스플로잇 기법을 다룹니다. | Kitploit
도구/GitHubGitHub/ameetsaahu/kernel-exploitation
Privilege EscalationExploitationCTFLearning & EducationCurated ResourcesBinary Exploitation
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 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
도구 다운로드