background/linux kernel

    Linux Kernel Debugging (with VMware)

    Linux Kernel Debugging (with VMware)

    결론부터 적자면 vmware를 사용한 방법은 실패했습니다. qemu를 사용한 디버깅 방법을 추천드립니다. VMware를 이용한 리눅스 커널 디버깅 방법에 대해 알아보자. 분석의 편의성을 위해 Debug Symbol를 설치한다. 다음과 같이 저장소 정보를 "/etc/apt/sources.list.d/ddebs.list" 파일에 저장한다. echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse deb http://ddebs.ubuntu.com $..

    Linux Kernel Debugging (with QEMU)

    Linux Kernel Debugging (with QEMU)

    이 글 읽어보고 따라 실습해보면서 정리하는 글 https://jeongzero.oopy.io/73084e52-54fa-43e2-986b-072ee2a4f80d 리눅스 커널 디버깅하기 1. 환경 jeongzero.oopy.io 기본 환경 세팅 ubuntu 18.04에서 진행한다. 사용하는 리눅스 커널의 버전은 4.7이다. sudo apt-get install qemu qemu-system git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux cd linux git checkout v4.7 필요한 패키지 설치 sudo apt-get install build-essential libncurses5 libncurses5..

    [Lazenca][Development of Kernel Module] 04.Creating a kernel module to privilege escalation

    [Lazenca][Development of Kernel Module] 04.Creating a kernel module to privilege escalation

    Creating a kernel module to privilege escalation Kernel Exploit시 반드시 알아야 하는 기본적인 함수는 prepare_kernel_cred(), commit_creds() 함수이다. 이번 예제는 해당 함수에 대한 이해와 해당 함수를 활용하여 권한상승을 일으키는 모듈을 만드는 것이다. cred structuer cred 구조체는 이렇게 생겼다. 가볍게 읽어보고 뒤에서 각 필드들이 뒤에 함수들에서 어떻게 사용되는지 살펴보자. https://elixir.bootlin.com/linux/v4.18/source/include/linux/cred.h#L111 struct cred { atomic_tusage; #ifdef CONFIG_DEBUG_CREDENTIALS ..

    [Lazenca][Development of Kernel Module] 03.ioctl(Input/Output control)

    [Lazenca][Development of Kernel Module] 03.ioctl(Input/Output control)

    ioctl(Input/Output control) ioctl은 하드웨어의 제어와 상태 정보를 얻기 위해 제공되는 오퍼레이션이다. read(), write()는 데이터의 읽고, 쓰기는 가능하지만 하드웨어의 제어 및 상태 정보까지는 확인할 수 없다. SPI 통신 속도 설정를 하거나, I2C 슬레이브 어드레스 설정,등의 작업은 read, write만으로는 할 수 없다. CD-ROM 디바이스 드라이버는 실제 장치에서 디스크를 꺼내도록 지시할 수 있는 ioctl 요청 코드를 제공한다. 위키피디아의 내용을 좀 더 읽어보면 이렇다. 시스템 호출은 표준 커널 기능에 접근하기 위한 편리한 설계이지만, 비표준 하드웨어 주변 장치에 접근하기에는 적합하지 않을 때가 있습니다. 대부분의 하드웨어 주변 장치(또는 장치)는 커널 ..

    [Lazenca][Development of Kernel Module] 02.Character Device Drivers

    [Lazenca][Development of Kernel Module] 02.Character Device Drivers

    Character Device Drivers 버퍼 캐시(Buffer cache)를 사용하지 않고 데이터를 한번에 하나의 문자를 읽고 쓰는 드라이버이다. 예) Keyboad, Sound card, Printer 드라이버 이외에도 Block Device, Network Device 드라이버가 있다. 블록 디바이스 드라이버는 버퍼 캐시를 통한 임의 접근과 블록단위로 입출력이 가능하다. 예) 하드디스크 네트워크 디바이스 드라이버는 네트워크 스택과 네트워크 하드웨어 사이에 위치해 데이터의 송수신을 담당한다. 예) Ethernet, Network interface card struct file_operations file_operations 구조체는 Character Device, Block Device Drive..