Exploit database

GH-e2bb33f25c5dfe2d640cadf16e3f502b

sangsheng2026/honor-90gt-mag-an00-root-research

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-64560

19 sources

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

Repository files13

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

tools/devprobe.c

C · 3,804 bytes
/*
 * Which /dev nodes can the Android shell domain actually open?
 *
 * Vendor-driver exploits (kgsl / Adreno, IPA, DSP, diag, ashmem, ...) are the
 * usual Android root path, and whether any of them is reachable from
 * uid 2000 / u:r:shell:s0 is decided entirely by the device node's SELinux
 * label and permissions.  This enumerates /dev, prints each entry with its
 * label, and tries to open the character devices the way an exploit would.
 *
 * Opens are O_RDWR|O_NONBLOCK|O_CLOEXEC and are closed immediately; nothing is
 * read, written or ioctl'd, so this is a pure capability probe.
 *
 * Usage: devprobe [dir...]      (default: /dev and its immediate subdirs)
 */
#define _GNU_SOURCE
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/xattr.h>
#include <sys/types.h>
#include <unistd.h>

#define MAXENT 4096

struct entry {
    char path[512];
    char label[256];
    int is_chr;
    int rdwr;
    int rdonly;
    int err;
};

static int try_open(const char *path, int flags)
{
    int fd = open(path, flags | O_NONBLOCK | O_CLOEXEC);

    if (fd < 0)
        return -errno;
    close(fd);
    return 0;
}

static void read_label(const char *path, char *out, size_t n)
{
    char proc[600];
    int fd;
    ssize_t r;

    /* /proc/self/attr/current is only our own label, so use the xattr-style
     * interface that adb's ls -Z uses: read the "security.selinux" xattr. */
    out[0] = 0;
    snprintf(proc, sizeof(proc), "%s", path);
    fd = open(proc, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
    if (fd >= 0) {
        char buf[256];
        r = fgetxattr(fd, "security.selinux", buf, sizeof(buf) - 1);
        if (r > 0) {
            buf[r] = 0;
            snprintf(out, n, "%s", buf);
        }
        close(fd);
    }
}

int main(int argc, char **argv)
{
    static struct entry ents[MAXENT];
    const char *dirs[64];
    int ndirs = 0, n = 0;

    setvbuf(stdout, NULL, _IOLBF, 0);

    if (argc > 1) {
        for (int i = 1; i < argc && ndirs < 64; i++)
            dirs[ndirs++] = argv[i];
    } else {
        dirs[ndirs++] = "/dev";
    }

    for (int d = 0; d < ndirs; d++) {
        DIR *dir = opendir(dirs[d]);
        struct dirent *de;

        if (!dir) {
            printf("opendir %s failed errno=%d\n", dirs[d], errno);
            continue;
        }
        while ((de = readdir(dir)) != NULL && n < MAXENT) {
            struct stat st;
            struct entry *e = &ents[n];

            if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
                continue;
            snprintf(e->path, sizeof(e->path), "%s/%s", dirs[d], de->d_name);
            if (lstat(e->path, &st))
                continue;
            e->is_chr = S_ISCHR(st.st_mode);
            if (!e->is_chr && !S_ISBLK(st.st_mode))
                continue;
            e->rdwr = try_open(e->path, O_RDWR);
            e->rdonly = try_open(e->path, O_RDONLY);
            read_label(e->path, e->label, sizeof(e->label));
            n++;
        }
        closedir(dir);
    }

    printf("DEVPROBE entries=%d  (mode: rdwr = open(O_RDWR), rd = open(O_RDONLY))\n", n);
    printf("%-34s %-8s %-10s %-10s %s\n", "PATH", "TYPE", "RDWR", "RDONLY", "SELINUX LABEL");
    for (int i = 0; i < n; i++) {
        struct entry *e = &ents[i];
        char a[16], b[16];

        if (e->rdwr == 0)
            snprintf(a, sizeof(a), "OK");
        else
            snprintf(a, sizeof(a), "%d", -e->rdwr);
        if (e->rdonly == 0)
            snprintf(b, sizeof(b), "OK");
        else
            snprintf(b, sizeof(b), "%d", -e->rdonly);
        printf("%-34s %-8s %-10s %-10s %s\n", e->path,
               e->is_chr ? "char" : "block", a, b, e->label);
    }
    printf("DEVPROBE_DONE\n");
    return 0;
}