qemu 및 gdb setting

2023. 8. 20. 17:58·Kernel Exploit/Theory
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 > Theory' 카테고리의 다른 글

kernel debuging with pwndbg - pwndbg 설치  (0) 2023.08.27
rootfs.cpio 파일 추가 shell script  (0) 2023.08.21
Kernel 보호기법 및 우회법  (0) 2023.08.20
exploit binary를 커널 이미지에 삽입하기.  (0) 2023.08.20
vmlinux 추출하기  (0) 2023.08.20
'Kernel Exploit/Theory' 카테고리의 다른 글
  • rootfs.cpio 파일 추가 shell script
  • Kernel 보호기법 및 우회법
  • exploit binary를 커널 이미지에 삽입하기.
  • vmlinux 추출하기
wyv3rn
wyv3rn
아저씨의 흔한 취미. wyv3rn#1249
  • wyv3rn
    think storage
    wyv3rn
  • 전체
    오늘
    어제
    • 분류 전체보기 (502)
      • To do list (7)
        • Doing (1)
        • Complete (6)
      • Diary (35)
      • Tips & theory (73)
      • Kernel Exploit (27)
        • Theory (15)
        • Exercise (5)
      • File Structure (6)
      • Wargame (313)
        • pwn.college (34)
        • Dreamhack (148)
        • pwnable.kr (15)
        • Lord of Sqlinjection (3)
        • Cryptohack (20)
        • Root me (27)
        • CodeEngn (4)
        • Exploit Education (22)
        • ROP Emporium (8)
        • H4C (10)
        • Hackerchool (22)
      • CTF (41)
        • Solved (39)
        • Unsolved (2)
      • Script (0)
      • RubiyaLap (0)
  • 블로그 메뉴

    • 홈
    • 방명록
  • 링크

  • 공지사항

    • PWN wargame 모음 (및 느낀점)
    • 비공개 글들에 대해.
    • 뭐라도 하나 얻어가시길...
  • 인기 글

  • 태그

    x64
    heap
    libc
    vtable
    hackerschool
    dreamhack
    x86
    docker
    _IO_FILE
    rop
    RTL
    Buffer Overflow
    CANARY
    pwntools
    Me
    pwnable.kr
    exploit education
    FSB
    32bit
    cryptohack
    64bit
    root-me
    ROOT ME
    la ctf
    Format String Bug
    lob
    BOF
    root
    phoenix
    tcache
  • 최근 댓글

  • 최근 글

  • 250x250
    반응형
  • hELLO· Designed By정상우.v4.10.3
wyv3rn
qemu 및 gdb setting
상단으로

티스토리툴바