Exploit databaseDownload repository ZIP
GH-d040af49f7627d91b0e314e6400f7010
creeeeger/cve-2024-56426
Sources for CVE-2024-56426
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files3
creeeeger/cve-2024-56426Revision 3d6d94a21066
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
ui/app.js
JavaScript · 25,500 bytes"use strict";
const token = new URLSearchParams(window.location.search).get("token") || "";
const state = {
models: [],
actions: [],
workflows: [],
fuseProfiles: [],
safety: {},
fuseAcknowledgements: {
permanent: false,
stock: false,
leftOk: false,
},
stageStatus: {},
selectedWorkflowId: "install_rom",
activeJobId: null,
logCursor: 0,
pollTimer: null,
toastTimer: null,
};
const elements = {
globalModel: document.querySelector("#global-model"),
globalFuseProfile: document.querySelector("#global-fuse-profile"),
fuseProfileDetail: document.querySelector("#fuse-profile-detail"),
fuseConfirmDialog: document.querySelector("#fuse-confirm-dialog"),
fuseCheckPermanent: document.querySelector("#fuse-check-permanent"),
fuseCheckStock: document.querySelector("#fuse-check-stock"),
fuseConfirmLeft: document.querySelector("#fuse-confirm-left"),
fuseCancelRight: document.querySelector("#fuse-cancel-right"),
keyBundlePath: document.querySelector("#key-bundle-path"),
efuseFingerprint: document.querySelector("#efuse-fingerprint"),
runtimeChip: document.querySelector("#runtime-chip"),
dependencyGroups: document.querySelector("#dependency-groups"),
refreshDependencies: document.querySelector("#refresh-dependencies"),
workflowChooser: document.querySelector("#workflow-chooser"),
stageGrid: document.querySelector("#stage-grid"),
consoleOutput: document.querySelector("#console-output"),
consoleStage: document.querySelector("#console-stage"),
consoleStatus: document.querySelector("#console-status"),
cancelJob: document.querySelector("#cancel-job"),
copyLog: document.querySelector("#copy-log"),
clearLog: document.querySelector("#clear-log"),
repoPath: document.querySelector("#repo-path"),
toast: document.querySelector("#toast"),
};
function api(path, options = {}) {
const headers = new Headers(options.headers || {});
headers.set("X-Control-Center-Token", token);
if (options.body) {
headers.set("Content-Type", "application/json");
}
return fetch(path, {...options, headers}).then(async (response) => {
const payload = await response.json().catch(() => ({}));
if (!response.ok) {
throw new Error(payload.error || `Request failed with status ${response.status}`);
}
return payload;
});
}
function showToast(message, error = false) {
window.clearTimeout(state.toastTimer);
elements.toast.textContent = message;
elements.toast.classList.toggle("error", error);
elements.toast.classList.add("visible");
state.toastTimer = window.setTimeout(() => elements.toast.classList.remove("visible"), 4200);
}
function statusText(status) {
const labels = {
idle: "Not run",
queued: "Queued",
running: "Running",
cancelling: "Stopping",
passed: "Passed",
failed: "Failed",
cancelled: "Cancelled",
};
return labels[status] || status;
}
function setConsoleStatus(status) {
elements.consoleStatus.className = `status-label ${status || "idle"}`;
elements.consoleStatus.textContent = (status || "idle").toUpperCase();
}
function stripAnsi(value) {
return value.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "");
}
function appendConsole(lines) {
if (!Array.isArray(lines) || lines.length === 0) {
return;
}
const wasNearBottom = elements.consoleOutput.scrollHeight - elements.consoleOutput.scrollTop
- elements.consoleOutput.clientHeight < 80;
elements.consoleOutput.textContent += stripAnsi(lines.join(""));
if (wasNearBottom) {
elements.consoleOutput.scrollTop = elements.consoleOutput.scrollHeight;
}
}
function renderDependencies(dependencies) {
const groups = new Map();
for (const dependency of dependencies) {
if (!groups.has(dependency.group)) {
groups.set(dependency.group, []);
}
groups.get(dependency.group).push(dependency);
}
elements.dependencyGroups.replaceChildren();
for (const [groupName, items] of groups.entries()) {
const group = document.createElement("article");
group.className = "dependency-group";
const title = document.createElement("h3");
title.textContent = groupName;
const list = document.createElement("div");
list.className = "dependency-list";
for (const dependency of items) {
const item = document.createElement("div");
item.className = `dependency-item ${dependency.found ? "found" : "missing"}`;
item.title = dependency.detail;
const dot = document.createElement("span");
dot.className = "dependency-dot";
dot.setAttribute("aria-label", dependency.found ? "Found" : "Missing");
const body = document.createElement("div");
const name = document.createElement("span");
name.className = "dependency-name";
name.textContent = dependency.label;
const detail = document.createElement("span");
detail.className = "dependency-detail";
detail.textContent = dependency.detail;
body.append(name, detail);
item.append(dot, body);
list.append(item);
}
group.append(title, list);
elements.dependencyGroups.append(group);
}
}
function buildCheckbox(name, label, checked = false, extraClass = "") {
const wrapper = document.createElement("label");
wrapper.className = `check-option ${extraClass}`.trim();
const input = document.createElement("input");
input.type = "checkbox";
input.name = name;
input.checked = checked;
const text = document.createElement("span");
text.textContent = label;
wrapper.append(input, text);
return wrapper;
}
function currentFuseProfile() {
return elements.globalFuseProfile.value || "stay_unfused";
}
function actionNoFuse(card) {
const strategy = card?.dataset.noFuse || "none";
if (strategy === "always") {
return true;
}
return strategy === "profile" && currentFuseProfile() === "stay_unfused";
}
function updateGlobalSafety() {
const profile = state.fuseProfiles.find((candidate) => candidate.id === currentFuseProfile());
elements.fuseProfileDetail.textContent = profile?.description || "Select a fuse state and intent.";
elements.fuseProfileDetail.classList.toggle("danger", currentFuseProfile() !== "stay_unfused");
elements.keyBundlePath.textContent = state.safety.keys_dir || "Unavailable";
elements.efuseFingerprint.textContent = state.safety.efuse_fingerprint || "Unavailable";
document.querySelectorAll(".global-target-value").forEach((node) => {
node.textContent = elements.globalModel.value;
});
document.querySelectorAll(".profile-note").forEach((node) => {
const card = node.closest(".stage-card");
const noFuse = actionNoFuse(card);
const ufs = card?.dataset.action === "ufs";
node.classList.toggle("danger", ufs || !noFuse);
node.textContent = ufs
? "WARNING: UFS boots the LK already installed on the device. The no-fuse profile only affects host-side preflight and does not protect this UFS boot."
: noFuse
? "No-fuse LK: five identified custom-key OTP patch rows are disabled for this build/send step."
: "Fusing-capable LK: custom-key OTP patches remain enabled. A later execution boundary can permanently enroll the key.";
});
refreshStageStatuses();
}
function renderWorkflowChooser() {
elements.workflowChooser.replaceChildren();
for (const workflow of state.workflows) {
const button = document.createElement("button");
button.type = "button";
button.className = "workflow-choice";
button.dataset.workflow = workflow.id;
button.setAttribute("role", "tab");
const selected = workflow.id === state.selectedWorkflowId;
button.classList.toggle("active", selected);
button.setAttribute("aria-selected", String(selected));
const name = document.createElement("strong");
name.textContent = workflow.name;
const description = document.createElement("span");
description.textContent = workflow.summary;
button.append(name, description);
button.addEventListener("click", () => {
state.selectedWorkflowId = workflow.id;
renderWorkflowChooser();
renderStages();
});
elements.workflowChooser.append(button);
}
}
function stageNumber(index) {
return String(index + 1).padStart(2, "0");
}
function createGuidanceCard(step, index, blocked = false) {
const card = document.createElement("article");
card.className = `guidance-card${step.danger || blocked ? " danger" : ""}`;
const number = document.createElement("span");
number.className = "stage-number";
number.textContent = stageNumber(index);
const body = document.createElement("div");
const badge = document.createElement("span");
badge.className = "step-label";
badge.textContent = blocked ? "Blocked" : "Guidance";
const title = document.createElement("h3");
title.textContent = step.title;
const description = document.createElement("p");
description.textContent = step.description;
body.append(badge, title, description);
if (step.link) {
const link = document.createElement("a");
link.className = "guidance-link";
link.href = step.link;
link.target = "_blank";
link.rel = "noopener noreferrer";
link.textContent = step.link_label || "Open reference";
body.append(link);
}
card.append(number, body);
return card;
}
function createStageCard(action, step, index) {
const card = document.createElement("article");
card.className = `stage-card${action.danger ? " danger" : ""}`;
card.dataset.action = action.id;
card.dataset.noFuse = step.no_fuse || "none";
const top = document.createElement("div");
top.className = "stage-topline";
const identity = document.createElement("div");
identity.className = "stage-identity";
const number = document.createElement("span");
number.className = "stage-number";
number.textContent = stageNumber(index);
const heading = document.createElement("div");
const label = document.createElement("span");
label.className = "step-label";
label.textContent = `${step.optional ? "Optional · " : ""}${step.label || "Action"}`;
const title = document.createElement("h3");
title.textContent = action.name;
const description = document.createElement("p");
description.className = "stage-description";
description.textContent = action.description;
heading.append(label, title, description);
identity.append(number, heading);
const marker = document.createElement("span");
marker.className = "verification-marker idle";
marker.textContent = "Not run";
top.append(identity, marker);
const form = document.createElement("div");
form.className = "stage-form";
const modelGroup = document.createElement("div");
modelGroup.className = "control-group";
const modelLabel = document.createElement("span");
modelLabel.className = "field-label";
modelLabel.textContent = "Global target";
const modelValue = document.createElement("div");
modelValue.className = "select-control mode-value global-target-value";
modelValue.textContent = elements.globalModel.value;
modelGroup.append(modelLabel, modelValue);
const modeGroup = document.createElement("div");
modeGroup.className = "control-group";
const modeLabel = document.createElement("span");
modeLabel.className = "field-label";
modeLabel.textContent = "Execution mode";
const modeValue = document.createElement("div");
modeValue.className = "select-control mode-value";
modeValue.textContent = action.mode;
modeGroup.append(modeLabel, modeValue);
const options = document.createElement("div");
options.className = "option-stack";
if (action.flash_options) {
options.append(buildCheckbox("wait", "Wait for a device", true));
options.append(buildCheckbox("no_reboot", "Keep device in download mode", false));
options.append(buildCheckbox("verbose", "Verbose Heimdall output", false));
}
if (action.requires_confirmation) {
options.append(buildCheckbox("confirmed", action.confirmation, false, "confirmation"));
}
form.append(modelGroup, modeGroup, options);
if (action.supports_no_fuse) {
const profileNote = document.createElement("div");
profileNote.className = "profile-note";
form.append(profileNote);
}
if (action.safety_note) {
const safetyNote = document.createElement("div");
safetyNote.className = "stage-safety-note";
safetyNote.textContent = action.safety_note;
form.append(safetyNote);
}
const footer = document.createElement("div");
footer.className = "stage-footer";
const verification = document.createElement("span");
verification.className = "stage-verification-text";
verification.textContent = action.requires_usb ? "USB stage has not run." : "Verification has not run.";
const run = document.createElement("button");
run.type = "button";
run.className = "button button-primary run-stage";
run.textContent = step.optional ? "Run optional step" : "Run step";
run.addEventListener("click", () => runStage(action.id));
footer.append(verification, run);
form.append(footer);
card.append(top, form);
return card;
}
function renderStages() {
const workflow = state.workflows.find((candidate) => candidate.id === state.selectedWorkflowId);
elements.stageGrid.replaceChildren();
if (!workflow) {
return;
}
const profile = currentFuseProfile();
if (!workflow.allowed_profiles.includes(profile)) {
elements.stageGrid.append(createGuidanceCard({
title: "This workflow does not match the selected fuse state",
description: workflow.blocked_message,
danger: true,
}, 0, true));
refreshStageStatuses();
return;
}
const steps = workflow.steps.filter((step) => !step.profiles || step.profiles.includes(profile));
steps.forEach((step, index) => {
if (step.kind === "guide") {
elements.stageGrid.append(createGuidanceCard(step, index));
return;
}
const action = state.actions.find((candidate) => candidate.id === step.action);
if (action) {
elements.stageGrid.append(createStageCard(action, step, index));
}
});
updateGlobalSafety();
refreshStageStatuses();
}
function refreshStageStatuses() {
const busy = Boolean(state.activeJobId);
document.querySelectorAll(".stage-card[data-action]").forEach((card) => {
const actionId = card.dataset.action;
const recordedStatus = state.stageStatus[actionId];
const matchesContext = recordedStatus
&& recordedStatus.model === elements.globalModel.value
&& recordedStatus.fuse_profile === currentFuseProfile();
const status = matchesContext
? recordedStatus
: {status: "idle", verification: ""};
const marker = card.querySelector(".verification-marker");
marker.className = `verification-marker ${status.status || "idle"}`;
marker.textContent = statusText(status.status || "idle");
const text = card.querySelector(".stage-verification-text");
text.textContent = status.verification
|| "Verification has not run.";
card.querySelector(".run-stage").disabled = busy;
});
elements.globalModel.disabled = busy;
elements.globalFuseProfile.disabled = busy;
elements.cancelJob.disabled = !busy;
}
function collectOptions(card) {
const options = {
fuse_profile: currentFuseProfile(),
fuse_ack_permanent: state.fuseAcknowledgements.permanent,
fuse_ack_stock: state.fuseAcknowledgements.stock,
fuse_ack_left_ok: state.fuseAcknowledgements.leftOk,
};
card.querySelectorAll('input[type="checkbox"]').forEach((input) => {
options[input.name] = input.checked;
});
const action = state.actions.find((candidate) => candidate.id === card.dataset.action);
if (action?.supports_no_fuse) {
options.no_fuse = actionNoFuse(card);
}
return options;
}
async function runStage(actionId) {
const card = document.querySelector(`.stage-card[data-action="${actionId}"]`);
if (!card) {
return;
}
const model = elements.globalModel.value;
const options = collectOptions(card);
try {
const job = await api("/api/run", {
method: "POST",
body: JSON.stringify({action: actionId, model, options}),
});
elements.globalModel.value = job.model;
elements.globalFuseProfile.value = job.options.fuse_profile;
state.activeJobId = job.id;
state.logCursor = 0;
state.stageStatus[actionId] = {
status: "running",
verification: "",
model: job.model,
fuse_profile: job.options.fuse_profile,
};
elements.consoleOutput.textContent = "";
elements.consoleStage.textContent = `${job.command.join(" ")} | ${model}`;
setConsoleStatus("running");
refreshStageStatuses();
startPolling();
} catch (error) {
showToast(error.message, true);
}
}
function startPolling() {
window.clearTimeout(state.pollTimer);
pollJob();
}
async function pollJob() {
if (!state.activeJobId) {
return;
}
try {
const job = await api(`/api/jobs/${state.activeJobId}?after=${state.logCursor}`);
appendConsole(job.lines);
state.logCursor = job.next;
setConsoleStatus(job.status);
state.stageStatus[job.action] = {
status: job.status,
verification: job.verification,
model: job.model,
fuse_profile: job.options.fuse_profile,
};
refreshStageStatuses();
if (["passed", "failed", "cancelled"].includes(job.status)) {
elements.consoleStage.textContent = `${job.action.toUpperCase()} | ${job.model} | ${job.verification}`;
showToast(job.verification || `Stage ${job.status}.`, job.status !== "passed");
state.activeJobId = null;
refreshStageStatuses();
return;
}
state.pollTimer = window.setTimeout(pollJob, 500);
} catch (error) {
showToast(error.message, true);
state.pollTimer = window.setTimeout(pollJob, 1200);
}
}
async function cancelActiveJob() {
if (!state.activeJobId) {
return;
}
try {
await api(`/api/jobs/${state.activeJobId}/cancel`, {
method: "POST",
body: JSON.stringify({}),
});
setConsoleStatus("cancelling");
showToast("Cancellation requested.");
} catch (error) {
showToast(error.message, true);
}
}
function populateGlobalModels(models) {
elements.globalModel.replaceChildren();
for (const model of models) {
const option = document.createElement("option");
option.value = model;
option.textContent = model;
elements.globalModel.append(option);
}
elements.globalModel.value = models.includes("G985F") ? "G985F" : models[0];
}
function populateFuseProfiles(profiles) {
elements.globalFuseProfile.replaceChildren();
for (const profile of profiles) {
const option = document.createElement("option");
option.value = profile.id;
option.textContent = profile.name;
elements.globalFuseProfile.append(option);
}
elements.globalFuseProfile.value = "stay_unfused";
}
function updateFuseDialogConfirmation() {
elements.fuseConfirmLeft.disabled = !(
elements.fuseCheckPermanent.checked && elements.fuseCheckStock.checked
);
}
function closeFuseDialog() {
if (elements.fuseConfirmDialog.open) {
if (typeof elements.fuseConfirmDialog.close === "function") {
elements.fuseConfirmDialog.close();
} else {
elements.fuseConfirmDialog.removeAttribute("open");
}
}
}
function applyFuseDecision(profile) {
if (profile !== "fuse") {
state.fuseAcknowledgements = {permanent: false, stock: false, leftOk: false};
}
elements.globalFuseProfile.value = profile;
renderStages();
updateGlobalSafety();
}
function openFuseDialog() {
state.fuseAcknowledgements = {permanent: false, stock: false, leftOk: false};
elements.fuseCheckPermanent.checked = false;
elements.fuseCheckStock.checked = false;
updateFuseDialogConfirmation();
elements.globalFuseProfile.value = "stay_unfused";
if (typeof elements.fuseConfirmDialog.showModal === "function") {
elements.fuseConfirmDialog.showModal();
} else {
elements.fuseConfirmDialog.setAttribute("open", "");
}
elements.fuseCheckPermanent.focus();
}
function applyRuntime(runtime) {
elements.runtimeChip.textContent = `${runtime.platform} · Python ${runtime.python}`;
elements.repoPath.textContent = runtime.repo;
}
async function loadStatus({render = true} = {}) {
if (!token) {
throw new Error("Missing UI token. Open the exact URL printed by exynos990_control_center.py.");
}
const payload = await api("/api/status");
state.models = payload.models;
state.actions = payload.actions;
state.workflows = payload.workflows;
state.fuseProfiles = payload.fuse_profiles;
state.safety = payload.safety || {};
state.stageStatus = payload.jobs.stages || {};
applyRuntime(payload.runtime);
renderDependencies(payload.dependencies);
const active = payload.jobs.active_job;
if (render) {
populateGlobalModels(payload.models);
populateFuseProfiles(payload.fuse_profiles);
if (active) {
if (payload.models.includes(active.model)) {
elements.globalModel.value = active.model;
}
const activeProfile = active.options?.fuse_profile;
if (payload.fuse_profiles.some((profile) => profile.id === activeProfile)) {
elements.globalFuseProfile.value = activeProfile;
state.fuseAcknowledgements = {
permanent: active.options.fuse_ack_permanent === true,
stock: active.options.fuse_ack_stock === true,
leftOk: active.options.fuse_ack_left_ok === true,
};
}
}
renderWorkflowChooser();
renderStages();
updateGlobalSafety();
}
if (active) {
state.activeJobId = active.id;
state.logCursor = 0;
elements.consoleOutput.textContent = "";
elements.consoleStage.textContent = `${active.action.toUpperCase()} | ${active.model}`;
refreshStageStatuses();
startPolling();
}
}
elements.globalModel.addEventListener("change", () => {
updateGlobalSafety();
});
elements.globalFuseProfile.addEventListener("change", () => {
if (elements.globalFuseProfile.value === "fuse") {
openFuseDialog();
return;
}
applyFuseDecision("stay_unfused");
});
elements.fuseCheckPermanent.addEventListener("change", updateFuseDialogConfirmation);
elements.fuseCheckStock.addEventListener("change", updateFuseDialogConfirmation);
elements.fuseConfirmLeft.addEventListener("click", () => {
if (!elements.fuseCheckPermanent.checked || !elements.fuseCheckStock.checked) {
return;
}
state.fuseAcknowledgements = {
permanent: elements.fuseCheckPermanent.checked,
stock: elements.fuseCheckStock.checked,
leftOk: true,
};
closeFuseDialog();
applyFuseDecision("fuse");
});
elements.fuseCancelRight.addEventListener("click", () => {
closeFuseDialog();
applyFuseDecision("stay_unfused");
});
elements.fuseConfirmDialog.addEventListener("cancel", (event) => {
event.preventDefault();
closeFuseDialog();
applyFuseDecision("stay_unfused");
});
elements.refreshDependencies.addEventListener("click", async () => {
elements.refreshDependencies.disabled = true;
try {
await loadStatus({render: false});
updateGlobalSafety();
showToast("Dependency checks refreshed.");
} catch (error) {
showToast(error.message, true);
} finally {
elements.refreshDependencies.disabled = false;
}
});
elements.cancelJob.addEventListener("click", cancelActiveJob);
elements.copyLog.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(elements.consoleOutput.textContent);
showToast("Log copied to clipboard.");
} catch (error) {
showToast(`Unable to copy log: ${error.message}`, true);
}
});
elements.clearLog.addEventListener("click", () => {
elements.consoleOutput.textContent = "";
});
loadStatus().catch((error) => {
elements.consoleOutput.textContent = error.message;
setConsoleStatus("failed");
showToast(error.message, true);
});