<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.theiphonewiki.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fox8091</id>
	<title>The iPhone Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.theiphonewiki.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fox8091"/>
	<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/wiki/Special:Contributions/Fox8091"/>
	<updated>2026-05-22T01:09:38Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.14</generator>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=KBAG&amp;diff=101531</id>
		<title>KBAG</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=KBAG&amp;diff=101531"/>
		<updated>2020-03-16T20:26:21Z</updated>

		<summary type="html">&lt;p&gt;Fox8091: Fix spelling &amp;amp; make consistant&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Apple's [[IMG3 File Format|IMG3]] and [[IMG4 File Format|IMG4]] security scheme uses a data format called a '''KBAG'''. At the bottom of a firmware file, you will see something that will, on the ASCII side of your hex editor, say &amp;quot;GABK&amp;quot;, which, as ARM is [[wikipedia:little-endian|little-endian]] based, is &amp;quot;KBAG&amp;quot; flipped. Look on the hex side and you will see the KBAG according to this format:&lt;br /&gt;
&lt;br /&gt;
== How it works ==&lt;br /&gt;
It boils down to using the [[GID Key]] to decrypt &amp;lt;code&amp;gt;encIV&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;encKey&amp;lt;/code&amp;gt;, then using that key and IV to decrypt the DATA section of the file (the code itself).&lt;br /&gt;
&lt;br /&gt;
Because of the circumstances with the [[IMG3 File Format]], the kernel never needs to even touch the [[GID Key]] anymore, as its job is to just flash the image to the [[NOR]] as is, with container and all.&lt;br /&gt;
&lt;br /&gt;
In order to decrypt the KBAG for img3, you need to remove them using this command: &amp;lt;code&amp;gt;dd if=IMG3_FILE bs=1 skip=4741424B  count=0x70&amp;lt;/code&amp;gt; or for img4, &amp;lt;code&amp;gt;dd if=IMG4FILE bs=44 skip=1 | openssl enc -aes-256-cbc -d -nopad -iv IV -K KEY &amp;gt; OUTPUTFILE&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To grab the KBAG for img3 files, you'd run &amp;lt;code&amp;gt;xpwntool /path/to/img3/ /dev/null&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
This is different with img4 files. For these, you can use [https://github.com/xerub/img4lib img4lib] and run the following command: &amp;lt;code&amp;gt;img4 -i /path/to/image.im4p -b&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==KBAG Format==&lt;br /&gt;
===KBAG128===&lt;br /&gt;
 typedef struct Unparsed_KBAG_AES128 {&lt;br /&gt;
      uint32_t magic;       // string with bytes flipped (&amp;quot;KBAG&amp;quot; in little endian)&lt;br /&gt;
      uint32_t fullSize;    // size of KBAG from beyond that point to the end of it&lt;br /&gt;
      uint32_t tagDataSize; // size of KBAG without this 0xC header&lt;br /&gt;
      uint32_t cryptState;  // 1 if the key and IV in the KBAG are encrypted with the [[GID Key]]&lt;br /&gt;
                            // 2 is used with a second KBAG for the [[S5L8920]], use is unknown.&lt;br /&gt;
      uint32_t aesType;     // 0x80 = aes128 / 0xc0 = aes192 / 0x100 = aes256&lt;br /&gt;
      uint8_t encIV[16];    // IV for the firmware file, encrypted with the [[GID Key]]&lt;br /&gt;
      uint8_t encKey[16];   // Key for the firmware file, encrypted with the [[GID Key]]&lt;br /&gt;
 } UnparsedKbagAes128_t;&lt;br /&gt;
&lt;br /&gt;
===KBAG192===&lt;br /&gt;
 typedef struct Unparsed_KBAG_AES192 {&lt;br /&gt;
      uint32_t magic;       // string with bytes flipped (&amp;quot;KBAG&amp;quot; in little endian)&lt;br /&gt;
      uint32_t fullSize;    // size of KBAG from beyond that point to the end of it&lt;br /&gt;
      uint32_t tagDataSize; // size of KBAG without this 0xC header&lt;br /&gt;
      uint32_t cryptState;  // 1 if the key and IV in the KBAG are encrypted with the [[GID Key]]&lt;br /&gt;
                            // 2 is used with a second KBAG for the [[S5L8920]], use is unknown.&lt;br /&gt;
      uint32_t aesType;     // 0x80 = aes128 / 0xc0 = aes192 / 0x100 = aes256&lt;br /&gt;
      uint8_t encIV[16];    // IV for the firmware file, encrypted with the [[GID Key]]&lt;br /&gt;
      uint8_t encKey[24];   // Key for the firmware file, encrypted with the [[GID Key]]&lt;br /&gt;
 } UnparsedKbagAes192_t;&lt;br /&gt;
&lt;br /&gt;
===KBAG256===&lt;br /&gt;
 typedef struct Unparsed_KBAG_256 {&lt;br /&gt;
      uint32_t magic;       // string with bytes flipped (&amp;quot;KBAG&amp;quot; in little endian)&lt;br /&gt;
      uint32_t fullSize;    // size of KBAG from beyond that point to the end of it&lt;br /&gt;
      uint32_t tagDataSize; // size of KBAG without this 0xC header&lt;br /&gt;
      uint32_t cryptState;  // 1 if the key and IV in the KBAG are encrypted with the [[GID Key]]&lt;br /&gt;
                            // 2 is used with a second KBAG for the [[S5L8920]], use is unknown.&lt;br /&gt;
      uint32_t aesType;     // 0x80 = aes128 / 0xc0 = aes192 / 0x100 = aes256&lt;br /&gt;
      uint8_t encIV[16];    // IV for the firmware file, encrypted with the [[GID Key]]&lt;br /&gt;
      uint8_t encKey[32];   // Key for the firmware file, encrypted with the [[GID Key]]&lt;br /&gt;
 } UnparsedKbagAes256_t;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Firmware Tags]]&lt;/div&gt;</summary>
		<author><name>Fox8091</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=YukonB_17B111_(iPhone8,4)&amp;diff=99200</id>
		<title>YukonB 17B111 (iPhone8,4)</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=YukonB_17B111_(iPhone8,4)&amp;diff=99200"/>
		<updated>2020-02-19T04:06:22Z</updated>

		<summary type="html">&lt;p&gt;Fox8091: Add partial 13.2.3 keys&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{keys&lt;br /&gt;
 | Version               = 13.2.3&lt;br /&gt;
 | Build                 = 17B111&lt;br /&gt;
 | Device                = iPhone8,4&lt;br /&gt;
 | Codename              = YukonB&lt;br /&gt;
 | DownloadURL           = http://updates-http.cdn-apple.com/2019FallFCS/fullrestores/061-49534/9B7159D2-0698-11EA-8279-C2B9E97E1FF8/iPhone_4.0_64bit_13.2.3_17B111_Restore.ipsw&lt;br /&gt;
&lt;br /&gt;
 | Model                 = N69AP&lt;br /&gt;
 | Model2                = N69uAP&lt;br /&gt;
&lt;br /&gt;
 | RootFS                = 048-90764-106&lt;br /&gt;
 | RootFSKey             = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | UpdateRamdisk         = 048-90336-111&lt;br /&gt;
 | UpdateRamdiskIV       = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | RestoreRamdisk        = 048-90011-111&lt;br /&gt;
 | RestoreRamdiskIV      = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | AOP                   = aopfw-s8000aop.im4p&lt;br /&gt;
 | AOPIV                 = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | AppleLogo             = applelogo@2x~iphone.im4p&lt;br /&gt;
 | AppleLogoIV           = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | BatteryCharging0      = batterycharging0@2x~iphone.im4p&lt;br /&gt;
 | BatteryCharging0IV    = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | BatteryCharging1      = batterycharging1@2x~iphone.im4p&lt;br /&gt;
 | BatteryCharging1IV    = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | BatteryFull           = batteryfull@2x~iphone.im4p&lt;br /&gt;
 | BatteryFullIV         = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | BatteryLow0           = batterylow0@2x~iphone.im4p&lt;br /&gt;
 | BatteryLow0IV         = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | BatteryLow1           = batterylow1@2x~iphone.im4p&lt;br /&gt;
 | BatteryLow1IV         = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | DeviceTree            = DeviceTree.n69uap.im4p&lt;br /&gt;
 | DeviceTreeIV          = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | GlyphPlugin           = glyphplugin@1136~iphone-lightning.im4p&lt;br /&gt;
 | GlyphPluginIV         = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | iBEC                 = iBEC.n69.RELEASE.im4p&lt;br /&gt;
 | iBECIV               = Unknown&lt;br /&gt;
 | iBECKey              = Unknown&lt;br /&gt;
&lt;br /&gt;
 | iBEC2                 = iBEC.n69u.RELEASE.im4p&lt;br /&gt;
 | iBEC2IV               = e0d9a06cad043f8b505736ce8bec87c3&lt;br /&gt;
 | iBEC2Key              = bc5c628b24b43d40d965a77a344caacce75822ee4091051660dbc15e7466d064&lt;br /&gt;
&lt;br /&gt;
 | iBoot                = iBoot.n69.RELEASE.im4p&lt;br /&gt;
 | iBootIV              = Unknown&lt;br /&gt;
 | iBootKey             = Unknown&lt;br /&gt;
&lt;br /&gt;
 | iBoot2                = iBoot.n69u.RELEASE.im4p&lt;br /&gt;
 | iBoot2IV              = da902ec9c927978c7e76e5fa353d8bd6&lt;br /&gt;
 | iBoot2Key             = c92739cf3b09d9147cd709e0a31333141af0ffc70a9b46610209f19d34e893f6&lt;br /&gt;
&lt;br /&gt;
 | iBSS                 = iBSS.n69.RELEASE.im4p&lt;br /&gt;
 | iBSSIV               = Unknown&lt;br /&gt;
 | iBSSKey              = Unknown&lt;br /&gt;
&lt;br /&gt;
 | iBSS2                 = iBSS.n69u.RELEASE.im4p&lt;br /&gt;
 | iBSS2IV               = cca4f18dc5705ee3a0b7e34f088bc2b2&lt;br /&gt;
 | iBSS2Key              = 88d47fc121bdcd647667b731c985f4896bef8051673ca4f03a5c5857763d0d57&lt;br /&gt;
&lt;br /&gt;
 | Kernelcache           = kernelcache.release.iphone8b&lt;br /&gt;
 | KernelcacheIV         = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | LLB                  = LLB.n69.RELEASE.im4p&lt;br /&gt;
 | LLBIV                = Unknown&lt;br /&gt;
 | LLBKey               = Unknown&lt;br /&gt;
&lt;br /&gt;
 | LLB2                  = LLB.n69u.RELEASE.im4p&lt;br /&gt;
 | LLB2IV                = 2ff9bee41a12b216135bb7cc01d984ce&lt;br /&gt;
 | LLB2Key               = 42930cdd0c7827180d08d2af5637d4e45bcf82e7caa1f10ab0e9fdf6999095db&lt;br /&gt;
&lt;br /&gt;
 | RecoveryMode          = recoverymode@1136~iphone-lightning.im4p&lt;br /&gt;
 | RecoveryModeIV        = Not Encrypted&lt;br /&gt;
&lt;br /&gt;
 | SEPFirmware           = sep-firmware.n69.RELEASE.im4p&lt;br /&gt;
 | SEPFirmwareIV         = Unknown&lt;br /&gt;
 | SEPFirmwareKey        = Unknown&lt;br /&gt;
 | SEPFirmwareKBAG       = Unknown&lt;br /&gt;
&lt;br /&gt;
 | SEPFirmware2          = sep-firmware.n69u.RELEASE.im4p&lt;br /&gt;
 | SEPFirmware2IV        = Unknown&lt;br /&gt;
 | SEPFirmware2Key       = Unknown&lt;br /&gt;
 | SEPFirmware2KBAG      = ec0b36b06561a0c66923523ae282f579dbee4f795dfa116f978483eccd7bc509952836d52a149ad51e405a6b818e2e8c&lt;br /&gt;
&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Fox8091</name></author>
		
	</entry>
</feed>