Exemplo n.º 1
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;
        }
Exemplo n.º 2
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          = "";
        }