Пример #1
0
        /// <summary>
        /// Opens an iDeviceFile stream on the specified path
        /// </summary>
        /// <param name="phone">A valid iDevice object</param>
        /// <param name="path">The file to open</param>
        /// <param name="openmode">A <see cref="FileAccess"/> value that specifies the operations that can be performed on the file</param>
        /// <returns></returns>
        unsafe public static iDeviceFile Open(iDevice phone, string path, FileAccess openmode)
        {
            OpenMode mode;
            int      ret;
            long     handle;
            string   full_path;

            mode = OpenMode.None;
            switch (openmode)
            {
            case FileAccess.Read: mode = OpenMode.Read; break;

            case FileAccess.Write: mode = OpenMode.Write; break;

            case FileAccess.ReadWrite: throw new NotImplementedException("Read+Write not (yet) implemented");
            }

            full_path = phone.FullPath(phone.CurrentDirectory, path);
            ret       = MobileDevice.AFCFileRefOpen(phone.AFCHandle, full_path, (int)mode, 0, out handle);
            if (ret != 0)
            {
                phone.ReConnect();
                throw new IOException("AFCFileRefOpen failed with error " + ret.ToString());
            }

            return(new iDeviceFile(phone, handle, mode));
        }
Пример #2
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (Interface.Device == null)
     {
         Interface = new iDevice();
     }
     if (Interface.Device == null)
     {
         lblStatus.Text = "No device connected";                
         return;
     }
     grpCache.Enabled = false;
     activate_btn.Enabled = false;
     deactivate_btn.Enabled = false;
     cache_btn.Enabled = false;
     int result = Interface.Deactivate();
     if (result == 0)
     {
         lblStatus.Text = "Device successfully deactivated";                
     }
     else
     {
         lblStatus.Text = "Device could not be deactivated";                
     }
     activate_btn.Enabled = true;
     deactivate_btn.Enabled = true;
     cache_btn.Enabled = true;
     grpCache.Enabled = true;
 }
Пример #3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {                
         Interface = new iDevice();                
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
         Application.Exit();
     }
 }
Пример #4
0
 private iDeviceFile(iDevice phone, long handle, OpenMode mode) : base()
 {
     this.phone  = phone;
     this.mode   = mode;
     this.handle = handle;
 }
Пример #5
0
 /// <summary>
 /// Opens a file for writing
 /// </summary>
 /// <param name="phone">A valid iDevice object</param>
 /// <param name="path">The file to be opened for writing</param>
 /// <returns>An unshared <c>iDeviceFile</c> object on the specified path with Write access. </returns>
 public static iDeviceFile OpenWrite(iDevice phone, string path)
 {
     return(iDeviceFile.Open(phone, path, FileAccess.Write));
 }
Пример #6
0
 /// <summary>
 /// Opens a file for reading
 /// </summary>
 /// <param name="phone">A valid iDevice object</param>
 /// <param name="path">The file to be opened for reading</param>
 /// <returns>An unshared <c>iDeviceFile</c> object on the specified path with Write access. </returns>
 public static iDeviceFile OpenRead(iDevice phone, string path)
 {
     return(iDeviceFile.Open(phone, path, FileAccess.Read));
 }
Пример #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("CFManzana by iSn0wra1n");

            iDevice dev = new iDevice();

            /* Reads various device settings. Values can be

            * ActivationPublicKey
            * ActivationState
            * ActivationStateAcknowledged
            * ActivityURL
            * BasebandBootloaderVersion
            * BasebandSerialNumber
            * BasebandStatus
            * BasebandVersion
            * BluetoothAddress
            * BuildVersion
            * CPUArchitecture
            * DeviceCertificate
            * DeviceClass
            * DeviceColor
            * DeviceName
            * DevicePublicKey
            * DieID
            * FirmwareVersion
            * HardwareModel
            * HardwarePlatform
            * HostAttached
            * IMLockdownEverRegisteredKey
            * IntegratedCircuitCardIdentity
            * InternationalMobileEquipmentIdentity
            * InternationalMobileSubscriberIdentity
            * iTunesHasConnected
            * MLBSerialNumber
            * MobileSubscriberCountryCode
            * MobileSubscriberNetworkCode
            * ModelNumber
            * PartitionType
            * PasswordProtected
            * PhoneNumber
            * ProductionSOC
            * ProductType
            * ProductVersion
            * ProtocolVersion
            * ProximitySensorCalibration
            * RegionInfo
            * SBLockdownEverRegisteredKey
            * SerialNumber
            * SIMStatus
            * SoftwareBehavior
            * SoftwareBundleVersion
            * SupportedDeviceFamilies
            * TelephonyCapability
            * TimeIntervalSince1970
            * TimeZone
            * TimeZoneOffsetFromUTC
            * TrustedHostAttached
            * UniqueChipID
            * UniqueDeviceID
            * UseActivityURL
            * UseRaptorCerts
            * Uses24HourClock
            * WeDelivered
            * WiFiAddress
             * */
            Console.WriteLine("\nDevice Name: " + dev.CopyValue("DeviceName"));
            Console.WriteLine("Device iOS Version: " + dev.CopyValue("ProductVersion"));
            System.Threading.Thread.Sleep(-1);
        }
Пример #8
0
		private iDeviceFile(iDevice phone, long handle, OpenMode mode) : base() {
			this.phone = phone;
			this.mode = mode;
			this.handle = handle;
		}
Пример #9
0
		/// <summary>
		/// Opens a file for writing
		/// </summary>
		/// <param name="phone">A valid iDevice object</param>
		/// <param name="path">The file to be opened for writing</param>
		/// <returns>An unshared <c>iDeviceFile</c> object on the specified path with Write access. </returns>
		public static iDeviceFile OpenWrite(iDevice phone, string path) {
			return iDeviceFile.Open(phone, path, FileAccess.Write);
		}
Пример #10
0
		/// <summary>
		/// Opens a file for reading
		/// </summary>
		/// <param name="phone">A valid iDevice object</param>
		/// <param name="path">The file to be opened for reading</param>
		/// <returns>An unshared <c>iDeviceFile</c> object on the specified path with Write access. </returns>
		public static iDeviceFile OpenRead(iDevice phone, string path) {
			return iDeviceFile.Open(phone, path, FileAccess.Read);
		}
Пример #11
0
		/// <summary>
		/// Opens an iDeviceFile stream on the specified path
		/// </summary>
		/// <param name="phone">A valid iDevice object</param>
		/// <param name="path">The file to open</param>
		/// <param name="openmode">A <see cref="FileAccess"/> value that specifies the operations that can be performed on the file</param>
		/// <returns></returns>
		unsafe public static iDeviceFile Open(iDevice phone, string path, FileAccess openmode) {
			OpenMode	mode;
			int			ret;
			long		handle;
			string		full_path;

			mode = OpenMode.None;
			switch(openmode) {
				case FileAccess.Read: mode = OpenMode.Read; break;
				case FileAccess.Write: mode = OpenMode.Write; break;
				case FileAccess.ReadWrite: throw new NotImplementedException("Read+Write not (yet) implemented");
			}

			full_path = phone.FullPath(phone.CurrentDirectory, path);
			ret = MobileDevice.AFCFileRefOpen(phone.AFCHandle, full_path, (int)mode, 0, out handle);
			if (ret != 0) {
				phone.ReConnect();
				throw new IOException("AFCFileRefOpen failed with error " + ret.ToString());
			}

			return new iDeviceFile(phone, handle, mode);
		}
Пример #12
0
 private void cache_btn_Click(object sender, EventArgs e)
 {
     if (Interface.Device == null)
     {
         Interface = new iDevice();
     }
     if (Interface.Device == null)
     {
         lblStatus.Text = "No device connected";
         return;
     }
     grpCache.Enabled = false;
     activate_btn.Enabled = false;
     deactivate_btn.Enabled = false;
     cache_btn.Enabled = false;
     MessageBox.Show("The process of creating a cache is simple: perform a legit activation, storing all the required data. That way, you can borrow (or, I guess, steal (don't do that, though)) a sim for the carrier your iPhone is locked to, and be able to reactivate without having to get that sim back.\nThis data is stored in a folder where you want it. It does not get sent to me (iSn0wra1n) or anyone else. Plus, we really have better things to do than look at your activation data.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     //This really isn't needed for iPod Touches or Wi-Fi only iPads (and I don't know if 3G iPad users need this, but be safe and do it).\n\nPress any key to continue or CONTROL-C to abort...\n\n");
     if (activationticket.Checked == true && Interface.CopyValue("ActivationState") == "Unactivated")
     {
         #region Get Wildcard Ticket
         string response = null;
         if (IsConnected() == false)
         {
             lblStatus.Text = "No Internet connection available";
             return;
         }
         lblStatus.Text = "Getting Wildcard ticket from Apple";
         ThreadStart starter = delegate
         {
             SslTcpClient.RunClient("albert.apple.com", Albert_Apple_Stuff(null), ref response);
         };
         Thread albertThread = new Thread(starter);
         albertThread.Start();
         while (albertThread.IsAlive == true)
         {
             Application.DoEvents();
         }
         if (response == "")
         {
             lblStatus.Text = "No response returned from Apple";
             return;
         }
         #endregion
         #region Grab necessary information
         lblStatus.Text = "Grabbing information from the Wildcard ticket";
         string[] keys = { "AccountTokenCertificate", "AccountToken", "FairPlayKeyData", "DeviceCertificate", "AccountTokenSignature" };
         IntPtr[] values = GrabTheData(response);                
         #endregion
     activationticket:
         Save.Filter = "Activation Ticket|*.iTicket";
         Save.DefaultExt = "iTicket";
         Save.ShowDialog();
         if (Save.FileName == "")
         {
             MessageBox.Show("Please select a location!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
             goto activationticket;
         }
         File.WriteAllText(Save.FileName, new CFDictionary(keys,values).ToString());
         lblStatus.Text = "Activation Ticket saved";
         Save.FileName = "";
     }
     else if (activationdata.Checked == true)
     {
     activationdata:
         try
         {
             Save.Filter = "Activation Data|*.iData";
             Save.DefaultExt = "iData";
             Save.ShowDialog();
             if (Save.FileName == "")
             {
                 MessageBox.Show("Please select a location!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 goto activationdata;
             }
             File.WriteAllText(Save.FileName, new CFDictionary(Interface.CopyDictionary("ActivationInfo")).ToString());
             lblStatus.Text = "Activation Data Saved";
             Save.FileName = "";
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             Application.Exit();
         }
     }
     else if (activationticket.Checked == true && Interface.CopyValue("ActivationState") != "Unactivated")            
     {
         lblStatus.Text = "Deactivate device to cache Activation Ticket";                
     }
     else
     {
         lblStatus.Text = "No cache option selected";
     }
     activate_btn.Enabled = true;
     deactivate_btn.Enabled = true;
     cache_btn.Enabled = true;
     grpCache.Enabled = true;
 }
Пример #13
0
        private void activate_btn_Click(object sender, EventArgs e)
        {
            if (Interface.Device == null)
            {
                Interface = new iDevice();
            }
            if (Interface.Device == null)
            {
                lblStatus.Text = "No device connected";                
                return;
            }
            if (Interface.CopyValue("ActivationState") != "Unactivated")
            {
                lblStatus.Text= "Device already Activated!";
                return;
            }
            grpCache.Enabled = false;
            activate_btn.Enabled = false;
            deactivate_btn.Enabled = false;
            cache_btn.Enabled = false;
            string response=null;
            lblStatus.Text = "";
            bool useCache = false;
            if (activationdata.Checked == true)
            {
            opendialog:
                Open.DefaultExt = "iData";
                Open.Filter = "Activation Data|*.iData";
                Open.ShowDialog();
                if (Open.FileName == "")
                {
                    MessageBox.Show("Please select a location!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    goto opendialog;
                }
                useCache = true;
            }

#region Step 1: Get Wildcard ticket
            if (IsConnected() == false)
            {
                lblStatus.Text = "No Internet connection available";
                goto Cleanup;
            }
            lblStatus.Text = "Getting Wildcard ticket from Apple";
            if (useCache == true)
            {
                ThreadStart starter = delegate
                {
                    SslTcpClient.RunClient("albert.apple.com", Albert_Apple_Stuff(Open.FileName), ref response);
                };
                Thread albertThread = new Thread(starter);
                albertThread.Start();
                while (albertThread.IsAlive == true)
                {
                    Application.DoEvents();
                }
            }
            else
            {
                ThreadStart starter = delegate
                {
                    SslTcpClient.RunClient("albert.apple.com", Albert_Apple_Stuff(null), ref response);
                };
                Thread albertThread = new Thread(starter);
                albertThread.Start();
                while (albertThread.IsAlive == true)
                {
                    Application.DoEvents();
                }
            }
            if (response.Contains("ack-received") == true)
            {
                lblStatus.Text = "Invalid response received from Apple";
                goto Cleanup;
            }
            if (response == "" || response == null)
            {
                lblStatus.Text = "No response returned from Apple";
                goto Cleanup;
            }
#endregion            
#region Step 2: Grab necessary information from Wildcard ticket
            lblStatus.Text = "Grabbing information from the Wildcard ticket";            
            IntPtr[] wct = GrabTheData(response);
#endregion
#region Step 3: Send Wildcard ticket to the iDevice            
            string[] keys = { "AccountTokenCertificate", "AccountToken", "FairPlayKeyData", "DeviceCertificate", "AccountTokenSignature"};
            lblStatus.Text = ("Sending Wildcard ticket to device");            
            int status = Interface.Activate(new CFDictionary(keys, wct));
            lblStatus.Text = ("Wildcard ticket sent to device");            
#endregion
#region Step 4: Check if activation was successful            
            if (status != 0)
            {
                lblStatus.Text = "Device could not be activated!";                
            }
            else
            {
                lblStatus.Text = "Device successfully activated!";                
            }
#endregion            
            Cleanup:
            activate_btn.Enabled = true;
            deactivate_btn.Enabled = true;
            cache_btn.Enabled = true;
            grpCache.Enabled = true;
            Open.FileName = "";
        }