Exploit databaseDownload repository ZIP
GH-9247836616796f879c19808cd689e07b
youssefnoser/opd2415-6.6.118-cve-2026-64560-ksu
Sources for CVE-2026-64560
19 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files20
youssefnoser/opd2415-6.6.118-cve-2026-64560-ksuRevision 1f03ea62a6b3
- ↑..Parent directory
- __init__.py
- fgroot_bridge.py
- fgroot_btf.py
- fgroot_build.py
- fgroot_common.py
- fgroot_config.py
- fgroot_derive.py
- fgroot_disasm.py
- fgroot_elf.py
- fgroot_evidence.py
- fgroot_image.py
- fgroot_kallsyms.py
- fgroot_kallsyms_native.py
- fgroot_patch.py
- fgroot_payload.py
- fgroot_profile.py
- fgroot_render.py
- fgroot_verify.py
- fgroot_vuln.py
- lz4py.py
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
repro/lib/fgroot_profile.py
Python · 9,063 bytes"""profile 载入 / 校验 / 命名。
对齐社区 schema v1(不新增顶层键),我们特有的字段集中在 `fgroot` 对象里,
保证与其它工具的 profile 可以双向交换。
校验是 fail-closed 的:缺哈希、缺 port 块、状态不明、路径越界一律拒绝,
而且**明确说明拒绝理由**(SPEC §4 的导入规则)。
"""
from __future__ import annotations
import re
from pathlib import Path
from .fgroot_common import (
REPO_ROOT,
FailClosed,
kernel_build_hash,
parse_hex,
read_json,
require,
sha256_file,
)
SCHEMA_VERSION = 1
VALID_STATUS = ("draft", "verified", "fixed", "impossible")
VALID_VERDICT = ("READY", "POSSIBLE", "NEEDS_PORT", "FIXED", "UNKNOWN")
_SAFE_NAME = re.compile(r"^[A-Za-z0-9._-]+$")
def profile_path(codename: str, kernel_release: str) -> Path:
"""SPEC §5:profiles/<codename>/<build-or-imagehash>.json"""
build = kernel_build_hash(kernel_release)
return REPO_ROOT / "profiles" / codename.lower() / f"{codename.lower()}-{build}.json"
def symbols_path(kernel_release: str) -> Path:
build = kernel_build_hash(kernel_release)
return REPO_ROOT / "symbols" / f"{build}.evidence.json"
def load(path: Path, *, status: str | None = None) -> dict:
"""
status: None 表示接受任意状态;"executable" 表示只接受可直接执行的 profile
(verified,或显式允许的 draft —— 调用方负责提示)。
"""
data = read_json(path)
validate(data, label=str(path))
if status is not None:
require(
data.get("status") == status,
f"{path}: 需要 status={status},实际 {data.get('status')!r}",
)
return data
def validate(data: dict, *, label: str = "profile", strict: bool = True) -> None:
require(isinstance(data, dict), f"{label}: 顶层不是对象")
require(
data.get("schemaVersion") == SCHEMA_VERSION,
f"{label}: schemaVersion 必须是 {SCHEMA_VERSION}(实际 {data.get('schemaVersion')!r})",
)
status = data.get("status")
require(status in VALID_STATUS, f"{label}: status={status!r} 不认识")
require(data.get("id"), f"{label}: 缺 id")
device = data.get("device")
require(isinstance(device, dict), f"{label}: 缺 device 对象")
for key in ("manufacturer", "model", "codename", "fingerprint", "kernelRelease"):
require(device.get(key), f"{label}: device.{key} 缺失(判定主键依赖它)")
images = data.get("images")
require(isinstance(images, dict), f"{label}: 缺 images 对象")
require(
images.get("decodedImageSha256"),
f"{label}: 缺 images.decodedImageSha256 —— 它是能否复用静态偏移的依据",
)
for key in ("stockBootSha256", "decodedImageSha256"):
value = images.get(key)
if value is not None:
require(
isinstance(value, str) and len(value) == 64,
f"{label}: images.{key} 不是 sha256 十六进制串",
)
artifacts = data.get("artifacts")
require(isinstance(artifacts, dict), f"{label}: 缺 artifacts 对象")
su = artifacts.get("su")
if strict:
require(isinstance(su, dict), f"{label}: artifacts.su 缺失")
if su.get("pending"):
# 显式的"还没产出"标记(新机型在拿到 NDK 之前就是这种状态):
# 不允许拿一个假哈希顶上,但允许如实标记为待产出,并在 profile-check 里显示出来。
require(su.get("note"),
f"{label}: artifacts.su 标了 pending 就必须写清楚原因(note)")
else:
require(su.get("sha256"), f"{label}: artifacts.su 缺 sha256(或显式标 pending: true)")
for entry in artifacts.get("strategies") or []:
if strict:
require(entry.get("name"), f"{label}: strategies[] 有条目缺 name")
port = data.get("port")
if port is not None:
require(port.get("profileName"), f"{label}: port.profileName 缺失")
require(port.get("device"), f"{label}: port.device 缺失")
require(isinstance(port.get("link"), dict) and port["link"],
f"{label}: port.link 为空")
require(isinstance(port.get("direct"), dict) and port["direct"],
f"{label}: port.direct 为空")
outputs = port.get("outputs")
require(isinstance(outputs, list) and outputs, f"{label}: port.outputs 为空")
for entry in outputs:
require(entry.get("source") and entry.get("path"),
f"{label}: port.outputs[] 条目缺 source/path")
_reject_escape(entry["source"], label)
_reject_escape(entry["path"], label)
for name, value in list(port["link"].items()) + list(port["direct"].items()):
parse_hex(value) # 解析失败即抛错
fgroot = data.get("fgroot") or {}
require(isinstance(fgroot, dict), f"{label}: fgroot 必须是对象")
verdict = (fgroot.get("verdict") or {}).get("state")
if verdict is not None:
require(verdict in VALID_VERDICT, f"{label}: fgroot.verdict.state={verdict!r} 不认识")
def _reject_escape(rel: str, label: str) -> None:
if rel.startswith("/") or ".." in Path(rel).parts or Path(rel).is_absolute():
raise FailClosed(f"{label}: 路径越界/绝对路径被拒绝: {rel!r}")
for part in Path(rel).parts:
require(_SAFE_NAME.match(part) or part in ("src", "build", "bin"),
f"{label}: 路径段 {part!r} 不在白名单字符集内")
def artifact_status(profile: dict, *, root: Path = REPO_ROOT) -> list[dict]:
"""核对 profile 里声明的 sha256 与磁盘上产物是否一致(缺文件不算失败,只标注)。"""
rows: list[dict] = []
artifacts = profile.get("artifacts") or {}
entries = []
if isinstance(artifacts.get("su"), dict):
entries.append(("su", artifacts["su"]))
for entry in artifacts.get("strategies") or []:
entries.append((entry.get("name", "?"), entry))
for entry in artifacts.get("notPromoted") or []:
entries.append((entry.get("name", "?"), entry))
for name, entry in entries:
if entry.get("pending"):
rows.append({"name": name, "path": entry.get("path"), "declared": None,
"actual": None, "match": None, "pending": True})
continue
path = root / (entry.get("path") or "")
row = {"name": name, "path": entry.get("path"), "declared": entry.get("sha256")}
if path.is_file():
actual = sha256_file(path)
row["actual"] = actual
row["match"] = (actual == entry.get("sha256"))
else:
row["actual"] = None
row["match"] = None
rows.append(row)
return rows
def target_spec(profile: dict) -> dict:
"""把 profile 的渲染输入整理成一个不依赖 profile 内部结构的描述子。"""
port = profile["port"]
fgroot = profile.get("fgroot") or {}
# 我们特有的开关放在 fgroot.render 里(SPEC §4:特有字段不往 port/顶层塞),
# 但兼容直接写在 port 里的老写法。
render_cfg = fgroot.get("render") or {}
def switch(name: str, default):
return render_cfg.get(name, port.get(name, default))
physical_delta = (port.get("physicalDelta")
or (profile.get("derivation") or {}).get("physical", {}).get("physicalDelta"))
return {
"profilePath": None,
"profileName": port["profileName"],
"profileId": profile["id"],
"device": port["device"],
"fingerprint": port.get("fingerprint") or profile["device"]["fingerprint"],
"kernelRelease": profile["device"]["kernelRelease"],
"kernelBuild": kernel_build_hash(profile["device"]["kernelRelease"]),
# 兜底值:profile 没写 port.macro 时用本仓库的目标名(各 profile 正常都会显式写)。
"macro": switch("macro", "PLZ110"),
"link": {k: parse_hex(v) for k, v in port["link"].items()},
"direct": {k: parse_hex(v) for k, v in port["direct"].items()},
"tuning": port.get("tuning") or {},
"outputs": port["outputs"],
"headerStyle": switch("headerStyle", "community"),
"envLayer": switch("envLayer", "none"),
"gateHint": bool(switch("gateHint", False)),
"kernelGate": bool(switch("kernelGate", False)),
"physicalDelta": physical_delta,
"files": fgroot.get("files") or {},
"structure": fgroot.get("structure") or {},
#: 6.12 移植补丁(见 repro/lib/fgroot_render.py 的 PORT_PATCHES)
"portPatches": (fgroot.get("port") or {}).get("patches") or [],
#: 移植补丁换掉的"宏 → 符号"(null = 不再使用),见 fgroot_evidence.symbol_requirements
"portSymbols": (fgroot.get("port") or {}).get("symbols") or {},
}
def verdict(profile: dict) -> dict:
return (profile.get("fgroot") or {}).get("verdict") or {}