Kernel
Kernel - Debbuging Script Utilize
LikeMermaid
2023. 4. 25. 00:36
728x90
Agenda
커널 디버깅 시 python script를 활용하여 디버깅하면 더욱 편리하게 디버깅 할 수 있음
Python Script Code
import os
gdb.parse_and_eval("0")
gdb.execute("", to_string=True)
except:
gdb.write("NOTE: gdb 7.2 or later required for Linux helper scripts to "
"work.\n")
else:
import linux.utils
import linux.symbols
import linux.modules
import linux.dmesg
import linux.tasks
import linux.config
import linux.cpus
import linux.lists
import linux.rbtree
import linux.proc
import linux.constants
import linux.timerlist
import linux.clk
import linux.genpd
import linux.device
sys
.path.insert(0, os.path.dirname(file) + "/scripts/gdb")try:
gdb.parse_and_eval("0")
gdb.execute("", to_string=True)
except:
gdb.write("NOTE: gdb 7.2 or later required for Linux helper scripts to "
"work.\n")
else:
import linux.utils
import linux.symbols
import linux.modules
import linux.dmesg
import linux.tasks
import linux.config
import linux.cpus
import linux.lists
import linux.rbtree
import linux.proc
import linux.constants
import linux.timerlist
import linux.clk
import linux.genpd
import linux.device
Apply
.gdbinit 파일에 아래와 같은 문구를 추가해 줌
add-auto-load-safe-path <script 파일 경로>
Command
lx-symbols [경로…] | 리눅스 커널(vmlinux)과 모듈(.ko)의 심볼을 (다시) 불러들입니다. |
lx-dmesg | 커널 로그(kmsg) 버퍼 내용을 출력합니다. |
lx-lsmod | 현재 적재된 커널 모듈의 목록을 출력합니다. |
lx-ps | 프로세스 및 스레드 목록을 출력합니다. |
lx-cpus | 커널이 인식하는 CPU 코어들의 관리 상태를 출력합니다. |
lx-list-check <list_head> | 주어진 list_head 연결 리스트 구조체의 일관성을 검사합니다. Unlink 관련 취약점을 디버깅할 때 유용할 수 있습니다. |