Kernel ROP, Pivots and the KPTI Trampoline


Kernel Exploitation: A CTF Study Path.

Once SMEP and SMAP are on, you can no longer run or read your own pages from the kernel. Code reuse is the answer: chain gadgets from the kernel image itself. KPTI adds a second wrinkle: you must switch page tables back before returning to userland.

What you will learn

  • Leaking the stack canary and the kernel base (KASLR) from info leaks
  • Building kernel ROP chains with gadgets from vmlinux
  • Returning to userland under KPTI (the swapgs_restore_regs_and_return_to_usermode trampoline, or signal-handler tricks)
  • Stack pivots when you control RIP but not the stack (pivot gadgets, predictable kernel data, pt_regs)
  • Turning a non-stack primitive (OOB index, interpreter bug) into a ROP chain

Prerequisites

Module 01. Comfortable with userland ROP.

References



Challenges

L3akCTF 2024 · difficulty ★☆☆☆☆ · module: Kernel ROP, Pivots and the KPTI Trampoline

A straightforward kernel stack overflow; the canonical first kernel ROP chain.

Mitigations: SMEP, SMAP, KPTI, KASLR, oops=panic

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, rootfs.cpio, run.sh.

Original challenge

Description

I was tryna crack the kernel base 'til my mate goes, "just peep the notes, bruv."

Points

Unknown

Solves

Unknown

Credits

  • Challenge author(s): pipironi, for L3akCTF 2024
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

K3RN3LCTF 2021 · difficulty ★★☆☆☆ · module: Kernel ROP, Pivots and the KPTI Trampoline

A stack bug in a module, guarded by a canary and KASLR: leak what you need, then return to userland cleanly.

Mitigations: SMEP, SMAP, KASLR

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, initramfs.cpio.gz, launch.sh, vuln.ko.

Original challenge

Description

If you have never done kernel pwn before, check out this: https://lkmidas.github.io/posts/20210123-linux-kernel-pwn-part-1/

Points

480

Solves

16

Credits

  • Challenge author(s): Seal, for K3RN3LCTF 2021
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

GACTF 2020 · difficulty ★★★☆☆ · module: Kernel ROP, Pivots and the KPTI Trampoline

A module that mixes heap and stack bugs; combine them into one chain to gain control of execution.

Mitigations: SMEP, SMAP, KASLR

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. /home/hacker/exploit is not copied into this VM. The console runs the /easy_kernel menu program as uid 1000, not a shell: the way in is through that program. The program needs AVX, so the CPU model differs from the original kvm64,+smep,+smap (+xsave,+avx under KVM, max under TCG).

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, rootfs.img, start_vm.sh.

Original challenge

Description

hint1:
放出一个带符号的文件供参考
链接:https://pan.baidu.com/s/1tAOPa-e7bWXS-yFvnRkxZA
提取码:vfor
released a symbol file to reference
https://drive.google.com/file/d/1yipOdfj6fdQDxZ_900-SfO4LXtVP5rDf/view?usp=sharing

hint2:
自定义系统调用源码
链接:https://pan.baidu.com/s/16v4vsHUvoHGoqKTjnhEEvQ
提取码:vfor
custom syscall source
https://drive.google.com/file/d/1Err6sJ9dyvoWkcay8VedjEZDKHE4HQLx/view?usp=sharing

URL
China:124.70.135.106:12574
Overseas: 149.28.31.156:12574

Points

952

Solves

2

Credits

  • Challenge author(s): not recorded (credit goes to the GACTF 2020 organizers)
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

ImaginaryCTF 2023 · difficulty ★★★☆☆ · module: Kernel ROP, Pivots and the KPTI Trampoline

A driver that lets you peek a little and write a little too much on the stack.

Mitigations: SMEP, SMAP, KPTI (kernel default; depends on the host CPU), no KASLR (nokaslr), stack canary, oops=panic

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, decompress.sh, gdb.sh, initramfs.cpio, run.sh, src/Makefile, src/exploit.c.

Original challenge

Description

Sometimes, there is a glimmer of hope, a spark of inspiration, a window of opportunity.

Attachments
https://imaginaryctf.org/r/izYM0#opportunity_dist.zip 

Points

490

Solves

11

Credits

  • Challenge author(s): Eth007, for ImaginaryCTF 2023
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

zer0pts CTF 2022 · difficulty ★★★☆☆ · module: Kernel ROP, Pivots and the KPTI Trampoline

An index check that forgets about negative numbers; escalate it into full kernel code execution and get back to userland cleanly.

Mitigations: SMEP, SMAP, KPTI, KASLR, oops=panic

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. /home/hacker/exploit is not copied into this VM. There is no shell: /root/interface runs as root on the console and you drive its menu remotely (kernel RCE). Invalid input ends the session. In this dojo the flag is /root/flag.txt.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, rootfs.cpio, src/buffer.c, src/interface.c, start-qemu.sh.

Original challenge

Description

Full chain...?

Points

304

Solves

8

Credits

  • Challenge author(s): ptr-yudai, for zer0pts CTF 2022
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

DEF CON CTF Qualifier 2026 · difficulty ★★★☆☆ · module: Kernel ROP, Pivots and the KPTI Trampoline

A tiny in-kernel interpreter with a bounds check that does not quite hold; a classic road to kernel ROP.

Mitigations: SMEP, SMAP, KASLR, SMP 1

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): README.txt, bzImage, coalmine.ko, initramfs.cpio, run.sh.

Original challenge

Description

We put a little too much faith in the canary, and not enough in our QEMU version...

Points

299

Solves

31

Credits

  • Challenge author(s): n00bi3s, for DEF CON CTF Qualifier 2026
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

bi0sCTF 2022 · difficulty ★★★☆☆ · module: Kernel ROP, Pivots and the KPTI Trampoline

A driver hands back memory it never cleared; leaks first, then control flow through a well-known kernel object.

Mitigations: KPTI (kernel default; depends on the host CPU), KASLR

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, rootfs.cpio, run.sh.

Original challenge

Description

32 bytes is all you get, or is it? :-O

Points

1000

Solves

1

Credits

  • Challenge author(s): k1R4, for bi0sCTF 2022
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

SCTF 2023 · difficulty ★★★★☆ · module: Kernel ROP, Pivots and the KPTI Trampoline

One read and one stack pointer: find somewhere in the kernel where your data sits at a predictable address.

Mitigations: SMEP, SMAP, KASLR, KPTI (kernel default; depends on the host CPU), oops=panic

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. The VM powers off 120 seconds after boot, as in the original.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, rootfs.cpio, start.sh.

Original challenge

Description

This rop seems different : )


google drive:https://drive.google.com/file/d/1fADK9biFO1-63Ig7NaK7H_DiY0hHXehh/view?usp=sharing
baiduyun:https://pan.baidu.com/s/1aG6sfgVeSGpiaqYfOY5z2g?pwd=SCTF
提取码:SCTF

POW solve.py has been released : https://pastebin.com/ZkCs6jj3

Points

714

Solves

9

Credits

  • Challenge author(s): pray77, for SCTF 2023
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

BackdoorCTF 2025 · difficulty ★★★★☆ · module: Kernel ROP, Pivots and the KPTI Trampoline

A kmalloc-64 object outlives its owner, and winning a race is part of making it useful.

Mitigations: SMEP, SMAP, KASLR, nopti

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, chall.ko, initramfs.cpio, run.sh.

Original challenge

Description

Just another kernel exploitation challenge :)

https://drive.google.com/drive/folders/1i1SwDUO-AhaB1Q9GyItAILIBWFMzOwB4?usp=sharing

Points

493

Solves

5

Credits

  • Challenge author(s): sh4dy, for BackdoorCTF 2025
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

DiceCTF 2025 Quals · difficulty ★★★★☆ · module: Kernel ROP, Pivots and the KPTI Trampoline

One byte too far is all you get; make a single-byte overflow count.

Mitigations: SMEP, SMAP, KASLR, KPTI (kernel default; depends on the host CPU)

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): Makefile, af_unix.c.patch, bzImage, initramfs.cpio.gz, kconfig, linux.dockerfile, run.sh.

Original challenge

Description

The most common type of oboe, the soprano oboe pitched in C, measures roughly 65 cm long and has metal keys, a conical bore and a flared bell.

Points

214

Solves

16

Credits

  • Challenge author(s): enzocut, for DiceCTF 2025 Quals
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

30-Day Scoreboard:

This scoreboard reflects solves for challenges in this module after the module launched in this dojo.

Rank Hacker Badges Score