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 파일로 재 압축한 다음
./ 폴더로 이동시킨다.
다운로드
728x90
반응형
'Kernel Exploit' 카테고리의 다른 글
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 |