Alvin Novian
Back to index

Running iOS on Fedora

I found this open source project called Inferno from this tweet and really hooked by it because I really hate the testing workflow on a real iOS device or via a simulator on MacOS. Inferno could be a solution for me so I don’t have to touch iPhone and never have to switch to MacOS again

I follow Inferno’s manual guide although they only provide guide for Arch & Debian and I use Fedora, thus I try to document and understand the process in this blog.

To follow Inferno’s guide spirit: these blog are supposed to be read, not copied verbatim.

Btw, for reference, this is the folder structure that I have in the end, but keep reading …

/home/user/Documents
├── custom-nettle
│   ├── lib
│   │   ├── pkgconfig
│   │   │   └── nettle.pc
│   │   └── libnettle.so
│   └── nettle-3.10.2
├── idevicerestore
├── Inferno
├── InfernoData
└── SimulatedSigningServer

Host Setup

Install the Dependencies

On Debian, this is what Inferno instructs you to install:

sudo apt-get install -y build-essential pkg-config libtasn1-6-dev liblz4-dev libglib2.0-dev libpng-dev libyuv-dev zstd libzstd-dev libgmp10 libgmp3-dev lzfse liblzfse-dev nettle-dev xmake

so let’s dive into each of them and see what’s the package name on Fedora, first the build-essential, on dnf5 that would be @development-tools or a group install of development-tools on older dnf

# dnf5
sudo dnf install @development-tools

# old dnf
sudo dnf group install development-tools

That will install package group for gcc, g++, make and core build utilities.


Next, we got pkg-config, on Fedora that would be pkgconf, a modern drop-in replacement for it and it has pkgconf-pkg-config as a shim to provide pkg-config (reference)

sudo dnf install pkgconf-pkg-config

That is a helper tool used during compilation that queries installed libraries for their include paths (.h files) and linker flags (.so/.a files) so compilers know where to find them


Next, we got couple libs: libtasn1-6-dev, liblz4-dev, libglib2.0-dev, libpng-dev, libyuv-dev. In Fedora they use suffix devel instead of dev , also they don’t include the soname version in the package name and they tend to keep the upstream project name rather than forcing a lib prefix onto every library like Debian, so that would be:

sudo dnf install libtasn1-devel lz4-devel glib2-devel libpng-devel libyuv-devel

and here are what each of them do:

libtasn1-devel: dev files for Libtasn-1, a library that handles ASN.1 (Abstract Syntax Notation One) serialization and parsing, commonly used in X.509 SSL/TLS certificates and PKCS cryptographic standards

lz4-devel: dev files for LZ4, an extremely fast lossless compression algorithm focused on rapid compression and decompression speeds rather than maximum compression ratio

glib2-devel: dev files for GLib, a foundational low-level C utility library (originally from GTK) that provides data structures (hash tables, linked lists, trees), event loops, threading, and file/string utilities

libpng-devel: dev files for the official PNG reference library

libyuv-devel: dev files for Google’s libyuv library, which performs high-speed, SIMD-accelerated color space conversions (e.g., YUV to RGB), scaling, and rotation for video frames


Next, zstd and libzstd-dev, while zstd is the same name in Fedora, you just need to adjust the dev package name

sudo dnf install zstd libzstd-devel

This will install command-line utility and C development headers for Zstandard, Facebook’s lossless compression algorithm that balances high compression ratios with fast decompression speeds


Next, libgmp10, libgmp3-dev, lzfse, liblzfse-dev. We need the same lib & devel adjustment, so that would be:

sudo dnf install gmp gmp-devel lzfse lzfse-devel

gmp and gmp-devel: install the runtime library and C development headers for the GNU Multiple Precision Arithmetic Library (GMP), used for arbitrary-precision math on massive integers, rational numbers, and floating-point values (a core dependency for cryptographic algorithms)

lzfse and lzfse-devel: Apple’s open-source lossless compression algorithm optimized for low energy consumption and high speed (matching zlib’s compression ratio at much higher speeds)


Next, nettle-dev, this is a low-level cryptographic library providing ciphers, hash functions, and public-key algorithms but Fedora shipped nettle without SM4 cipher (thanks to u/aioeu telling me about it on reddit), which is needed by Inferno and that part was taking a lot of my time, because the source code for SM4 is included in Fedora but they build the shared object without it. Anyway, we need to build it ourself to make sure all the needed function is provided by it

So let’s fetch and extract from GNU’s FTP

mkdir custom-nettle
cd custom-nettle
wget https://ftpmirror.gnu.org/gnu/nettle/nettle-3.10.2.tar.gz
echo "fe9ff51cb1f2abb5e65a6b8c10a92da0ab5ab6eaf26e7fc2b675c45f1fb519b5 nettle-3.10.2.tar.gz" | sha256sum -c -
tar -xvf nettle-3.10.2.tar.gz
cd nettle-3.10.2

Now we need to configure it before build and make sure to provide prefix & libdir into your desired path, this is important otherwise it would try to install / replace the default nettle shipped from Fedora, which is not what we want. For me, I use the home directory to avoid conflict entirely and avoid using sudo

./configure --prefix=/home/user/Documents/custom-nettle --libdir=/home/user/Documents/custom-nettle/lib

And build the custom nettle

make -j$(nproc)
make install

And then later whenever we use xmake, we need to provide PKG_CONFIG_PATH to make sure it use our custom build nettle in the build step and provide LD_LIBRARY_PATH to use custom build nettle for the runtime usage. Example:

PKG_CONFIG_PATH=/home/user/Documents/custom-nettle/lib/pkgconfig LD_LIBRARY_PATH=/home/user/Documents/custom-nettle/lib xmake <the-rest-of-the-command>

Last, xmake is the same name in Fedora:

sudo dnf install xmake

xmake is a lightweight cross-platform build utility based on Lua


So the “Install the Dependencies” step is done, let’s move on …

Graphical interface

Inferno for Debian also instruct us to install this for the graphical interface (rather than command-line with VNC)

sudo apt-get install -y libwxgtk3.2-dev wx-common

So in Fedora that would be under one package

sudo dnf install wxGTK-devel

Building Inferno

Remember we need to always provide PKG_CONFIG_PATH and LD_LIBRARY_PATH

git clone --depth=1 https://git.chefkiss.dev/AppleHax/Inferno.git
cd Inferno
PKG_CONFIG_PATH=<ppath> LD_LIBRARY_PATH=<lipath> xmake f -m release --qom_cast_debug=n
PKG_CONFIG_PATH=<ppath> LD_LIBRARY_PATH=<lipath> xmake
cd ..

Installing the libimobiledevice Suite

Inferno has some steps to build libimobiledevice and its suite from source, but I found that Fedora can actually provide those, so you just need to install it with dnf and make sure to install all the mentioned package in this step, because it will be used when building the Simulated Signing Server and building idevicerestore

sudo dnf install libimobiledevice-devel libplist-devel libirecovery-devel libtatsu-devel libzip-devel

And then, you need to build idevicerestore’s fork for Inferno and make sure to provide PKG_CONFIG_PATH and LD_LIBRARY_PATH when building it

git clone git@github.com:VisualEhrmanntraut/idevicerestore.git
cd idevicerestore
PKG_CONFIG_PATH=<ppath> LD_LIBRARY_PATH=<lipath> ./autogen.sh --prefix=/home/user/Documents/idevicerestore

Building the Simulated Signing Server

Remember we need to always provide PKG_CONFIG_PATH and LD_LIBRARY_PATH

git clone --depth=1 https://git.chefkiss.dev/AppleHax/SimulatedSigningServer.git
cd SimulatedSigningServer
PKG_CONFIG_PATH=<ppath> LD_LIBRARY_PATH=<lipath> xmake
cd ..

Installing VirtualHere

Just check the same flow in Inferno’s guide

File Setup

Creating the Disks

Again, remember we need to always provide PKG_CONFIG_PATH and LD_LIBRARY_PATH, I will write PKGLD for abbrevity

And make sure to write the image into a different folder than the Inferno repo, I use InfernoData for it so

# in the cloned Inferno repo
PKGLD xmake r -w ../InfernoData inferno-img create -f raw root 32G
PKGLD xmake r -w ../InfernoData inferno-img create -f raw firmware 8M
PKGLD xmake r -w ../InfernoData inferno-img create -f raw syscfg 128K
PKGLD xmake r -w ../InfernoData inferno-img create -f raw ctrl_bits 8K
PKGLD xmake r -w ../InfernoData inferno-img create -f raw nvram 8K
PKGLD xmake r -w ../InfernoData inferno-img create -f raw effaceable 4K
PKGLD xmake r -w ../InfernoData inferno-img create -f raw panic_log 1M
PKGLD xmake r -w ../InfernoData inferno-img create -f raw sep_nvram 64K
PKGLD xmake r -w ../InfernoData inferno-img create -f raw sep_ssc 128K

Fetching the IPSW

Inferno’s guide mention TheAppleWiki and IPSW(dot)me to download the IPSW, but it’s easier to use TheAppleWiki instead, because we will also need SEP-firmware VI & Key paired with that IPSW file.

Keep in mind, some of the IPSW provided in theapplewiki.com does not have SEP-firmware IV and SEP-firmware Key yet, so choose one with the complete information available, for me I was using 24B119_(iPhone12,1)

Fetching the SEP ROM

Just follow Inferno’s guide

Running & Restoring

Running the Emulated iPhone

I use the usb-uplink-addr=0.0.0.0:8030 option from the example, to make sure USB connection is established

PKGLD xmake r -w ../InfernoData inferno-aarch64 -M t8030,sep-rom=../InfernoData/AppleSEPROM-Cebu-B1,kaslr-off=true,usb-uplink-addr=0.0.0.0:8030 \
    -append "tlto_us=-1 mtxspin=-1 serial=3 wdt=-1" \
    -smp 7 -m 4G -serial mon:stdio \
    -drive file=../InfernoData/sep_nvram,if=pflash,format=raw \
    -drive file=../InfernoData/sep_ssc,if=pflash,format=raw \
    -drive file=../InfernoData/root,format=raw,if=none,id=root -device nvme-ns,drive=root,bus=nvme-bus.0,nsid=1,nstype=1,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/firmware,format=raw,if=none,id=firmware -device nvme-ns,drive=firmware,bus=nvme-bus.0,nsid=2,nstype=2,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/syscfg,format=raw,if=none,id=syscfg -device nvme-ns,drive=syscfg,bus=nvme-bus.0,nsid=3,nstype=3,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/ctrl_bits,format=raw,if=none,id=ctrl_bits -device nvme-ns,drive=ctrl_bits,bus=nvme-bus.0,nsid=4,nstype=4,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/nvram,if=none,format=raw,id=nvram -device apple-nvram,drive=nvram,bus=nvme-bus.0,nsid=5,nstype=5,id=nvram,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/effaceable,format=raw,if=none,id=effaceable -device nvme-ns,drive=effaceable,bus=nvme-bus.0,nsid=6,nstype=6,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/panic_log,format=raw,if=none,id=panic_log -device nvme-ns,drive=panic_log,bus=nvme-bus.0,nsid=7,nstype=8,logical_block_size=4096,physical_block_size=4096 2>Stderr.txt

It should open a new window with the emulated iPhone Inferno Window

Starting the Simulated Signing Server

On a new terminal tab, start the Simulated Signing Server (SSS) and don’t forget to pass the PKGLD

PKGLD xmake r SimulatedSigningServer 127.0.0.1 8031

Run VirtualHere client

On a new terminal tab, use sudo to run the VirtualHere GUI so it can access the USB, once running it should auto discover USB server in localhost:8030 and display it with label Inferno | https://chefkiss.dev/donate/. Right click on that label, and check the [ ] Auto-use all on this server to make sure idevicerestore will always use that USB connection when we continue

Starting the Restore

On a new terminal tab, use sudo so idevicerestore can see the USB for DFU Device, and I’m still not sure if we need the PKGLD prefix or not, but since we use the custom build probably is better to always do so

sudo PKGLD ./idevicerestore --erase -i 0x1122334455667788 YOUR_IPSW_HERE -s http://127.0.0.1:8031/ --sep-key YOUR_IPSW_SEP_KEY_HERE --dev-as-ap

You need to replace the YOUR_IPSW_HERE with the downloaded IPSW path and YOUR_IPSW_SEP_KEY_HERE with the SEP-firmware IV and SEP-firmware Key concatenated without any space i.e. VIKEY

This process will take time, for me it was about ~20 minutes and the emulator will be automatically closed

Inferno Restore

Filesystem Patches

Continue with the guide and make sure to provide PKGLD and point to the InfernoData

PKGLD xmake r -w ../InfernoData inferno-fs-patcher -d root

This process will also take time, it was faster than the 1st stage though, probably ~10 minutes

iOS Setup

And then you start the emulator again with the earlier command but you don’t need the usb-uplink-addr option since now the emulator has been setup

PKGLD xmake r -w ../InfernoData inferno-aarch64 -M t8030,sep-rom=../InfernoData/AppleSEPROM-Cebu-B1,kaslr-off=true \
    -append "tlto_us=-1 mtxspin=-1 serial=3 wdt=-1" \
    -smp 7 -m 4G -serial mon:stdio \
    -drive file=../InfernoData/sep_nvram,if=pflash,format=raw \
    -drive file=../InfernoData/sep_ssc,if=pflash,format=raw \
    -drive file=../InfernoData/root,format=raw,if=none,id=root -device nvme-ns,drive=root,bus=nvme-bus.0,nsid=1,nstype=1,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/firmware,format=raw,if=none,id=firmware -device nvme-ns,drive=firmware,bus=nvme-bus.0,nsid=2,nstype=2,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/syscfg,format=raw,if=none,id=syscfg -device nvme-ns,drive=syscfg,bus=nvme-bus.0,nsid=3,nstype=3,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/ctrl_bits,format=raw,if=none,id=ctrl_bits -device nvme-ns,drive=ctrl_bits,bus=nvme-bus.0,nsid=4,nstype=4,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/nvram,if=none,format=raw,id=nvram -device apple-nvram,drive=nvram,bus=nvme-bus.0,nsid=5,nstype=5,id=nvram,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/effaceable,format=raw,if=none,id=effaceable -device nvme-ns,drive=effaceable,bus=nvme-bus.0,nsid=6,nstype=6,logical_block_size=4096,physical_block_size=4096 \
    -drive file=../InfernoData/panic_log,format=raw,if=none,id=panic_log -device nvme-ns,drive=panic_log,bus=nvme-bus.0,nsid=7,nstype=8,logical_block_size=4096,physical_block_size=4096 2>Stderr.txt

You will continue with the iOS Setup Flow.

And there you have it, iOS on Fedora 🎉

iOS Setup

iOS Fedora Screenshot

Conclusion

It’s really an interesting project, the is not great if you run this on x86_64 but if you have M chip macbook that runs Asahi Linux / Fedora Asahi Remix or just run MacOS I think it should be okay, I’m planning to test this myself in Fedora Asahi Remix on M1 MacBook Air later, some significant things is still missing from the emulator but it’s really awesome already, support them if you can!

You can use Inferno as a research tool, they say it already supports iOS 13 to 27, having a real iOS emulator instead of MacOS’ iOS Simulator is awesome!