<?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=Comex</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=Comex"/>
	<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/wiki/Special:Contributions/Comex"/>
	<updated>2026-05-08T13:43:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.14</generator>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=MobileBackup_Copy_Exploit&amp;diff=7389</id>
		<title>MobileBackup Copy Exploit</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=MobileBackup_Copy_Exploit&amp;diff=7389"/>
		<updated>2010-07-23T18:14:27Z</updated>

		<summary type="html">&lt;p&gt;Comex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;BackupAgent normally restricts files to be restored to a specific set of directories (&amp;quot;domains&amp;quot;).  It even has a check to ensure that &amp;quot;..&amp;quot; isn't in the path:&lt;br /&gt;
&lt;br /&gt;
    Path contains sneaky dots to traverse up outside of the domain: %@&lt;br /&gt;
&lt;br /&gt;
However, for some reason, this check isn't applied when taking alternate code paths for special handling of certain files.  For example, a restore to HomeDomain with a path starting with Library/Preferences/SystemConfiguration/ is migrated to the new directory for system configuration, /var/preferences/SystemConfiguration.  This bypasses the sneaky dots check, so spirit is able to restore to this path:&lt;br /&gt;
&lt;br /&gt;
    Library/Preferences/SystemConfiguration/../../../../../var/db/launchd.db/com.apple.launchd/overrides.plist&lt;br /&gt;
&lt;br /&gt;
This was fixed in iOS 3.2.1 and 4.0.&lt;br /&gt;
&lt;br /&gt;
[[Category:Exploits]]&lt;/div&gt;</summary>
		<author><name>Comex</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=MobileBackup_Copy_Exploit&amp;diff=6387</id>
		<title>MobileBackup Copy Exploit</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=MobileBackup_Copy_Exploit&amp;diff=6387"/>
		<updated>2010-05-14T23:11:34Z</updated>

		<summary type="html">&lt;p&gt;Comex: New page: BackupAgent normally restricts files to be restored to a specific set of directories (&amp;quot;domains&amp;quot;).  It even has a check to ensure that &amp;quot;..&amp;quot; isn't in the path:      Path contains sneaky dots...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;BackupAgent normally restricts files to be restored to a specific set of directories (&amp;quot;domains&amp;quot;).  It even has a check to ensure that &amp;quot;..&amp;quot; isn't in the path:&lt;br /&gt;
&lt;br /&gt;
    Path contains sneaky dots to traverse up outside of the domain: %@&lt;br /&gt;
&lt;br /&gt;
However, for some reason, this check isn't applied when taking alternate code paths for special handling of certain files.  For example, a restore to HomeDomain with a path starting with Library/Preferences/SystemConfiguration/ is migrated to the new directory for system configuration, /var/preferences/SystemConfiguration.  This bypasses the sneaky dots check, so spirit is able to restore to this path:&lt;br /&gt;
&lt;br /&gt;
    Library/Preferences/SystemConfiguration/../../../../../var/db/launchd.db/com.apple.launchd/overrides.plist&lt;/div&gt;</summary>
		<author><name>Comex</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=BPF_STX_Kernel_Write_Exploit&amp;diff=6386</id>
		<title>BPF STX Kernel Write Exploit</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=BPF_STX_Kernel_Write_Exploit&amp;diff=6386"/>
		<updated>2010-05-14T23:06:45Z</updated>

		<summary type="html">&lt;p&gt;Comex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;bpf has a little virtual machine that executes packet filters.  The machine includes a &amp;quot;scratch area&amp;quot; which is stored as an array on the stack.  There are two instructions that write to that array:&lt;br /&gt;
&lt;br /&gt;
        case BPF_ST:&lt;br /&gt;
            mem[pc-&amp;gt;k] = A;                                                &lt;br /&gt;
            continue;                                                      &lt;br /&gt;
        &lt;br /&gt;
        case BPF_STX:&lt;br /&gt;
            mem[pc-&amp;gt;k] = X;&lt;br /&gt;
            continue;          &lt;br /&gt;
&lt;br /&gt;
bpf_validate runs first to check the program, and handles BPF_ST correctly, but forgets to handle BPF_STX:&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Check that memory operations use valid addresses.&lt;br /&gt;
         */&lt;br /&gt;
        if ((BPF_CLASS(p-&amp;gt;code) == BPF_ST ||&lt;br /&gt;
             (BPF_CLASS(p-&amp;gt;code) == BPF_LD &amp;amp;&amp;amp;&lt;br /&gt;
              (p-&amp;gt;code &amp;amp; 0xe0) == BPF_MEM)) &amp;amp;&amp;amp;&lt;br /&gt;
            p-&amp;gt;k &amp;gt;= BPF_MEMWORDS)&lt;br /&gt;
            return 0;&lt;br /&gt;
&lt;br /&gt;
This allows arbitrary locations on the stack to be modified.&lt;br /&gt;
&lt;br /&gt;
This bug was actually fixed in FreeBSD: http://svn.freebsd.org/viewvc/base/head/sys/net/bpf_filter.c?r1=182380&amp;amp;r2=182379&amp;amp;pathrev=182380&lt;/div&gt;</summary>
		<author><name>Comex</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=BPF_STX_Kernel_Write_Exploit&amp;diff=6385</id>
		<title>BPF STX Kernel Write Exploit</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=BPF_STX_Kernel_Write_Exploit&amp;diff=6385"/>
		<updated>2010-05-14T23:06:00Z</updated>

		<summary type="html">&lt;p&gt;Comex: New page: bpf has a little virtual machine that executes packet filters.  The machine includes a &amp;quot;scratch area&amp;quot; which is stored as an array on the stack.  There are two instructions that write to th...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;bpf has a little virtual machine that executes packet filters.  The machine includes a &amp;quot;scratch area&amp;quot; which is stored as an array on the stack.  There are two instructions that write to that array:&lt;br /&gt;
&lt;br /&gt;
        case BPF_ST:&lt;br /&gt;
            mem[pc-&amp;gt;k] = A;                                                &lt;br /&gt;
            continue;                                                      &lt;br /&gt;
        &lt;br /&gt;
        case BPF_STX:&lt;br /&gt;
            mem[pc-&amp;gt;k] = X;&lt;br /&gt;
            continue;          &lt;br /&gt;
&lt;br /&gt;
bpf_validate runs first to check the program, and handles BPF_ST correctly, but forgets to handle BPF_STX:&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Check that memory operations use valid addresses.&lt;br /&gt;
         */&lt;br /&gt;
        if ((BPF_CLASS(p-&amp;gt;code) == BPF_ST ||&lt;br /&gt;
             (BPF_CLASS(p-&amp;gt;code) == BPF_LD &amp;amp;&amp;amp;&lt;br /&gt;
              (p-&amp;gt;code &amp;amp; 0xe0) == BPF_MEM)) &amp;amp;&amp;amp;&lt;br /&gt;
            p-&amp;gt;k &amp;gt;= BPF_MEMWORDS)&lt;br /&gt;
            return 0;&lt;br /&gt;
        /*&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This was actually fixed in FreeBSD: http://svn.freebsd.org/viewvc/base/head/sys/net/bpf_filter.c?r1=182380&amp;amp;r2=182379&amp;amp;pathrev=182380&lt;/div&gt;</summary>
		<author><name>Comex</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=Talk:Spirit&amp;diff=6384</id>
		<title>Talk:Spirit</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=Talk:Spirit&amp;diff=6384"/>
		<updated>2010-05-14T22:54:46Z</updated>

		<summary type="html">&lt;p&gt;Comex: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There exists also a tool called [[Spirit Fixer|Spirit Fixer v1.01]], written by [[Kirma]]. Anybody knows what that is? Here's a link: http://twitter.com/elior231/status/13296125900&lt;br /&gt;
&lt;br /&gt;
--[[User:Http|http]] 21:42, 4 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I'd love to see a technical writeup of everything, although I don't blame you if you don't. I'm lazy about those things too. As far as trying to keep it secret from Apple, I don't feel theres a point, they'll find it no matter what we do.&lt;br /&gt;
&lt;br /&gt;
--[[User:Geohot|geohot]] 14:02, 5 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I have started reverse engineering Spirit and making some UML(like) data flow and function diagrams. The problem is that I am guessing at too many things since I did not wana post anything and have someone get pissed it was out there. I am up for putting a formal brief together if others want to collaborate. I would imagine as Geohot said, that apple had this disassembled before the .tar was dry. Not to mention that they are not just looking for the exploit that was used (since they most likely had a whiteboard full of potentials during design) , they are looking for copyright violations and their stollen code in every bit of its bits.  &lt;br /&gt;
&lt;br /&gt;
--KodeSlinger 16:31, 5 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
Meh, as mentioned on spiritjb.com, once Apple has shown that they've fixed it, the source will be released anyway. - MuscleNerd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@MuscleNerd - I started working on it BS (Before Spirit :) ), to create a centralized location that dynamically maps (HW/FW/SW) physical and logical drawings together. My thought was something like this wiki on crack. Ideally to generate functional diagrams of the idevice that act as a starting point to link to more detailed sections pertaining to that functions exploits, related functions, and source code samples(or any other data). Since I am new to this community I have been trying to organize this data for my own brain, and thought others might use it. I will post some screen shots later. The more organized we are the easier it will be to exploit the next vulnerability. &lt;br /&gt;
--[[User:Viper911h|KodeSlinger]] 20:11, 5 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
Oh hah, cool :)  If you do that though, obviously you shouldn't go overboard and start publicly discussing variations of this that would help Apple close other holes yet to be exploited (it sounds like your well-versed enough to do that!) - MuscleNerd&lt;br /&gt;
&lt;br /&gt;
@MuscleNerd - Hah; yeah obviously cool kidz only lol --[[User:Viper911h|KodeSlinger]] 21:08, 5 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Reversing Spirit ==&lt;br /&gt;
&lt;br /&gt;
I just started reversing Spirit and thought I'd share what I learned so far in hopes of hearing more from others.&lt;br /&gt;
&lt;br /&gt;
Spirit.exe extracts a bunch of files into a temp directory as follows:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
+ Documents and Settings/&amp;lt;User&amp;gt;/Local Settings/spiritxxx&lt;br /&gt;
|&lt;br /&gt;
+ - dl&lt;br /&gt;
|   |&lt;br /&gt;
|   + - dl.exe&lt;br /&gt;
|&lt;br /&gt;
+ - igor&lt;br /&gt;
|   |&lt;br /&gt;
|   + - 2dcde0a77381d24b7c02ac0cf7f714434c4ccdcf.dylib&lt;br /&gt;
|   + - 3e404d11fcbd5486d3be2dd86ce21316e1854842.dylib&lt;br /&gt;
|   + - 74227c0021c5e12effb5bd3175eb469a8df0622e.dylib&lt;br /&gt;
|   + - b735701843456754988021d128c2671ee36d1b04.dylib&lt;br /&gt;
|   + - f6c17e934ba0ad477812de0b7cb019396d259d93.dylib&lt;br /&gt;
|   + - install&lt;br /&gt;
|   + - map.plist&lt;br /&gt;
|&lt;br /&gt;
+ - resources&lt;br /&gt;
    |&lt;br /&gt;
    + - 320x480.jpg&lt;br /&gt;
    + - 1024x768.jpg&lt;br /&gt;
    + - overrides.plist&lt;br /&gt;
    + - icon.ico&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Spirit.exe is simply a GUI wrapper for dl.exe, which does the heavy lifting and is written using the cross-platform library CoreFoundation.dll.  Dl.exe uses the iTunes DLL to get access to the iDevice, registering a callback function through AMDeviceNotificationSubscribe.  The callback function launches a thread, which uploads 4 files as follows:&lt;br /&gt;
&lt;br /&gt;
# One of the dylibs (depending on the iDevice version?) is uploaded as /var/mobile/Media/spirit/one.dylib&lt;br /&gt;
# The Mach-O ARM executable &amp;quot;install&amp;quot; is uploaded as /var/mobile/Media/spirit/install&lt;br /&gt;
# The Spirit.exe is uploaded as /var/mobile/Media/spirit/freeze.tar.xz&lt;br /&gt;
# One of the jpgs is uploaded as /var/mobile/Media/spirit/bg.jpg&lt;br /&gt;
&lt;br /&gt;
After the files are uploaded, the upload thread signals to the main thread that the files are ready.  The main thread then sends over two plists (shown at the end of the log below) via MobileBackup.&lt;br /&gt;
&lt;br /&gt;
As I've only just started looking at this, and I'm also new to the iPhone scene, I have lots of questions.&lt;br /&gt;
&lt;br /&gt;
# Is the MobileBackup interface documented anywhere?  Was it used in other jb tools before Spirit?&lt;br /&gt;
# Why is Spirit.exe uploaded to the iDevice as freeze.tar.xz?&lt;br /&gt;
# What purpose do map.plist and overrides.plist serve?&lt;br /&gt;
# What are the two plists sent at the end of the transfer, and how do they allow the &amp;quot;install&amp;quot; image to be executed?&lt;br /&gt;
# What does install do to provide an untethered solution?&lt;br /&gt;
&lt;br /&gt;
I'll post more as I learn, but it would be nice to hear if others have made more progress.&lt;br /&gt;
&lt;br /&gt;
-[[User:EnohpiDesrever|EnohpiDesrever]] 16:47, 14 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
# Don't think it's documented.&lt;br /&gt;
# Actually, freeze.tar.xz is tacked on to Spirit.exe, after the string 'magicmagicmagicm'.  xz is http://tukaani.org/xz/&lt;br /&gt;
# One maps firmware version to the dylib that should be uploaded.  The other is read by launchd.&lt;br /&gt;
# Just look at the contents of overrides.plist and the launchd source.  The nefarious part is actually getting that file in the appropriate directory.  (Note that overrides is only used for the initial install, because launchd spawns everything at once and the following solution ensures the exploit is run first.)&lt;br /&gt;
# By installing itself as /usr/lib/libgmalloc.dylib.  To quote saurik: &amp;quot;if you touch the file /var/db/.launchd_use_gmalloc, then the first thing launchd does is set DYLD_INSERT_LIBRARIES to /usr/lib/libgmalloc.dylib and restart itself&amp;quot;&lt;br /&gt;
&lt;br /&gt;
--[[User:Comex|Comex]] 22:54, 14 May 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Comex</name></author>
		
	</entry>
</feed>