import * as fs from 'node:fs'; import * as path from 'node:path'; import { computePerceptualHashFromRgba, decryptWithPasskey, deriveKeyFromImage, encryptWithPasskey, generateDicewarePassphrase, generateEncryptionKeyPair, generateRandomPasskey32, generateSigningKeyPair, initCrypto, isPasskeyEncrypted, toHex, } from '@ombrix/crypto-adapter'; import { Ombrix, type StegoMethod } from '@ombrix/edge-sdk'; import { executeCodeMode, findLatestCarrierImage, openNativeFileDialog, resolveFuzzyCarrierPath, startMcpServer, } from '@ombrix/mcp-server'; import { haarDwtStego, hyperMatrixMethod, jpegDctStego, pvdStego, robustResilientStego, } from '@ombrix/stego-advanced'; import type { ForensicsConsensusReport } from '@ombrix/stego-forensics'; import { pngLsbMatching } from '@ombrix/stego-lab'; import { pngLsbSequential } from '@ombrix/stego-png-lsb'; import { getMcpClientTargets, installMcpToClient, promptUser } from './mcp-installer.js'; import { decodePng, encodePng } from './png-codec.js'; export interface CliResult { exitCode: number; stdout: string; stderr: string; } const VERSION = '0.1.7'; /** * Resolves a 32-byte cryptographic passkey from a carrier image or photo file. */ function resolvePhotoKey(imagePath: string, mode: 'perceptual' | 'raw' = 'perceptual'): string { const resolved = path.resolve(imagePath); if (!fs.existsSync(resolved)) { throw new Error(`Key image file not found: '${resolved}'`); } const bytes = new Uint8Array(fs.readFileSync(resolved)); if (bytes.length === 0) { throw new Error(`Key image file is empty: '${resolved}'`); } if (mode === 'raw') { return toHex(deriveKeyFromImage(bytes)).toUpperCase(); } // Perceptual mode: survives lossy recompression & color adjustments try { const carrier = decodePng(bytes); const keyBytes = computePerceptualHashFromRgba(carrier.width, carrier.height, carrier.data); return toHex(keyBytes).toUpperCase(); } catch { // If not a standard PNG (e.g. JPEG or raw file), fallback to deriveKeyFromImage return toHex(deriveKeyFromImage(bytes)).toUpperCase(); } } const HELP_BANNER = ` ██████╗ ███╗ ███╗██████╗ ██████╗ ██╗██╗ ██╗ ██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██║╚██╗██╔╝ ██║ ██║██╔████╔██║██████╔╝██████╔╝██║ ╚███╔╝ ██║ ██║██║╚██╔╝██║██╔══██╗██╔══██╗██║ ██╔██╗ ╚██████╔╝██║ ╚═╝ ██║██████╔╝██║ ██║██║██╔╝ ██╗ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═╝ OMBRIX CLI v${VERSION} — Zero-Telemetry Forensic Steganography Suite USAGE: ombrix [options] COMMANDS: embed [options] Embed a message or file into a carrier PNG extract [options] Extract hidden message from a stego PNG scan [options] Run multi-detector forensic steganalysis inspect Analyze carrier capacity across 7 algorithms benchmark [options] Compare algorithms on carrier (PSNR, MSE, SSIM) keygen [diceware|crypto32|photo|keypair] Generate cryptographic passkeys or keypairs eval