728x90
반응형
qemu란?
vmware와 같은 가상 머신 에뮬레이터이다.
보통 ctf에서는 앞서 만든 bzImage와 rootfs.cpio (+vmlinux는 주어지기도하고 아닐수도 있음) 파일로 qemu를 통해 가상 머신을 실행할 수 있다.
run.sh
qemu가 어떻게 구동될지 설정을 담고 있는 파일이다.
#!/bin/sh
qemu-system-x86_64 \
-m 64M \
-nographic \
-kernel bzImage \
-append "console=ttyS0 loglevel=3 oops=panic panic=-1 nopti nokaslr" \
-no-reboot \
-smp 1 \
-monitor /dev/null \
-initrd rootfs.cpio \
-net nic,model=virtio \
-net user \
-cpu qemu64 \
-s
중요한 몇가지만 우선 보고 넘어가자.
kernel 파일 설정
-kernel ./bzImage
파일 시스템 파일 설정
-initrd ./rootfs.cpio
gdb attach를 위한 1234포트를 open
-s
kernel ASLR 제거
-append "nokaslr"
커널 메시지 출력 설정
echo 1 > /proc/sys/kernel/dmesg_restrict
gdb attach
위와 같이 -s 옵션이 지정되어있다면 gdb 내에서
target remote localhost:1234
명령어를 통해 qemu에 gdb를 attach 할 수 있다.
유의사항
qemu script에서 주석이 중간에 포함되면 그 다음 줄은 실행되지 않는 경우가 있으니 유의하자.
ex.) 아래와 같은 경우 -s 옵션이 안들어가서 gdb attach가 안됨.
-cpu qemu64 \
# -cpu kvm64,+smep
-s
그러므로 아래와 같이 주석을 제일 뒤로 보내자.
-cpu qemu64 \
-s
# -cpu kvm64,+smep
728x90
반응형
'Kernel Exploit' 카테고리의 다른 글
exploit binary를 커널 이미지에 삽입하기. (0) | 2023.08.20 |
---|---|
vmlinux 추출하기 (0) | 2023.08.20 |
Kernel exploit - kernel build 및 file system build (0) | 2023.08.06 |
Kernel exploit - 모듈 프로그래밍 (0) | 2023.08.06 |
Kernel exploit - 디바이스 드라이버 (0) | 2023.08.06 |