Exploit database

GH-9247836616796f879c19808cd689e07b

youssefnoser/opd2415-6.6.118-cve-2026-64560-ksu

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-64560

18 sources

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

Repository files20

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

repro/lib/fgroot_common.py

Python · 4,554 bytes
"""FGroot 复现流水线的公共部件。

设计约束(来自 SPEC/HANDOFF 的验收要求):

* **fail-closed**:缺证据、证据冲突、尺寸/哈希不符一律抛错退出,绝不"猜一个值继续";
* **零第三方依赖**:只用 CPython 标准库,任何能跑 python3 的地方都能跑;
* **每一步都可复核**:每个阶段把输入哈希、参数、结论写进 JSONL 记录。

本模块只放纯函数与小工具,不做任何设备写入。
"""

from __future__ import annotations

import hashlib
import json
import os
import re
import sys
from dataclasses import dataclass, field
from pathlib import Path

# --------------------------------------------------------------------------
# 常量:本仓库使用的固定身份
# --------------------------------------------------------------------------

REPO_ROOT = Path(__file__).resolve().parents[2]

#: arm64 Linux 内核 Image 的逻辑基址(GKI 4K 页,48-bit VA)
KIMAGE_VADDR = 0xFFFFFFC080000000
#: 线性映射(direct map)基址
PAGE_OFFSET = 0xFFFFFF8000000000
#: 本目标平台(Qualcomm sun / GKI)的物理装载参数,需按平台单独取证
DEFAULT_PHYS_OFFSET = 0x80000000
DEFAULT_KERNEL_PHYS_LOAD = 0xA8000000

#: 从 kernelRelease 里取构建号段:6.6.118-android15-8-g<12hex>-abogki...-4k
KERNEL_BUILD_RE = re.compile(r"-g([0-9a-f]{8,16})(?:-|$)")


class FailClosed(RuntimeError):
    """流水线的统一失败类型:消息必须写清"发生了什么 + 依据 + 该做什么"。"""


def require(condition: bool, message: str) -> None:
    if not condition:
        raise FailClosed(message)


def kernel_build_hash(release: str) -> str:
    """从 kernelRelease 抽出构建号段(profile 判定主键)。"""
    m = KERNEL_BUILD_RE.search(release or "")
    if not m:
        raise FailClosed(
            f"kernelRelease 无法解析出构建号段: {release!r};"
            "profile 的主键依赖它(形如 6.6.118-android15-8-g9bc34d5b0c79-abogki...-4k)"
        )
    return m.group(1)


def sha256_file(path: Path, chunk: int = 1 << 20) -> str:
    h = hashlib.sha256()
    with open(path, "rb") as fh:
        while True:
            block = fh.read(chunk)
            if not block:
                break
            h.update(block)
    return h.hexdigest()


def sha256_bytes(data: bytes) -> str:
    return hashlib.sha256(data).hexdigest()


def read_json(path: Path) -> dict:
    try:
        return json.loads(Path(path).read_text(encoding="utf-8"))
    except FileNotFoundError as exc:
        raise FailClosed(f"缺少文件: {path}") from exc
    except json.JSONDecodeError as exc:
        raise FailClosed(f"JSON 解析失败: {path}: {exc}") from exc


def write_json(path: Path, data: dict) -> None:
    path = Path(path)
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")


def write_text(path: Path, text: str) -> None:
    path = Path(path)
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(text, encoding="utf-8")


def parse_hex(value) -> int:
    if isinstance(value, int):
        return value
    if isinstance(value, str):
        return int(value, 0)
    raise FailClosed(f"无法解析为整数: {value!r}")


# --------------------------------------------------------------------------
# 阶段日志:每轮把"输入哈希 / 参数 / 结论"落到磁盘,中途失败也有现场
# --------------------------------------------------------------------------


@dataclass
class StageLog:
    """一次流水线运行的记录器;每行一条 JSON,立即 flush。"""

    path: Path | None = None
    verbose: bool = True
    entries: list[dict] = field(default_factory=list)

    def record(self, stage: str, **fields) -> dict:
        entry = {"stage": stage, **fields}
        self.entries.append(entry)
        if self.path:
            self.path.parent.mkdir(parents=True, exist_ok=True)
            with open(self.path, "a", encoding="utf-8") as fh:
                fh.write(json.dumps(entry, ensure_ascii=False) + "\n")
                fh.flush()
                os.fsync(fh.fileno())
        if self.verbose:
            detail = " ".join(f"{k}={v}" for k, v in fields.items())
            print(f"[{stage}] {detail}", file=sys.stderr, flush=True)
        return entry


def die(message: str, code: int = 2) -> "NoReturn":  # type: ignore[valid-type]
    print(f"fgroot: 失败: {message}", file=sys.stderr, flush=True)
    raise SystemExit(code)