Skip to content

sekai ctf 2026

Untitled Encore

Yes, you can no longer make PJSK content with Sonolus.

Challenge Description

Yes, you can no longer make PJSK content with Sonolus.

No, I will not ask you to play with Sonolus...

Wizardry Plan

this chall gave me wizardy dobby gobliny vibe so we are going to talk sorcery here

harry potter type shit

to clarify things ik dobby aint a goblin but i dont want to mention Griphook in my writeup tbh idk why

so the challenge gives a windows program that works like a tiny chart editor

it wants a valid chart

the program text says

text

edit the chart then press enter
ctrl+v paste chart
enter playtest

the ui has 20 rows

each row has these fields

text

lane delta kind flick

so my goal is to recover the 20 row chart that passes playtest

after the right chart is entered the program pops the flag

Finding the eBPF Gremlin

i searched inside the exe for file magic bytes

the elf magic

text

7f 45 4c 46

was found at file offset

text

0xcf00

dumping from there gave

text

elf 64 bit lsb relocatable ebpf stripped

so the real validator was not normal x64 shit

it was embedded ebpf goblin

the exe also copies that embedded blob here

text

140009e11  mov r8d 0xbb8
140009e17  lea rdx 0x14000e700
140009e21  call memcpy

that confirmed the program actually uses the ebpf blob during playtest

The 84 Byte Abracadabra Magic

the chart gets converted into an internal byte buffer

the validator checks the size

text

cmp rax 0x54
jne fail

0x54 is 84

so the real Severus Snape is

text

an 84 byte chart buffer that satisfies the ebpf validator

not raw pasted text

Command Soup from Hell

the ebpf rodata contains an encoded command stream

the real wazaaaa starts at rodata offset

text

0x28

after the spells of decoding the commands the opcode layout is

text

12 x 0x21
20 x 0x44
32 x 0x62
32 x 0x8b
1 x 0xf0

this layout explains the check

20 x 0x44 matches the 20 visible chart rows

Byte Wizard Nonsense

each command is 4 bytes

the decode rule is

Python

tok = cmd[0] ^ ((i * 17 - 0x5d) & 255)
a   = cmd[1] ^ ((i * 29 + 17) & 255)
b   = cmd[2] ^ ((i * 31 + 123) & 255)
c   = cmd[3] ^ ((i * 37 + 197) & 255)

i is the byte offset in the command stream

so it goes

text

0 4 8 12 ...

decoded opcode meaning

text

0x21 fixed bytes
0x44 one chart note
0x62 generated bytes
0x8b scratch bytes
0xf0 valid end

Note Goblin Math

opcode 0x44 checks one chart row

a note is stored as two bytes

Python

lane  = x & 7
kind  = (x >> 3) & 3
flick = (x >> 5) & 1
delta = y

valid note values are

text

lane <= 4
kind <= 2
3 <= delta <= 16

the note check is

Python

h = (x * 17 + y * 31 + state + a * 73) & 0xffff
(((h >> 8) ^ h) & 255) == b

then the state is updated

Python

state = rol32((state ^ h) + ((x << 8) | y) + b,(a & 7) + 1)
(state & 255) == c

the initial state is

text

0x31c3f00d

so the solve is small as fuck

for each 0x44 command i brute magiced

text

5 lanes
3 kinds
2 flick values
14 delta values

then 0x62 and 0x8b are direct calculations

the command stream reaches 0xf0

that is the clean path instead of the MISS path

so the recovered bytes can be turned back into chart rows

pasting those rows makes the same 84 byte buffer again

pressing enter runs the playtest on that buffer

the success branch pops the flag

The Sacred Chart Scroll

text

0 12 0 0
1 7 0 0
2 7 1 0
3 5 0 1
4 13 2 0
3 6 1 0
2 6 1 1
1 11 0 0
0 8 2 0
4 4 0 1
0 9 1 0
1 5 0 0
2 10 2 1
3 5 0 0
4 15 1 0
2 3 0 1
0 12 2 0
4 6 2 1
1 7 1 0
3 9 0 0

paste this whole thing

text

0 12 0 0 1 7 0 0 2 7 1 0 3 5 0 1 4 13 2 0 3 6 1 0 2 6 1 1 1 11 0 0 0 8 2 0 4 4 0 1 0 9 1 0 1 5 0 0 2 10 2 1 3 5 0 0 4 15 1 0 2 3 0 1 0 12 2 0 4 6 2 1 1 7 1 0 3 9 0 0

and voila

Flag

SEKAI{eBPF_my_B3l0v3d}

i tried to make it as wizardy as possible

Discussion

Loading discussion…

Related solves

Keep reading

Complete archive