IPhone Hacking

From ivc wiki
Revision as of 22:22, 24 October 2007 by Ivc (talk | contribs)
Jump to navigationJump to search

The iPhone was released in the USA 29th June 2007, and after 2 months it was finally possible to hack the iPhone to allow it run true native third-party applications, aka homebrew applications.

Downgrade

If the phone came with v1.1.1, it's (as of writing) necessary to downgrade to v1.0.2.

  1. Download the iPhone v1.0.2 firmware from Apple.
  2. Download and install iTunes v7.3.2. Select a new folder if iTunes is already installed.
  3. On the iPhone, press and hold both the SLEEP and HOME buttons for 8-10 seconds.
  4. The screen should go completely black, release the SLEEP button and continue to hold the HOME button.
  5. When the iPhone says 'Connect to iTunes' release the button and connect the USB-cable.
  6. Open iTunes and click 'Ok' when it prompts that a restore is needed. Hold SHIFT (on Windows) and select the v1.0.2 firmware file.
  7. The restore should complete with a 1013 error. A yellow triangle on the iPhone indicates that v1.0.2 has been installed.

Jailbreak

Jailbreaking means to escape the 'Media'-partition of the iPhone where only some settings and all the media files is stored. Technically the jailbreak is essentially 'chroot /var/root/Media'.

  1. There are two ways to jailbreak on Windows, Apptapp installer or iBrickr. Download the recommended Apptapp installer.
  2. With the iPhone still in the yellow-triangle-restore-mode, run Apptapp and let it process through all the steps. It will jailbreak and install Installer.app.
  3. Once jailbreaked, the iPhone will return to the 'Slide for emergency' and still needs activation to load the normal Springboard.

Activate

A normal iPhone can only work and be activated on the AT&T operator. Faking the activation tricks the iPhone into 'Activated'-state and all the functions except phone is available.

  1. Download the iAsign package for Mac and then the Windows (Win32) update. Put iAsign.exe in the 'bin'-folder.
  2. Upload the iPhoneActivation.pem file to the iPhone and put it in /Library/System/Lockdown/ using the upload function iBrickr.
  3. Open a command-prompt (Start -> Run -> cmd) and change directory (cd) to the iAsign folder.
  4. Run 'iAsign --automatic iPhoneActivation_private.pem' to generate a new activated certificate on the iPhone.
  5. A message should show stating the iPhone is activated. The 'Slide to emergency'-message should have changed to 'Slide to unlock'.
  6. You now see the Springboard and the 'Installer' application.
  7. To make it easy to upload files and execute remote commands on the iPhone, open Installer, install 'BSD Subsystem' and 'OpenSSH'. Use WinSCP to connect with username 'root' and password 'dottie' (first connect takes time).

Youtube

Youtube requires some certificates to work properly.

  1. Download the 3 required Youtube files.
  2. Upload the data_ark.plist, device_private_key.pem and device_public_key.pem files to /var/root/Library/Lockdown/.
  3. Open the data_ark.plist and copy the certificate block starting with 'LS0tLS1CRUd...'.
  4. In the same directory, go into 'pair_records', edit the file (double click), paste the certificate into the DeviceCertificate section.
  5. Go into the 'activation_records' directory and to the same for all the files.
  6. Hold the SLEEP button for 5 seconds and reboot the iPhone.

Unlock

To be able to use any SIM-card the iPhone's baseband firmware has to be modified.

  1. Download AnySIM v1.1 and extract the AnySIM.app folder.
  2. Upload the AnySIM.app folder to the /Application/ directory on the iPhone
  3. Change the permissions on the 'anysim' binary to 0755 by selecting 'Properties' in WinSCP and checking all the checkboxes for 'X'.
  4. Shutdown the iPhone, insert the new SIM-card and power-on. AnySIM should appear in the Springboard.
  5. Open AnySIM, disable the Auto-lock as instructed and follow the two steps to begin the unlocking. Normally takes 5-10 minutes to complete the unlocking.
  6. If you get a 'SIM Locked'-message after the process is successful, press 'Unlock' and enter the PIN-code for the SIM. You can disable the prompt in Settings -> Phone -> SIM Pin.

Localization

The iPhone does not come with any other dictionary or keyboard layouts then the default American package.

New recommended method:

  1. In Safari go to http://russianiphone.com/beta/en/ and http://iph0ne.moo.no/ and install the sources when prompted.
  2. Go into Installer and install Mobile Enhancer (which is a plugin like extension) and Norwegian Keyboard (plugin for Mobile Enhancer).
  3. Reboot phone.

Old method: To add Norwegian locale support, a few files has to be patched. The character '[', ']' and '{' will be replaced with 'æ', 'ø' and 'å' respectively.

  1. Download the Norwegian dictionary from the iPhoneShop download page.
  2. Download the patched keyboard .artwork file with Norwegian character keyboard images.
  3. Download the patched UIKit binary to output the actual Norwegian character code when the key is touched.
  4. Extract all the files and put them into the /System/Library/Frameworks/UIKit.framework/ directory on the iPhone. Backup the originals. Change the permissions for 'UIKit' to 0755.
  5. Reboot the iPhone and test the new keyboard and dictionary.

Phone Number Format

The default phone number format is the classic American standard with the parentheses and spaces. The format string is dictated by a simple settings file.

Replace US format with NO format:

  1. On the iPhone, go to /System/Library/Frameworks/AddressBookUI.framework/ and download the ABPPhoneFormats.plist file.
  2. Browse to this binary-to-xml website to convert the plist to a XML-file.
  3. Open the new file in a plain text editor and find the 'US'-key.
  4. Change the format string in the 'US'-key to the new format. For Norway the string will be ######## and +47 ########.
  5. Save the file and upload the file to the same directory. No need to convert the plist back to binary.
  6. Reboot the iPhone and check the Phone application to see the new string.

International Caller ID

The iPhone supports 7 digits to handle local and international phone number formats. It cuts of from the end and tries to match the phone number with the contacts. The length differs from country to country.

  1. Download the patched AppSupport binary that match the length of the phone number, AppSupport.
  2. Upload AppSupport to /System/Library/Frameworks/Appsupport.framework/
  3. Reboot the phone.

Voicemail Button

The voicemail button in the Phone application will not be functional on a non-AT&T network. It's possible to re-program the button to dial the correct voicemail phone number.

  1. Open the Phone application and select the Keypad.
  2. Enter the code *5005*86*...# where the three dots ('...') indicates the voicemail phone number for the operator.
  3. For Telenor in Norway, this sequence is used *5005*86*+4791509001#.
  4. Try to hit the voicemail button and it will connect to the voicemail service.

Updating to v1.1.1

There are many interesting fixes and a few new features in the iPhone v1.1.1 firmware update. But applying the update will re-jail and flash the modem baseband. A regular update does not remove settings and all the media files are preserved, third-party applications is wiped. Some applications may need updates to function on v1.1.1.

Updating

  1. Open iTunes and keep it open during the next steps. This is to trick the re-jailing.
  2. Remotely SSH into the iPhone (using putty or terminal) and change directory (cd) to /var/root/
  3. Rename the 'Media'-directory to 'Media-old' using 'mv Media Media-old' and issue this command to create a symbol link, 'ln -s / Media '.
  4. Another prerequisite is a copy of 'lockdownd' from v1.0.2, 'cp /usr/libexec/lockdownd /var/root/lockdown.1.0.2' (/var/root/ is not erased). It's used to generate a valid activation certificate on v1.1.1.
  5. Now, in iTunes click the 'Update'-button to start the update process. When it's finished the phone should show a activation screen and the slider should say 'Slide to emergency'. Everything is OK.

Enabling read/write

  1. Download the JailbreakWindows_v1.1.1.zip package and extract it.
  2. Open a command-prompt and change directory to the JailbreakWindows directory and execute the iphuc-jailbreak.exe application.
  3. To make sure the iPhone is jailbroken, issue 'ls' and look for 'Applications'. It it shows up, everything is good.
  4. To enable read/write (rw), the /etc/fstab file has to be replaced. A special putjailbreak-command overwrites the correct sector in the flash to update the file. In ipuch-jailbreak.exe, issue 'putjailbreak rdisk0s1 /dev/rdisk0s1'.
  5. Reboot the iPhone to enable read/write filesystem.

Install SSH

This step assumes a working Wifi configuration has been set up before the v1.1.1 upgrade. Else you need a open Wifi network and/or do the activation and contacts hack to enable a Wifi network connection to be able to connect via SSH.

  1. In the JailbreakWindows folder, delete the com.apple.update.plist.orig, com.apple.update.plist.orig, update and update.org files. Else the renaming of the original files from the iPhone will fail.
  2. Open a commd-prompt and execut the sshify-windows.bat batch file. Follow the simple instructions.
  3. When phase 4 is finished, the last 'fileref' should return 0. That means a file failed to be copied.
  4. Execute iphoneinterface.exe and issue this command to upload the last com.apple.update.plist, 'putfile /System/Library/LaunchDaemons/com.apple.update.plist'.
  5. Reboot the iPhone once more to enable the dropbear SSH server.
  6. Connect to the SSH server (putty or terminal) and use the username root and the new password alpine. The dropbear server is not SCP compatible.

Install Installer.app

  1. Follow the same procedure when installing SSH above.
  2. Open a command-prompt and execute the installapps.bat batch script.
  3. Installer.app can be executed before activation by doing the activation and contacts hack.

Activating

  1. Open a command-prompt and change directory to the JailbreakWindows directory.
  2. Execut iphoneinterface.exe and issue this command to install the public certificate to make the activation work, ' putfile /System/Library/Lockdown/iPhoneActivation.pem'
  3. SSH remotely and make a copy of lockdownd for v1.1.1, 'cp /usr/libexec/lockdownd /var/root/lockdownd.1.1.1'.
  4. Copy the old lockdownd from v1.0.2 over the current lockdownd, 'cp /var/root/lockdown.1.0.2 /usr/libexec/lockdownd'.
  5. Restart the lockdownd daemon, 'ps xa', find the PID, 'kill 21'. It should automatically restart.
  6. Do the same for the afcd daemon, 'ps xa', 'kill 43'.
  7. Note that iphoneinterface.exe will fail to work if the iPhone is rebooted with lockdownd from v1.0.2, afc requires v1.1.1. Copy over v1.1.1 before rebooting.
  8. Download the iAsign package for Mac and then the Windows (Win32) update. Put iAsign.exe in the 'bin'-folder.
  9. Open a command-prompt and change directory to the iAsign folder.
  10. Run 'iAsign --automatic iPhoneActivation_private.pem' to generate a new activated certificate on the iPhone. A message should show stating the iPhone is activated.
  11. Restore the lockdownd from v1.1.1, 'cp /var/root/lockdown.1.1.1 /usr/libexec/lockdownd'.
  12. Kill lockdownd once more and it should, 'ps xa', and 'kill <pid>'.
  13. The iPhone screen should now have a 'Slide to unlock'-slide and the phone is successfully activated.

Patch Springboard

The new Springboard has to be patched to behave as before.

  1. Make springpatch executable, 'chmot 755 /usr/bin/springpatch'.
  2. Execute the patch, '/usr/bin/springpatch'.

Fix Previous Installer.app

If Installer.app was installed before the update, all the preferences files are invalid as the applications are wiped.

  1. Remove the preferences for Installer.app, 'rm -r /private/var/root/Library/Installer'.
  2. Make the new Installer.app executable, 'chmod 755 /Applications/Installer.app/Installer'.
  3. Reboot to load the changes.

References