kernel exploit helper - gdb, cpio 압축 및 압축해제, 컴파일

2023. 9. 9. 22:34·Kernel Exploit/Theory
728x90
반응형

서론

커널 익스를 하다보면

페이로드를 작성하고, 컴파일하고, cpio 파일을 압축 해제하고, 여기에 컴파일된 파일을 넣고, 다시 압축하는

일련의 과정을 반복하기에 이를 쉘 스크립트로 만들어보았다.

 

사용법

설명서는 아래와 같다.

┌[root🐲 Wyv3rn]-(~/kernel/pwnyable/LK01)
└> ./kernel_helper
Usage: ./kernel_helper [OPTION] OR ./kernel_helper [FILE1] [FILE2] ...
Put this file in same directory with rootfs.cpio

[OPTION]
-ext                     Extract rootfs.cpio to unzip directory.
                         Caution! unzip directory shall be removed if exist.
-mer                     Merge all file in unzip directory to rootfs.cpio.
-gdb                     Start gdb with vmlinux (if exist) and connection to localhost:1234

[FILE1] [FILE2]
File1.c File2.c ...      Compile each file source code and add to rootfs.cpio
                         Caution! unzip directory shall be removed.

기본적으로 rootfs.cpio 파일과 동일한 폴더에 해당 파일이 위치해야한다.

 

cpio 압축 해제하기

./kernel_helper -ext

unzip 디렉토리를 생성하고 rootfs.cpio 파일을 ./unzip 폴더에 압축 해제한다.

 

cpio로 압축하기

./kernel_helper -mer

unzip 디렉토리 내의 파일을 rootfs.cpio 파일로 생성하여 ./ 폴더로 이동시킨다.

* 기존에 ./ 폴더에 있던 rootfs.cpio 파일은 새로 압축된 파일로 교체된다.

 

gdb 실행

./kernel_helper -gdb

gdb를 실행하고 localhost:1234로 접속한다.

 

소스코드 컴파일 및 rootfs.cpio 파일 생성.

./kernel_helper payload.c payload2.c ...

입력된 소스코드를 컴파일하고 (gcc -o payload payload.c -static -no-pie)

./ 디렉토리의 rootfs.cpio 파일을 unzip 디렉토리에 압축해제한다음

컴파일된 파일을 unzip 폴더로 이동하고

rootfs.cpio 파일로 재 압축한 다음

./ 폴더로 이동시킨다.

 

다운로드

kernel_helper
0.00MB

 

728x90
반응형
저작자표시 비영리 변경금지 (새창열림)

'Kernel Exploit > Theory' 카테고리의 다른 글

Kernel - KPTI 우회  (0) 2023.09.10
Kernel - SMAP 우회, krop (간단 글)  (0) 2023.09.10
Kernel - stack pivoting #2 - with xchg  (0) 2023.09.09
Kernel - stack pivoting #1 - with mov esp.  (0) 2023.09.08
Kernel - SMEP 우회, cr4 overwrite #2  (0) 2023.09.08
'Kernel Exploit/Theory' 카테고리의 다른 글
  • Kernel - KPTI 우회
  • Kernel - SMAP 우회, krop (간단 글)
  • Kernel - stack pivoting #2 - with xchg
  • Kernel - stack pivoting #1 - with mov esp.
wyv3rn
wyv3rn
아저씨의 흔한 취미. wyv3rn#1249
  • wyv3rn
    think storage
    wyv3rn
  • 전체
    오늘
    어제
    • 분류 전체보기 (520) N
      • To do list (7)
        • Doing (1)
        • Complete (6)
      • Diary (35)
      • Tips & theory (75)
      • Kernel Exploit (28)
        • Theory (16)
        • Exercise (5)
      • File Structure (6)
      • Wargame (322)
        • pwn.college (34)
        • Dreamhack (156)
        • pwnable.kr (15)
        • Lord of Sqlinjection (4)
        • Cryptohack (20)
        • Root me (27)
        • CodeEngn (4)
        • Exploit Education (22)
        • ROP Emporium (8)
        • H4C (10)
        • Hackerchool (22)
      • CTF (46) N
        • Solved (44) N
        • Unsolved (2)
      • Script (0)
      • RubiyaLap (0)
  • 블로그 메뉴

    • 홈
    • 방명록
  • 링크

  • 공지사항

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

  • 태그

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

  • 최근 글

  • 250x250
    반응형
  • hELLO· Designed By정상우.v4.10.3
wyv3rn
kernel exploit helper - gdb, cpio 압축 및 압축해제, 컴파일
상단으로

티스토리툴바