news
I wished to get Rockbox operating on the nano 5G, so I set out to adjust the make use of. My inspiration was basic: a current music gamer without a web connection. I constructed a completely untethered boot chain that loads Rockbox from the nano 5G’s NAND, without any computer system or button series required after setup. I likewise discovered a method to make the existing make use of totally untethered on the nano 7G, and likely the 6G too.
Existing DFU exploits, consisting of q3k’s wInd3xsupply code execution on the nano 5G, however booting customized code by doing this needs a computer system each time. I utilized wInd3x to check out the gadget and establish a practical, totally untethered make use of. The firmware information listed below describe the current nano 5G firmware,
1.0.2 (34A20020)
The catch with ipod_sun
The nano 5G’s NAND flash appears through a flash translation layer(FTL )as a sensible disk with 4 KiB sectors. Its partition table separates a little personal location for relentless gadget state, a firmware partition including boot programs and resources, and an information volume for user files. The firmware partition has a directory site of called images; the font styles live inside rsrca resource volume formatted as FAT16.
The initial ipod_sun chain integrates a resource-validation bypass with a font-parser vulnerability. Apple’s firmware directory site determines the typical os as ososthe disk-mode program as diskand the resource image including typefaces as rsrcThe disk-mode boot course does not ask for the resource signature check utilized by regular OS boot.
Switching the disk and osos directory site entries makes use of that distinction: picking disk mode now releases Apple’s routine OS under the disk-mode policy. The OS still reads its font styles, however the bootloader has actually not needed a legitimate signature for the customized resource image.
// Resource-validation decision only; other image checks are omitted.
if (selected_target==OSOS) {
status=check_resource_policy(rsrc);
if (failed(status))
return status;
}
// The DISK path does not request this rsrc check.
return boot_image(firmware_directory);
// With swapped entries, the DISK entry points to Apple's normal OS.
The font style then sets off CVE-2010-1797the FreeType CFF stack-overflow vulnerability likewise understood through the star make use of. A malformed font style program damages the parser’s stack and reroutes execution. My 5G port adapts that strategy to the gadget’s typeface and execution context.
The switched images stay on disk, however each reboot still needs selecting disk mode with the gadget’s buttons. A typical boot chooses the other entry. I desired a much better experience, with the customized font style filling through the typical OS course.
Discovering a bypass in the regular boot course
The bootloader is arranged into EFI-style modules saved as Portable Executable (PE) images. The module that passes execution to the next boot phase chooses whether to confirm rsrcIt initially asks the PrivateData module for FirmwareStatuswhich originates from a confirmed record in the personal NAND partition.
The definitive branch is listed below. This is rebuilded C from the reverse-engineered regimen, with unassociated fuse handling and procedure setup left out.
status=private_data->> get_variable( private_data, U16("FirmwareStatus"&& word); if (status!=0) return status; if (word & & 0x1) return UINT32_C(0x8000000a);// Reject the boot effort. if (word & & 0x2) return 0;// Skip rsrc signature recognition. uint32_t size=sizeof(recognition);// Check the rsrc signature and turn down a void outcome. status=resource->> get_info( resource, BDS_GUID(BDS_VALIDATION), && size, recognition); if (! BDS_ERROR(status) && & recognition[0]==0) return UINT32_C(0x8000001a); return status; A worth of 2 returns success before the resource-validation inquiry. Bit 0 should stay clear: it is inspected initially, so 3 would turn down the boot effort. Tracing the bring back OS programs that it sets the status to 1 throughout firmware transfer and clears it to 0 at the end. This recommends an update-in-progress guard that avoids booting an insufficient setup.
Apple’s resource-mount course composes status 2 just on the very first effective boot, after rsrc has actually passed signature confirmation. My hypothesis is that this prevents duplicating signature confirmation to reduce boot time or lower energy usage.
This is the 2nd bypass. Rather of camouflaging the regular OS as disk mode, I can leave the firmware directory site alone and provide a legitimate personal record with bit 1 set. The typical boot course then accepts the customized resource image, and its typeface provides code execution immediately.
The record resides in the personal partition, recognized by MBR type 0x3eOn the 5G design I analyzed, the partition starts at sensible block 1, with 4 KiB blocks. The bootloader checks out a 512-byte header from its start. The status-bearing format starts with the little-endian magic PRVD and has this design:
0x00 |
0x44565250 (PRVD |
0x04–0x0c |
3 32-bit words: 2, 0, 4 |
0x40 |
32-bit FirmwareStatus; usage 2 |
0x80 |
16-byte device-bound stability tag |
The stability tag is device-specific, so developing and conserving a legitimate PRVD record needs code execution on that iPod.
*firmware_status=0;
read_private_header(header); // Read-error handling omitted here.
if (is_plain_header(header))
return PD_SUCCESS;
if (!is_prvd_v2(header))
return PD_UNSUPPORTED;
// SHA-1 covers the first 0x80 bytes, including FirmwareStatus.
sha1(header, 0x80, digest);
aes_encrypt_uid(digest, 16, expected_tag);
if (!equal16(header + 0x80, expected_tag))
return PD_SECURITY_VIOLATION;
*firmware_status=read_u32_le(header + 0x40);
return PD_SUCCESS;
The tag is the very first 16 bytes of the SHA-1 absorb, secured with the gadget’s hardware AES UID secret, picked through crucial slot 2. It confirms the personal header, however as the authentication is built on gadget we can falsify it if we have code execution.
Utilizing emCORE to make it consistent
To check and upgrade the personal partition, I adjusted <em>emCORE</em>an older structure from freemyipod's earlier iPod exploitation and boot work. It supplied an existing USB-controlled environment to extend for the 5G.
I composed the nano 5G NAND chauffeur and incorporated it into emCORE along with the flash translation layer (FTL) and hardware AES gain access to. I'll cover the flash memory sequencer subsystem (FMSS), which makes it possible for NAND composes, in a future post. The FTL provides sensible sectors over physical flash; it is the layer through which I check out and compose the personal record and set up the customized font style.
The private-status tool validates the existing header and tag, constructs the upgraded record, and acquires its brand-new tag from the gadget. It reconsiders the partition table and header before composing, then flushes the compose and reads it back. The tool composes a total 4 KiB rational sector although the bootloader just takes in the smaller sized header. This deals with nano 5G hardware.
When the personal record and customized font style are set up, they stay in NAND throughout restarts. emCORE and the host computer system are required for the setup workflow, not for each subsequent boot.
A bootloader in less than 28 KB
Reaching the font style parser immediately fixed determination. The next restraint was fitting something beneficial inside the typeface. I desired it to pack Rockbox from storage, so the payload required a NAND chauffeur, a flash translation layer, a filesystem reader, and enough start-up code to hand off dependably.
<table>
<caption>From the font style slot to the primary payload ceiling</caption>
<thead><tr>PartComputation</tr></thead>
<tbody>
<tr><td>Typeface slot</td><td>165,416 font bytes</td></tr>
<tr><td>Font style container</td><td>Deduct 78,312 font bytes</td></tr>
<tr><td>Set overhead, omitting the stub</td><td>Deduct 1,056 font bytes, leaving 86,048</td></tr>
<tr><td>× 3 encoding</td><td>Each code byte utilizes 3 font bytes: ⌊ 86,048 ÷ 3 ⌋=28,682 code bytes</td></tr>
<tr><td>Clean-up stub</td><td>Deduct 808 code bytes for clean-up and handoff to the bootloader</td></tr>
<tr><td>Main payload ceiling</td><td>28,682 − 808=<strong>27,874 bytes</strong></td></tr>
</tbody>
</table>
To fit, I put together with size and link-time optimizations and had the linker get rid of unused areas. The Rockbox kernel is kept on the gadget's FAT32 partition and can be quickly upgraded.
Taking control from the font style parser
Code execution at first shows up in a harmed FreeType call frame. The stack has actually been damaged, and Apple's OS has actually left disrupts, DMA controllers, timers, caches, and address translation set up for its own usage. Leaping directly into a big C program would bring that state into storage initialization.
I divided the bootstrap into 2 images. The very first is the 808-byte assembly stub at <code>0x22050000</code>Its task is to leave the parser context: mask IRQs and FIQs, change to a personal stack, stop acquired timer activity, quiesce DMA and clock domains, and tidy up caches and the MMU before going into the primary payload. It changes the broken stack and after that leaps to the Rockbox kernel loader.
The 2nd image is the primary loader at <code>0x22060000</code>Its entry code disables the guard dog before beginning the NAND scan, installs its own stack, and clears the uninitialized-data location before calling C. The guard dog matters since rebuilding the sensible flash mapping can take a number of seconds; a reset in the middle would stop the boot before it ever discovered Rockbox.
This separation keeps the most vulnerable phase little. The assembly stub develops a regulated execution environment; the primary payload can then do the more significant storage operate in freestanding C.
Checking out NAND and beginning Rockbox
At the hardware level, the NAND chauffeur utilizes FMSS, a programmable microcontroller, to interact with the NAND chips. lemonjesus's earlier deal with the S5L8702 sequencer, released as <em>S5L8702-FMISS-Tools</em>records its guideline set and supplies tools for examining and developing bytecode. That research study is essential previous work for comprehending this part of the storage hardware; my work here utilizes the sequencer to check out NAND as part of the nano 5G boot course.
The loader very first checks that the split second timer utilized for motorist timeouts is running. It then initializes the read-only NAND and FTL stack, installs the FAT filesystem, and opens <code>/.rockbox/rockbox.ipod</code>The core series follows the Rockbox bootloader's own file-loading course:
rc=storage_init(); if (rc) return stop working(NB_NAND_INIT, rc); filesystem_init(); if (disk_mount_all() <<=0 )return stop working(NB_FAT_MOUNT, -1); rc=load_firmware((anonymous char *)NB_LOAD_ADDR, BOOTDIR "/" BOOTFILE, (int)NB_LOAD_LIMIT); if (rc <<=EFILE_EMPTY) return stop working(NB_LOAD, rc);// The complete program reaches this handoff after nb_prepare() prospers. nb_jump(NB_LOAD_ADDR); The file loader checks the Rockbox design identifier and checksum, then leaves the executable image at 0x08000000The last handoff keeps disrupts masked, cleans up and revokes caches, drains pipes pending composes, and branches to that address. Rockbox’s start-up code takes over from there. If storage, installing, or image loading stops working, the payload reveals the stopping working phase on the LCD and stops.
- Regular power-onThe bootloader checks out the verified PRVD status and avoids the resource-signature check.
- Font-triggered executionApple’s OS parses the customized font style, which composes the 2 bootstrap images to SRAM and transfers manage.
- A tidy execution environmentThe entry stub takes control of the CPU and acquired hardware state; the primary payload prepares storage.
- Rockbox from NANDThe loader discovers the Rockbox image, copies it into DRAM, checks it, and leaps to its entry point.
Outcome and limitations
On my nano 5G, the outcome is a cold, battery-powered boot directly into Rockbox, without any USB connection and no disk-mode button series. The PRVD partition setting skips <code>rsrc</code> recognition and, when integrated with the <em>star</em> make use of, makes it possible for untethered boot directly into Rockbox. The primary restriction is that the font payload is restricted to 27,874 bytes. Setup and repair treatments, in addition to the reverse-engineering notes and develop information, remain in the nano5g_bootstub and nano5g_emCORE repositories listed below.
I have actually verified that the private-data partition works the very same method on the nano 7G, which recommends the approach will likely deal with the 6G too. I prepare to get the nano 4G and 5G Rockbox ports into good condition before using this technique to the 6G and 7G.
<h2 id="sources-title">Recommendations</h2>
<ul>
<li>nano5g_bootstub: the typeface make use of, PRVD analysis, two-stage Rockbox loader, and precise size budget plan.</li>
<li>nano5g_emCORE: the emCORE port, NAND read/write tools, confirmed private-record updates, and setup treatment.</li>
<li>CUB3D's ipod_sun: the earlier nano 6G/7G chain integrating the disk-mode swap with a customized font style.</li>
<li>q3k, "wInd3x, the iPod Bootrom make use of ten years far too late": the USB/DFU entry point utilized to run anonymous code throughout setup, with background on the iPod boot chain.</li>
<li>Apple's firmware upgrade brochure: lists nano 5G firmware 1.0.2 (34A20020) under iPod software application household 34.</li>
<li>CVE-2010-1797: the existing FreeType CFF vulnerability utilized by the font style make use of.</li>
<li>freemyipod's emCORE source: the initial structure and earlier gadget targets on which the nano 5G adjustment constructs.</li>
<li>lemonjesus's S5L8702-FMISS-Tools: earlier reverse engineering of the flash-controller sequencer, with instruction-set paperwork and bytecode tools.</li>
<li>n3g_fmss: my documents of the nano 3G flash memory sequencer.</li>
<li>n4g_fmss: my paperwork of the nano 4G flash memory sequencer.</li>
<li>Rockbox source: upstream firmware, storage, filesystem, and image-loading code recycled in this work.</li>
</ul>
Discover more from PMN S.P.O.R.T.S - A PRIME MEDIA NETWORK BRAND
Subscribe to get the latest posts sent to your email.





