QWB2018 - core
Created|Updated
|Post Views:
PART I
unpack
1 | loo@localhost:~/ctf/kernel/xiaozaiya/kernel-PWN/QWB2018-core/tar/try$ ls |
1 | loo@localhost:~/ctf/kernel/xiaozaiya/kernel-PWN/QWB2018-core/tar/try$ file core.cpio.gz |
- gzip ->
gunzip ./core.cpio.gz
->./core.cpio
md core && cd core && cpio -idv < ../core.cpio
start.sh
1 | qemu-system-x86_64 \ |
Runnable
1 | qemu-system-x86_64 \ |
- -s : qemu调试
- 开启
pti
和kaslr
panic=0
kernel panic之后停止重启,避免陷入死循环
init
1 | #!/bin/sh |
- root权限
setsid /bin/cttyhack setuidgid 0 /bin/sh
pack
find ./core | cpio -o -H newc > ./core.cpio
❌find ./core | cpio -o --format=newc > ./core.cpio
❌
1 | cd ./core |
1 | [ 0.023397] Spectre V2 : Spectre mitigation: LFENCE not serializing, switching to generic retpoline |
gcc -g -o pwwn ./pwwn.c ~/pwnlib.c -I ~ -static -masm=intel
exp.sh
1 | cd ./core |
PART II
pti
&kaslr
1 | loo@localhost:~/ctf/kernel/xiaozaiya/kernel-PWN/QWB2018-core/core$ fileplus ./core.ko |
1 | loo@localhost:~/ctf/kernel/xiaozaiya/kernel-PWN/QWB2018-core/core$ checksec core.ko |
overflow
qmemcpy(v2, &bss_name, length);
汇编如下
1 | .text:0000000000000120 movzx ecx, bx |
向core_copy_func
传入0xffffffffffff0000 | overflow_lenth
exp
1 | #include "pwnlib.h" |
gdb.sh
1 | target remote :1234 |
PART III
Q(A)
Q
1 | void main(){ |
当下面没有调用的时候会导致实际上没写上,需要先调用一次😶🌫️?
貌似第一次编译会优化掉,在用户态调用一次之后注释掉用户态调用,之后也不会出现问题
Q&A
1 | loo@localhost:~/ctf/kernel/xiaozaiya/kernel-PWN/QWB2018-core$ ./myexp.sh |
c语言程序中使用了寄存器的名称作为变量名
Q
1 | loo@localhost:~/ctf/kernel/xiaozaiya/kernel-PWN/QWB2018-core$ ROPgadget --binary ./vmlinux --only "pop" | grep ret |
ROPgadget使用–only找不到
ropper很慢
以前好像不是这样
Q&A
打包太慢
pack的时候加上-v选项帮查找问题所在,删掉他们 <- vmlinux
Q&A
iretq要求栈结构
1 | 00:0000│ rsp 0xfffffe00000021d8 —▸ 0x401c96 (getshell) ◂— endbr64 |
iretq_struct |
---|
ret_addr |
user_cs |
user_rflags |
user_sp |
user_ss |
op
ctrl+a c
+q
cpio -t < ./core.cpio
lsmod
dmesg
cpio -ov -H newc > ../core.cpio
strings ./vmlinux | grep -i "linux version"
cat /proc/kallsyms | grep "T _stext"
参考
Author: John Doe
Copyright Notice: All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Related Articles
2025-06-20
MINI-LCTF2022 - kgadget
PART Iunpack1234567loo@localhost:~/ctf/kernel/xiaozaiya/kernel-PWN/kgadget/try$ tar -xvf ./kgadget.tar.xzbzImageREADME.mdrootfs.cpiorun.shloo@localhost:~/ctf/kernel/xiaozaiya/kernel-PWN/kgadget/try$ lsREADME.md bzImage kgadget.tar.xz rootfs.cpio run.sh 12loo@localhost:~/ctf/kernel/xiaozaiya/kernel-PWN/kgadget$ file rootfs.cpiorootfs.cpio: ASCII cpio archive (SVR4 with no CRC) md core && cd ./core && cpio -idv <...
2025-06-20
CISCN2017-babydriver
PART Iunpack12loo@localhost:~/ctf/kernel/xiaozaiya/kernel-PWN/CISCN2017-babydriver/try$ file ./rootfs.cpio./rootfs.cpio: ASCII cpio archive (SVR4 with no CRC) md core && cd ./core && cpio -idv < ../rootfs.cpio start.sh12345678910111213#!/bin/bashqemu-system-x86_64 \-initrd rootfs.cpio \-kernel bzImage \-cpu kvm64,+smep \-append 'console=ttyS0 root=/dev/ram kpti=1 nokaslr oops=panic panic=1' \-monitor /dev/null \-enable-kvm \-m 256M \--nographic \-smp...
2025-06-20
~/kernel
“少上网多读书” – arttnba3 结构体,函数以及变量结构体多起来之后有点乱,整理在这里 struct cred 4.4.72 12345678910111213141516171819202122232425262728293031323334353637383940struct cred { atomic_t usage; /* 0 4 */ kuid_t uid; /* 4 4 */ //不知道什么用,参考作用 kgid_t gid; /* 8 4 */ kuid_t suid; /* 12 4 */ ...
2025-07-26
ISCC2025-EBPF
to be continued… PART Iunpack allinone.sh run.sh12345678910111213#!/bin/shqemu-system-x86_64 \ -m 512M \ -cpu qemu64,+smep,+smap -smp 2 \ -kernel bzImage \ -append "console=ttyS0 quiet panic=-1 nokaslr" \ -initrd rootfs.cpio \ -drive file=./flag,if=virtio,format=raw,readonly=on \ -nographic \ -net nic,model=e1000 \ -no-reboot \ -monitor /dev/null runable 123456789101112131415#!/bin/shqemu-system-x86_64 \ ...
2025-08-10
2021QWB--notebook
2025-08-04
LLVM PASS PWN
知LLVM(Low Level Virtual Machine)的设计理念 统一(LLVM IR) 编译器通常分成三部分: 前端:对源码进行不完全处理 -> 中端:对前端产物优化 后端:得到机器码 llvm passllvm pass -> llvm IR 处理 pass的基本类型: 分析型pass 转换型pass 实用型pass * pass的处理单位: 处理函数:FounctionPass 处理模块:ModulePass 处理单个基本块:BasicBlockPass 处理循环:LoopPass clang和llvm123456# Ubuntu-18.04sudo apt install clang-8sudo apt install llvm-8sudo apt install clang-10sudo apt install llvm-10 编译123456789101112131415161718# pass# 编译clang-10 -g -c -fPIC -fno-rtti ./Hello.cpp -o Hello.o...