Exploit databaseDownload repository ZIP
GH-f682c1334366367d649da57393839571
starry2233/cve-2026-25262-poc
Sources for CVE-2026-25262
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files8
starry2233/cve-2026-25262-pocRevision 9a6174dcea2e
- ↑..Parent directory
- README.md
- __init__.py
- mock_device.py
- probe.py
- requirements.txt
- sahara_client.py
- selftest.py
- transport.py
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
poc/selftest.py
Python · 4,892 bytes# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2026 Starry2233
"""无硬件自测:用 MockSaharaDevice 跑通 probe 的全部只读流程。
运行:python -m poc.probe selftest (或 python -m poc.selftest)
"""
from __future__ import annotations
import logging
import struct
import sys
from .mock_device import MockSaharaDevice
from .sahara_client import (
FUSE_ARM,
FUSE_HEXAGON,
PBL_BASE,
SaharaNak,
SaharaSession,
decode_fuse,
scan_strings,
)
OK = "[ ok ]"
FAIL = "[fail]"
class _Checker:
def __init__(self):
self.failures = 0
self.count = 0
def check(self, name: str, cond: bool, detail: str = "") -> None:
self.count += 1
if cond:
print(f"{OK} {name}")
else:
self.failures += 1
print(f"{FAIL} {name} {detail}")
def eq(self, name: str, got, want) -> None:
self.check(name, got == want, f"got={got!r} want={want!r}")
def _fake_memory() -> dict:
"""构造一份带 PBL 特征串和量产 fuse 值的内存镜像(对应 slide 27/43)。"""
pbl = bytearray(0x400)
for off, s in (
(0x238, b'"Q",B0h,"M QUALCOMM COPYRIGHT"'),
(0x3A3, b"MODEM BOOT ROM VERSION: 1.0"),
(0x3BF, b"MODEM PBL VERSION"),
):
pbl[off:off + len(s)] = s
return {
PBL_BASE: bytes(pbl),
FUSE_HEXAGON: struct.pack("<I", 0x00003C50),
FUSE_ARM: struct.pack("<I", 0x000002E1),
}
def run_selftest() -> bool:
logging.basicConfig(level=logging.CRITICAL)
c = _Checker()
print("== Sahara 客户端自测(Mock 设备)==")
dev = MockSaharaDevice(memory=_fake_memory())
ses = SaharaSession(dev, loglevel=logging.CRITICAL)
# --- 1. 握手 + 命令模式 ---
hello = ses.enter_command_mode()
c.eq("HELLO.version", hello["version"], 2)
c.eq("HELLO.max_cmd_len", hello["max_cmd_len"], 0x400)
c.eq("HELLO.mode", hello["mode"], 0) # 设备自述为 IMAGE_TX_PENDING
# --- 2. 身份信息 ---
ident = ses.read_identity()
c.eq("identity.serial", ident.get("serial"), 0x1A2B3C4D)
c.eq("identity.serial_str", ident.get("serial_str"), "1a2b3c4d")
c.eq("identity.hwid", ident.get("hwid"), 0x009600E100000000)
c.check("identity.pkhash", ident.get("pkhash") == bytes(range(32)).hex())
c.eq("identity.sbl_version", ident.get("sbl_version"), 1)
chip = ident.get("chip_id_v3")
c.check(
"identity.chip_id_v3",
isinstance(chip, dict) and chip.get("msm_id") == 0x0000020E,
f"got={chip}",
)
# --- 3. 复位后重新握手,进入 MEMORY_DEBUG ---
ses.reset()
ses2 = SaharaSession(dev, loglevel=logging.CRITICAL)
md = ses2.enter_memory_debug()
c.check("memory_debug.bit64", md["bit64"] is False, str(md))
c.eq("memory_debug.table_addr", md["memory_table_addr"], 0x80000000)
# --- 4. 读 PBL 并提取字符串 ---
data = ses2.read_memory(PBL_BASE, 0x400)
c.eq("read_memory.length", len(data), 0x400)
found = scan_strings(data, 6)
c.check(
"PBL 字符串命中",
any("MODEM BOOT ROM VERSION" in s for s in found),
f"found={found[:5]}",
)
# --- 5. 读 fuse 并解码 ---
hexv = int.from_bytes(ses2.read_memory(FUSE_HEXAGON, 4), "little")
armv = int.from_bytes(ses2.read_memory(FUSE_ARM, 4), "little")
c.eq("fuse.hexagon_raw", hexv, 0x00003C50)
c.eq("fuse.arm_raw", armv, 0x000002E1)
dec = decode_fuse(hexv, armv)
c.check("fuse.hexagon 已熔断", dec["hexagon_secure_boot_blown"] is True, str(dec))
c.check("fuse.hexagon 后门关闭", dec["hexagon_rom_shortcut_open"] is False)
c.check("fuse.arm 已熔断", dec["arm_secure_boot_blown"] is True)
c.check("fuse.arm 后门关闭", dec["arm_rom_shortcut_open"] is False)
# --- 6. 负例:设备拒绝 MEMORY_DEBUG(NAK 0x19 = INVALID_MEMORY_READ) ---
dev_deny = MockSaharaDevice(deny_memory_read=True)
ses3 = SaharaSession(dev_deny, loglevel=logging.CRITICAL)
try:
ses3.enter_memory_debug()
c.check("NAK 应抛异常", False, "没有抛异常")
except SaharaNak as exc:
c.check("NAK 被正确识别", exc.status == 0x19, str(exc))
except Exception as exc: # noqa: BLE001
c.check("NAK 被正确识别", False, f"异常类型不对:{type(exc).__name__}: {exc}")
print()
if c.failures:
print(f"结果:{c.count - c.failures}/{c.count} 通过,{c.failures} 失败")
return False
print(f"结果:{c.count}/{c.count} 全部通过")
return True
def main() -> int:
for stream in (sys.stdout, sys.stderr):
try:
stream.reconfigure(encoding="utf-8", errors="replace")
except Exception: # noqa: BLE001
pass
return 0 if run_selftest() else 1
if __name__ == "__main__":
raise SystemExit(main())