kernel gef shortcut

커널에서는 ‣ 을 자주쓰기에 이 전용 gdb를 위한 shortcut을 만들어보았다.

basic

중요도명령어뭐 해줌언제 쓰나
⭐⭐⭐kbase커널 베이스 주소(KASLR base) 출력KASLR 잡혔는지/베이스 필요할 때
⭐⭐⭐kcurrentcurrent task 주소(현재 태스크) 출력지금 실행 중 태스크(task_struct) 잡을 때
⭐⭐⭐ktask태스크 리스트 + 주요 오프셋/필드(cred, comm 등)까지 뽑아줌cred/comm/stack 오프셋 확인, current 검증할 때
⭐⭐⭐kvmmap커널 가상주소 맵(physmap/vmalloc/module 등) 출력주소가 어디 영역인지 분류할 때
⭐⭐⭐ksymaddr-remotekallsyms를 “메모리 스캔”으로 복원/조회vmlinux 심볼 없을 때 함수/심볼 주소 찾을 때
⭐⭐⭐ksymaddr-remote-apply위에서 얻은 심볼을 GDB에 적용(pseudo ELF)이후부터 b commit_creds 같은 심볼 브레이크가 쉬워짐
⭐⭐☆kchecksec커널 보안 옵션(보호기법) 체크SMEP/SMAP/PTI/KASLR 등 환경 정리할 때
⭐⭐☆kmagic커널에서 유용한 주소들 모음 출력“뭐가 어디 있지?” 할 때 빠른 지도
⭐⭐☆kcmdline부팅 cmdline 출력kaslr, pti, panic_on_warn 같은 옵션 확인
⭐⭐☆kversion커널 버전 출력익스/오프셋/기법 갈라질 때 기준점
⭐⭐☆kconfig커널 config 덤프(가능하면)BTF/SLUB/하드닝 옵션 확인

struct & table

명령어뭐 해줌
ktask태스크 목록 + task_struct 주요 오프셋(cred/comm/pid/stack 등) + (옵션에 따라) 유저 프로세스 mm/레지스터/FD/시그널/네임스페이스/seccomp까지
syscall-table-viewsyscall table 보기(ia32/x32/compat 등도)
ksysctlsysctl 파라미터 덤프
kdmesgdmesg ring buffer 덤프
kpipepipe 정보 표시
kipcsSysV IPC(sem/msg/shm) 덤프

page

명령어뭐 해줌메모
v2p / p2v가상주소↔물리주소 변환 보여줌physmap/PA 추적할 때
xp물리 메모리 덤프(shortcut)“PA 기준”으로 보고 싶을 때
page + (virt2page,page2virt,phys2page,page2phys)struct page ↔ VA/PA 변환슬랩/페이지 구조 추적할 때

heap

명령어뭐 해줌언제 씀
slub-dumpSLUB freelist 덤프 (no-symbol+kASLR에서도 지원)UAF로 freelist/재할당 흐름 볼 때
slab-dumpSLAB freelist 덤프SLAB 구성일 때
slob-dumpSLOB freelist 덤프초경량 할당자일 때
slub-tiny-dumpSLUB-TINY freelist 덤프tiny 구성일 때
slab-contains“이 주소가 어느 kmem_cache 소속인지” 추정객체 주소만 있고 cache 모를 때
kmem-cache-aliaskmem_cache alias 이름 덤프kmalloc-* 매핑 확인할 때
buddy-dumpbuddy allocator free-list 덤프page allocator 상태/오더 확인
vmalloc-dumpvmalloc used/freed 리스트 덤프vmalloc 영역 흔적/해제 추적
slab-virtualslab-meta ↔ slab-data 변환 (CONFIG_SLAB_VIRTUAL)(해당 옵션일 때) 메타/데이터 대응
highmem-dumpHighMem 매핑 덤프highmem 관련 분석

module

명령어뭐 해줌
kmod모듈 주소/심볼 표시
kloadvmlinux를 “로드 주소 없이” 로드 (debuginfo 있을 때 유용)
kmod-load커널 모듈을 “로드 주소 없이” 로드 (debuginfo 있을 때)
kcdevchar device 정보 덤프
kbdevblock device 정보 덤프
kfilesystems지원 파일시스템 목록
kclock-sourceclocksource 리스트
kbpfBPF 정보 덤프
ktimertimer 덤프
kpcidevPCI 디바이스 덤프
kdevioI/O-port / I/O-memory 정보
kdmabufDMA-BUF 정보
kirqIRQ 정보
knetdev네트워크 디바이스 표시

tracing

명령어뭐 해줌포인트
ksearch-code-ptr커널 data 영역에서 코드 포인터 탐색누수 포인터/함수포인터 흔적 찾을 때
thunk-tracer자동 호출되는 thunk 함수 주소 수집RIP/제어흐름 힌트
usermodehelper-tracercall_usermodehelper_setup 실행 정보 수집modprobe/usermodehelper 흐름 확인
kmalloc-tracerkmalloc/kfree 이벤트 수집/표시힙 레이아웃/재할당 타이밍
kmalloc-allocated-by특정 syscall 세트 실행 후 kmalloc/kfree된 구조체 출력“어떤 syscall이 어떤 구조체 만들지”
ktrace커널 함수/인자 트레이스함수 호출 흐름 관찰

QEMU 모니터/레지스터/CPU 관련

명령어뭐 해줌
qregqemu-monitor로 레지스터 보여줌(예: qemu 2.x에서 $cs 같은 것)
msrMSR read/write (동적 asm 실행)
cetIntel CET 설정 표시