, 29 tweets, 7 min read
My Authors
Read all threads
I was planning to keep this knowledge private, but damn it. This is a thread about Apple SWD cables, some things they can do and how to use them
For now I only have got KongSWD, so everything below applies to this type of cable first of all
f you’re reading this thread, you’ve most likely seen many photos with these weird Apple internal cables posted here, on Twitter, — Gorilla, Kong, Kanzi, Chimp, Flamingo, etc.

But have you ever wondered what they are for, what they can do and why they are so expensive? Answer is simple — they provide JTAG, powerful debug interface
What can you achieve with JTAG on iOS device? Three major capabilities are:
1) Arbitrary memory access (well, there’re some weird limitations though) — you can halt CPU and dump arbitrary portions of virtual memory or load arbitrary file from your computer back to device
2) Arbitrary CPU register access - you can halt CPU and view current register state and change value in any of them
3) Halt CPU at arbitrary point of execution, so you can use first 2 capabilities
With these capabilities you can do pretty much whatever you want with a device: execute arbitrary code at any point, dump anything you want (for example, SecureROM), play with MMIO...
...or grab firmware keys, as I did few weeks ago just by dumping iBoot, pointing “ticket” command’s address to load address, sending the patched iBoot back and then executing my custom payload, Lina, which allows to utilize aes_crypto_cmd()
Obviously Apple wouldn’t make their production devices vulnerable to some stolen cables. That’s because JTAGging is only possible on devices with CPFM lower or equal to 0x01
CPFM stands for ChiP Fusing Mode, as far as I know. It’s fused deep inside of a SoC and cannot be changed. It consists of two boolean values - security mode (bit 0) and production mode (bit 1)
If bit 0 is set, SoC has Secure security mode, otherwise Insecure
If bit 1 is set, SoC has Production production mode, otherwise Development
So, to be able to JTAG into device, it has to be Development fused (CPFM 0x01 or 0x00). In other cases, this is what you’ll get:
Cayman (Apple A10) production devices will connect, but no CPUs will be available to choose (about that later)
Skye (Apple A11) will connect and have SEP and ANS2 (some co-processor, I believe) available, but they’re always powered off
Perhaps that's because the version of Astris I have incorrectly detects chip revision of both Cayman and Skye targets I've got (iPad 2018 and iPhone X)
Such CPFM can only be on prototype devices, at least DVT or older. PVT always has CPFM 0x03 (Production + Secure)
To interact with SWD-cables you need a piece of software called Astris. It’s shipped as part of RestoreTools and HomeDiagnostics, never heard it to be shipped as a standalone package
You still can install it separately using Pacifist, but in that case you’ll have to launch LaunchDaemons and kernel extensions shipped with it manually
When you launch Astris with a probe connected to your Mac and a device connected to the probe, you’ll see something like this:
First thing you need to do is to choose CPU. For that:

cpu CPU0
Then you need to stop its execution:

halt

Usually it prints register dump:
Now you can change any register you like including PC

reg pc 0x41414141
Or load patched copy of iBoot back to device, so you can run classic payloads:

load path_to_file address
Some corrections about Astris installation: Astris package inside of RestoreTools/HomeDiagnostics doesn't contain many useful support scripts. So beside Astris itself, you should also install this part of HomeDiagnostics
The scripts seem to be (partially) incompatible with older/newer Astris versions, so install only matching versions from the same HomeDiagnostics package

For example, when I installed Whitetail scripts along with Electric Astris, I had issues with GDB debugging
Yes, those 8000...800N ports Astris prints when it detects a target are actually the ports you can use to connect to with GDB/LLDB
It never worked properly for me for some reason, but those additional scripts add few new debug features to Astris itself. For example, breakpoints and watchpoints (well, I've never noticed these commands before I installed the scripts)
Missing some Tweet in this thread? You can try to force a refresh.

Enjoying this thread?

Keep Current with Lisa Braun

Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!