# rust505/ios-ramdisk-builder-a12-a13 architecture

> Architecture diagram of the GitHub repository rust505/ios-ramdisk-builder-a12-a13, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rust505/ios-ramdisk-builder-a12-a13
- Repository: https://github.com/rust505/ios-ramdisk-builder-a12-a13

## Overview

This repository builds and boots A12/A13 iOS SSH ramdisks. Its main workflow selects firmware, extracts and decrypts boot components, applies version-specific bootloader and kernel patches, expands and populates a ramdisk, then packages an IMG4 bootchain for DFU loading and SSH access. The README documents these orchestration steps and capabilities; source excerpts show patcher behavior but not build4.sh or boot.sh internals, so workflow edges are cited to the README rather than inferred from unsampled code.

Main entry points: [`build4.sh`](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/build4.sh) (Build Orchestrator), [`patch/apply_kernel_patches.py`](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/apply_kernel_patches.py) (Kernel Patch Driver), [`boot.sh`](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/boot.sh) (DFU Loader), [`ramdisk_expand.sh`](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/ramdisk_expand.sh) (Ramdisk Expansion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Firmware Build"]
  node_buildscript["Build Orchestrator<br/>[build4.sh]"]
  node_firmware["Firmware Extraction<br/>[build4.sh]"]
  node_ramdisk["Ramdisk Expansion<br/>[ramdisk_expand.sh]"]
  node_bootchain[("Packaged Bootchain<br/>[build4.sh]")]
end

subgraph group_patch["Image Patching"]
  node_ibootpatch["iBoot Patching"]
  node_ibootpatch2["iBoot Patchfinder 2"]
  node_ibootfinal["Boot Args Finalization<br/>[finalize_iboot.py]"]
  node_kernelapply["Kernel Patch Driver"]
  node_kernelfinder["Kernel Patchfinder"]
  node_kernelbytes["iOS 26 Byte Patches"]
  node_sptm["SPTM Patching"]
  node_txm["TXM Patching<br/>[txm_patchfinder.py]"]
  node_preflight["Patch Preflight<br/>[preflight.py]"]
  node_dtpatch["DeviceTree Patching<br/>[dtpatch.py]"]
end

subgraph group_assets["Keys and Assets"]
  node_keycollect["Key Collection"]
  node_devicekeys[("Device Keys")]
  node_ibecjson[("iBEC Key Sets")]
  node_sshasset["SSH Ramdisk Assets<br/>[ssh.tar.gz]"]
  node_signature["IM4M Signatures"]
end

subgraph group_boot["Device Boot"]
  node_bootloader["DFU Loader<br/>[boot.sh]"]
  node_device(("Pwned DFU Device"))
  node_sshaccess["Root SSH Access"]
end

node_engineer(("Builder"))
node_ipsw[("Apple IPSW")]
node_sshclient(("SSH Client"))

node_engineer -->|"selects firmware"| node_buildscript
node_buildscript -->|"downloads IPSW"| node_ipsw
node_buildscript -->|"extracts components"| node_firmware
node_firmware -->|"decrypts and patches"| node_ibootpatch
node_firmware -->|"newer iBEC path"| node_ibootpatch2
node_firmware -->|"patches kernel"| node_kernelapply
node_kernelapply -->|"runs finder"| node_kernelfinder
node_kernelapply -->|"supports byte patches"| node_kernelbytes
node_kernelapply -.->|"uses iOS 18 helpers"| node_sptm
node_kernelapply -.->|"uses iOS 18 helpers"| node_txm
node_buildscript -->|"finalizes boot args"| node_ibootfinal
node_buildscript -.->|"patches DeviceTree"| node_dtpatch
node_buildscript -.->|"checks patch inputs"| node_preflight
node_keycollect -->|"queries key data"| node_ipsw
node_buildscript -->|"looks up keys"| node_devicekeys
node_buildscript -->|"looks up keys"| node_ibecjson
node_buildscript -->|"expands ramdisk"| node_ramdisk
node_ramdisk -->|"injects SSH files"| node_sshasset
node_buildscript -->|"signs IMG4 output"| node_signature
node_buildscript -->|"packages bootchain"| node_bootchain
node_engineer -->|"starts device boot"| node_bootloader
node_bootloader -->|"loads components"| node_bootchain
node_bootloader -->|"sends boot images"| node_device
node_device -->|"boots ramdisk"| node_sshaccess
node_sshclient -->|"connects over SSH"| node_sshaccess

click node_buildscript "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/build4.sh"
click node_firmware "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/build4.sh"
click node_keycollect "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/collect_ibec_keys.py"
click node_devicekeys "https://github.com/rust505/ios-ramdisk-builder-a12-a13/tree/main/keys"
click node_ibecjson "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/ibec_keys_iPhone12_1.json"
click node_ibootpatch "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/iboot_patchfinder.py"
click node_ibootpatch2 "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/iboot_patchfinder2.py"
click node_ibootfinal "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/finalize_iboot.py"
click node_kernelapply "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/apply_kernel_patches.py"
click node_kernelfinder "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/kernel_patchfinder.py"
click node_kernelbytes "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/ios26_kernel_byte_patches.py"
click node_sptm "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/sptm_patchfinder.py"
click node_txm "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/txm_patchfinder.py"
click node_preflight "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/preflight.py"
click node_dtpatch "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/bin/dtpatch.py"
click node_ramdisk "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/ramdisk_expand.sh"
click node_sshasset "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/resources/ssh.tar.gz"
click node_signature "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/resources/IM4M_0x8030"
click node_bootchain "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/build4.sh"
click node_bootloader "https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/boot.sh"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_buildscript,node_firmware,node_ramdisk,node_bootchain,node_sshclient toneBlue
class node_ibootpatch,node_ibootpatch2,node_ibootfinal,node_kernelapply,node_kernelfinder,node_kernelbytes,node_sptm,node_txm,node_preflight,node_dtpatch,node_ipsw toneAmber
class node_keycollect,node_devicekeys,node_ibecjson,node_sshasset,node_signature toneMint
class node_bootloader,node_device,node_sshaccess toneRose
class node_engineer toneIndigo
```

## Components

### Firmware Build

- [Build Orchestrator](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/build4.sh): `build4.sh`
- [Firmware Extraction](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/build4.sh): `build4.sh`
- [Ramdisk Expansion](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/ramdisk_expand.sh): `ramdisk_expand.sh`
- [Packaged Bootchain](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/build4.sh): `build4.sh`

### Image Patching

- [iBoot Patching](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/iboot_patchfinder.py): `patch/iboot_patchfinder.py`
- [iBoot Patchfinder 2](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/iboot_patchfinder2.py): `patch/iboot_patchfinder2.py`
- [Boot Args Finalization](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/finalize_iboot.py): `patch/finalize_iboot.py`
- [Kernel Patch Driver](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/apply_kernel_patches.py): `patch/apply_kernel_patches.py`
- [Kernel Patchfinder](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/kernel_patchfinder.py): `patch/kernel_patchfinder.py`
- [iOS 26 Byte Patches](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/ios26_kernel_byte_patches.py): `patch/ios26_kernel_byte_patches.py`
- [SPTM Patching](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/sptm_patchfinder.py): `patch/sptm_patchfinder.py`
- [TXM Patching](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/txm_patchfinder.py): `patch/txm_patchfinder.py`
- [Patch Preflight](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/patch/preflight.py): `patch/preflight.py`
- [DeviceTree Patching](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/bin/dtpatch.py): `bin/dtpatch.py`

### Keys and Assets

- [Key Collection](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/collect_ibec_keys.py): `collect_ibec_keys.py`
- [Device Keys](https://github.com/rust505/ios-ramdisk-builder-a12-a13/tree/main/keys): `keys`
- [iBEC Key Sets](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/ibec_keys_iPhone12_1.json): `ibec_keys_iPhone12_1.json`
- [SSH Ramdisk Assets](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/resources/ssh.tar.gz): `resources/ssh.tar.gz`
- [IM4M Signatures](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/resources/IM4M_0x8030): `resources/IM4M_0x8030`

### Device Boot

- [DFU Loader](https://github.com/rust505/ios-ramdisk-builder-a12-a13/blob/main/boot.sh): `boot.sh`
- **Pwned DFU Device**
- **Root SSH Access**

### Other components

- **Builder**
- **Apple IPSW**
- **SSH Client**

## Connections

- Builder → Build Orchestrator: selects firmware (evidence: `README.md`)
- Build Orchestrator → Apple IPSW: downloads IPSW (evidence: `README.md`)
- Build Orchestrator → Firmware Extraction: extracts components (evidence: `README.md`)
- Firmware Extraction → iBoot Patching: decrypts and patches (evidence: `README.md`)
- Firmware Extraction → iBoot Patchfinder 2: newer iBEC path (evidence: `README.md`)
- Firmware Extraction → Kernel Patch Driver: patches kernel (evidence: `README.md`)
- Kernel Patch Driver → Kernel Patchfinder: runs finder (evidence: `patch/apply_kernel_patches.py`)
- Kernel Patch Driver → iOS 26 Byte Patches: supports byte patches (evidence: `patch/apply_kernel_patches.py`)
- Kernel Patch Driver → SPTM Patching: uses iOS 18 helpers (evidence: `README.md`)
- Kernel Patch Driver → TXM Patching: uses iOS 18 helpers (evidence: `README.md`)
- Build Orchestrator → Boot Args Finalization: finalizes boot args (evidence: `README.md`)
- Build Orchestrator → DeviceTree Patching: patches DeviceTree (evidence: `README.md`)
- Build Orchestrator → Patch Preflight: checks patch inputs (evidence: `README.md`)
- Key Collection → Apple IPSW: queries key data (evidence: `README.md`)
- Build Orchestrator → Device Keys: looks up keys (evidence: `README.md`)
- Build Orchestrator → iBEC Key Sets: looks up keys (evidence: `README.md`)
- Build Orchestrator → Ramdisk Expansion: expands ramdisk (evidence: `README.md`)
- Ramdisk Expansion → SSH Ramdisk Assets: injects SSH files (evidence: `README.md`)
- Build Orchestrator → IM4M Signatures: signs IMG4 output (evidence: `README.md`)
- Build Orchestrator → Packaged Bootchain: packages bootchain (evidence: `README.md`)
- Builder → DFU Loader: starts device boot (evidence: `README.md`)
- DFU Loader → Packaged Bootchain: loads components (evidence: `README.md`)
- DFU Loader → Pwned DFU Device: sends boot images (evidence: `README.md`)
- Pwned DFU Device → Root SSH Access: boots ramdisk (evidence: `README.md`)
- SSH Client → Root SSH Access: connects over SSH (evidence: `README.md`)
