Apple iPhone: Can’t Receive SMS Problem

October 4th, 2007

Yes, there are some lemon iPhones that don’t allow you to receive SMS messages. Yes, you can’t receive SMS message in your iPhone. After a bit of playing around with the unit, it really feels like BETA quality hardware. Lots of little issues left and right. Oh well. Maybe their new version will be better? iPhone 2.0? Anyway, here is the procedure for fixing this issue. Fair warning: Make sure you know what you are doing and ensure that your units are fully charged. You don’t want to interrupt the process in a middle of an update.

  1. Grab latest 1.0.2 (latest safe firmware) firmware update. Extract the bbupdater, ICE03.14.08_G.fls and ICE03.14.08_G.eep files. You can do this by unzipping the firmware file then mounting it in a MacOSX or Linux box. If you are using Windows then I suggest you Google for the files there are links lying around. I just don’t want to link to them myself. When you have them upload them to the iPhone. I suggest you use iBrickr or SCP them to the iPhone. Create a directory under /Applications/relock and store the files there. Putting executable files in the /var/root directory won’t allow you to run them.
  2. Reflash baseband to its original state. Ok here is the challenging part. Make sure you have enough battery life, good network connectivity and that you don’t get interrupted. Then, login to the iPhone via SSH or use MobileTerminal.app on the phone. Type the following commands:
  3. cd /Applications/relock
    launchctl unload -w /System/Library/LaunchDaemons/com.apple.CommCenter.plist
    ./bbupdater -f ICE03.14.08_G.fls -e ICE03.14.08_G.eep
    launchctl load -w /System/Library/LaunchDaemons/com.apple.CommCenter.plist
    
  4. SIM Unlock again. At this point, you have a fresh baseband firmware. Of course, this baseband firmware is still SIM locked to AT&T. Therefore, you will have to do the entire SIM unlock process again. I suggest you use the anySIM.app application as it works pretty well already. Or you can use the procedures that I have collected and documented before here.

So if you cannot receive SMS message in your phone. Try this procedure out. Enjoy!

Darwin 6.2 on VMWare on Fedora Core 7

September 23rd, 2007

Should have been a straight forward process but quirks in the Darwin installer added around one (1) hour of twiddling to an otherwise simple process. Here is what I had to do to get it all working.

  1. Download Darwin OSX install image. You can do this by visiting the Apple Open Source website that contains a nicely packaged ISO for your installation convenience.
  2. Make sure your copy of VMWare Server is working. You can download VMWare server for free to the VMWare website. Fortunately, they have fixed the kernel bugs already that prevent VMWare from properly building before.
  3. Create a new Virtual Machine. Ok the normally procedure would be to create a new VM. Select “Others” as the operating system. Specify the amount of RAM you would like to assign that VM (I choose 256MB). Create a new IDE hard disk to install your Darwin files (take note it SHOULD BE IDE and not SCSI). Mount the ISO image under the CDROM device. Normally, this should be ok. But, it will get stuck with the error “still waiting for root device”.
  4. Shuffle around IDE devices. You will notice that the CDROM is mounted as the IDE (1:0) device. Your hard disk is mounted as IDE (0:0). You should move the CDROM to IDE (0:1) instead.

The rest of the installation process should proceed by answering the questions prompted by the install. I allowed the installer to specify the partitioning. The system will then proceed to install the files. After which it will prompt you for a reboot.

Here are some additional things you might want to do to get a decently working system.

  • Setting your hostname. This can be done by editing the /etc/hostconfig file and filling in the hostname field. You can also configure your default router here. However, I plan to use DHCP so this should be moot.
  • Configuring networking. Edit the /etc/iftab file. Replace the line under the en0 network device from AUTOMATIC to DHCP. This is because I plan to use DHCP.
  • Running the SSH daemon. Edit the /etc/hostconfig file. You can see an option for SSHSERVER there.

Still more things you can do here. When in doubt this is a BSD system so your BSD knowledge should come in handily.

Software Freedom Day 2007

September 15th, 2007

I just came from the Software Freedom Day 2007 celebration here at the National Computer Center (NCC). This celebration was organized by the Bluepoint Foundation. Here is a copy of my presentation materials on Open Source in Mobility. In this presentation, I gave an overview of the current mobile, open source and Internet ecosystems and some opportunities in this space. Of course, with particular emphasis on open source.

Conquering the Apple iPhone II - Tested on Globe and Smart Postpaid

September 12th, 2007

This is the next phase of my iPhone cracking exercise. No need for turbosims, supersims, soldering and paying. Yes, its free. Thanks to the iPhone Dev Wiki (link widtheld) folks. The first installment can be found here. However, this guide should be standalone since I am flashing the phone and restoring to factory settings.

Here is a picture of it working! Sorry I could not get a better picture.




iPhone with a Globe Telecoms Post-paid SIM




iPhone with a Smart Telecommunications Post-paid SIM

  1. Update iPhone to 1.0.2 (nothing newer). This is required because a particular baseband firmware and modem is required. This update will fail if you already previously cracked/activated the iPhone. This may take times as the 1.0.2 update is 91MB.
  2. Restore iPhone. This sets the iPhone back to its factory settings. This is only done if necessary. You can do this via iTunes.
  3. Jailbreak and Activate the iPhone.. This can be done using the usual methods (documented in my previous blog) or using a new video found here. The ibricker method is a lot easier than the previously documented methods. The user interface is also nicer. Then proceed to install PXL. Then install the “Installer” Application.
  4. Reload Baseband Firmware. I followed the instructions from this site. It was one of the cleanest documents out there.
  5. Replace lockdownd. This is what you do last. With iBrickr of course.

And … It works on Globe Postpaid and Smart Postpaid. You guys enjoy. Yahoo!

PS. I am not posting a copy of the files you need to do the hack as you can get them thru the websites presented in this blog entry. Again, DO THIS AT YOUR OWN RISK. Please make sure you absolutely know what you are doing before your try this out. If you brick your iPhone you can try the factory restore method.

Parallel Computing: Quick Guide to Configuring NFS

September 8th, 2007

Providing common shared storage is an important part of parallel computing. Being able to share files between compute nodes in a parallel cluster is key to getting a parallel job done. This is a follow-up article on configuring OpenMPI for Parallel Computing. You need to do this to get other nodes to play in your cluster. So, let’s get started.

For the Server:

  1. Install necessary packages. This is to install the NFS packages and its dependencies such as portmapper.
    yum install nfs-utils nfs-utils-lib portmap
    
  2. Install Dependencies. Ensure NFS-related services are started and start-up by default. These assume the RedHat-way of doing things. This will vary depending on your Linux distribution.
    /sbin/chkconfig portmap on
    /sbin/chkconfig nfs on
    /sbin/chkconfig nfslock on
    /sbin/service portmap start
    /sbin/service nfs start
    /sbin/service nfslock start
    
  3. Share Drive. Configure the directory or drive you want to share and edit the /etc/exports file. Then inform NFS that you have created a shared drive.
    mkdir /share
    cat "/share *(rw, no_root_squash,sync)" >> /etc/exports
    exportfs -ra
    
  4. Configure your security. This involves setting your hosts.allow and hosts.deny files. But, I prefer just setting the firewall. So edit your /etc/sysconfig/iptables file and add the following lines.
    -A RH-Firewall-1-INPUT -p tcp -m tcp -s 10.11.81.0/24 --dport 2049 -j ACCEPT
    -A RH-Firewall-1-INPUT -p udp -m udp -s 10.11.81.0/24 --dport 2049 -j ACCEPT
    -A RH-Firewall-1-INPUT -p tcp -m tcp -s 10.11.81.0/24 --dport 111 -j ACCEPT
    -A RH-Firewall-1-INPUT -p udp -m udp -s 10.11.81.0/24 --dport 111 -j ACCEPT
    

For the Client:

  1. Install necessary packages. This is to install the NFS packages and its dependencies such as portmapper.
    yum install nfs-utils nfs-utils-lib portmap
    
  2. Install Dependencies. Ensure NFS-related services are started and start-up by default. These assume the RedHat-way of doing things. This will vary depending on your Linux distribution.
    /sbin/chkconfig portmap on
    /sbin/chkconfig nfslock on
    /sbin/service portmap start
    /sbin/service nfslock start
    
  3. Configure Filesystem Table. Edit your system’s fstab to ensure that this directory is mounted immediately on boot. Just as a warning make sure your uids across the systems are uniform.
    10.11.81.49:/share      /share       nfs        rw,exec       0 0
    
  4. Mount drive. You can either reboot your system or type the following command:
    mount /share
    

That is it. Pretty simple right? Now you have a shared drive amongst the different machines in your parallel cluster to run your parallel computing programs.

Pinoy Top Blogs Sold for an Undisclosed Sum

September 7th, 2007

We are not quite used to seeing Filipino entrepreneurs sell their creations on this new dotCom market. So, I believe this one makes it news worthy. Here is a link from his blog describing the sale.

After several months of negotiations, I have finally agreed to sell the Pinoy Top Blogs project. It’s a decision that was very hard to make but I figured that the future of the project will be more secured with the new owners.

Several thins prompted me to move into making this decision and I’d like to share that with all bloggers who are involved and been part of the project in the last 2 years.

The sale was to a group called Enthropia which is behind a number of web-related ventures. I don’t really know the new them but I hope they take good care of this piece of Internet real estate. Congratulations Abe!

Parallel Computing and Random Numbers

August 31st, 2007

When writing programs that work together on different machines. Programmers encounter numerous types of problems ranging from endianess, file storage format, executable formats and many others. One possible problem is generating random numbers.

Random number generators are implemented in many different ways. I will not aim to discuss the details of generating random numbers here. Just a few solutions to some common problems.

Simple C Program for generating random numbers:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[])
{
        double rn;
        int i;
        time_t mytime;

        srand (time (&mytime));

        for (i=0;i<10;i++) {
                rn = 1.0 * (rand() / (RAND_MAX + 1.0));
                printf("Process 0, random number %d: %.14fn", i, rn);
        }

        return 0;
}

An obvious parallel program would look like this:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <mpi.h>

int main(int argc, char *argv[])
{
        time_t mytime;
        double rn;
        int i, myid, nprocs;

        /* initialize MPI */
        MPI_Init(&argc, &argv);
        MPI_Comm_rank(MPI_COMM_WORLD, &myid);
        MPI_Comm_size(MPI_COMM_WORLD, &nprocs);

        srand(time(&mytime));

        for (i=0;i<10;i++) {
                rn = 1.0 * (rand() / (RAND_MAX + 1.0));
                printf("Process %d, random number %d: %.14fn", myid, i+1, rn);
        }

        MPI_Finalize();
        return 0;
}

What is wrong with the picture? Well, if you look at the output since the random number generators in each process is seeded with more or less the same seed then … they generate the same sequence of random numbers! Oh no! Then if all the numbers are taken together … they are not random!

So what should we do?

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <mpi.h>

int main(int argc, char *argv[])
{
        time_t mytime;
        double rn;
        int i, myid, nprocs;

        /* initialize MPI */
        MPI_Init(&argc, &argv);
        MPI_Comm_rank(MPI_COMM_WORLD, &myid);
        MPI_Comm_size(MPI_COMM_WORLD, &nprocs);

        srand(time(&mytime) * myid);

        for (i=0;i<10;i++) {
                rn = 1.0 * (rand() / (RAND_MAX + 1.0));
                printf("Process %d, random number %d: %.14fn", myid, i+1, rn);
        }

        MPI_Finalize();
        return 0;
}

The simplest solution is the code above. Notice, we just made the seed vary by using the rank of the process. The output of this solution seems random. But No! Each process generates a set of random numbers that are distributed in the same way. The distribution is not common for the entire communicator! This has dire implications when using these random numbers for monte carlo computations and others that need properly distributed random numbers.

Fortunately, a bunch of generous and smart folks have written a library that allows you to generate random numbers in parallel. The library is pretty powerful that it allows you to tune the parameters of your pseudo-random number generator. This library is called SPRNG.

SPRNG 1.0 provides the user the various SPRNG random number generators each in its own library. For most users this is acceptable, as one rarely uses more than one type of generator in a single program. However, if the user desires this added flexibility, SPRNG 2.0 provides it. In all other respects, SPRNG 1.0 and SPRNG 2.0 are identical. Both versions only uses the GNU Multi Precision (GMP) package for one of their generators. SPRNG 3.0 uses GMP for all generators. SPRNG 4.0 is a C++ version with the GMP package removed. It is not backwards compatible with any of the previous SPRNG versions, except for its default FORTRAN interface.

You can download a package with a pre-built SPRNG 3.0 library and some sample code. It comes with a Makefile for your convenience. You can download the code from here.

Please make sure you have GMP and its development libraries installed before building this code. I wrote a feature on GMP here. In a Fedora system, you can install GMP with the following commands:

yum install gmp gmp-devel

The sample code can be found here:

#include <stdio.h>
#include <mpi.h>
#include "sprng.h"

#define SIMPLE_SPRNG

#define SEED 985456376

int main(int argc, char *argv[])
{
	int *stream;
	double rn;
	int i, myid, nprocs;

	/* initialize MPI */
	MPI_Init(&argc, &argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &myid);
	MPI_Comm_size(MPI_COMM_WORLD, &nprocs);

	/**
	 * initial PRNG streams.
	 * 1 - 48 bit LCRNG.
	 * 2 - 64 bit LCRNG.
	 * the steam id is the same as the rank and the
	 * number of streams is the same as the number of
	 * processes.
	**/
	stream = init_sprng(2, myid, nprocs, SEED, SPRNG_DEFAULT);

	for (i=0;i<3;i++) {
		rn = sprng(stream);
		printf("Process %d, random number %d: %.14fn", myid, i+1, rn);
	}

	/* free random number stream */
	free_sprng(stream);

	MPI_Finalize();
	return 0;
}

See it was not that hard. Now you can write your Monte Carlo simulator. Good luck!

PS. I left a little bug in the sample code above. It will compile and run but I left something that is not normally a best practice when using pseudo-random number generators.

Computer Math with Big Numbers

August 27th, 2007

As programmers, we are used to dealing with lots and lots of numbers. Most of the time these numbers are quite small and manageable. Something they get really large and ugly. We create all sorts of programs to deal with these giants numbers collectively know as BIGNUM. Why do we need them? There are extreme cases where our standard data types (int and float) do not quite cut it anymore. These data types have fixed precision and therefore do not have the flexibility of dealing with BIGNUMs.

However, there is nothing to fear. Most programming languages already come with libraries that help programmers deal with these BIGNUMs. I would like to talk about one know as GMP or GNU MP.

GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. There is no practical limit to the precision except the ones implied by the available memory in the machine GMP runs on. GMP has a rich set of functions, and the functions have a regular interface.

This short blog post will show one how to quickly get down and dirty using GMP.

  1. Install GMP. Fortunately, most Linux systems come with GMP installed. However, if you are one of the unfortunate few to not have it installed try doing following (for Fedora systems only).
    yum install gmp gmp-devel
    

    These commands will install GMP and its dependencies on your system.

  2. Write a Test Program. Here is a short test program you can use to test BIGNUM.
    #include <gmp.h>
    
    int main () {
            mpz_t sum, x, y;
    
            mpz_init (x);
            mpz_set_str (x, "199999999999999999999999", 0);
            mpz_init (y);
            mpz_set_str (y, "1", 0);
            mpz_init (sum);
    
            mpz_add (sum, x, y);
            gmp_printf ("GMP X + Y = %Zd.n", sum);
    
            return 0;
    }
    

    In a nutshell, this program initializes three (3) GMP Integers (MPZ). X is loaded with a really large number and Y loaded with a smaller one. The sum of both X and Y are stored in the variable sum. The value of the variable sum is then displayed on the screen. More later on.

  3. Compile and Build Program. You can them execute the following command to compile and build this test program in one go.
    gcc -o huge huge.c -lgmp
    

    Take note that you have to explicitly link this program with the GMP libraries that are installed in your system.

Then you can run the program in the usual way. Now, it should be easy to write programs that require arbitrary precision arithmetic. You might ask … are these computations efficient? Lets find out.

Here is a test program using regular C arithmetic functions defined in math.h.

#include <stdio.h>
#include <math.h>

int main ()
{
        double x,y;

        x = 999999999;
        y = 9;

        printf ("X^Y=%E.n", pow(x,y));

        return;
}

Here is a similar program using GMP instead.

#include <gmp.h>

int main ()
{
        mpf_t x, pow;

        mpf_init (x);
        mpf_init (pow);
        mpf_set_str (x, "999999999", 0);

        mpf_pow_ui (pow, x, 9);

        gmp_printf ("X^Y=%FE.n", pow);

        return;
}

Then we compile and run both program. We use the command time to determine how long each program takes to complete. Here are the results.


With GMP Without GMP
Results 1.0e81 1.0e81
Time 0.002s 0.002s

Not much difference right. That is some numbers that fit into regular C arithmetic. Nothing special here. Now check this program out. It allows me to specify the number value of X.

#include <gmp.h>

int main (int argc, char *argv[])
{

        if (argc < 2) {
                gmp_printf ("Error: Insufficient argumentsn");
                return 0;
        }

        mpf_t x, pow;

        mpf_init (x);
        mpf_init (pow);
        mpf_set_str (x, argv[1], 0);

        mpf_pow_ui (pow, x, 9);

        gmp_printf ("X^Y=%FE.n", pow);

        return 0;
}

Here are the results:


X Time to compute X^9
9999999999 0.002s
20 9s 0.002s
30 9s 0.002s
40 9s 0.002s
50 9s 0.002s
60 9s 0.002s
70 9s 0.002s
80 9s 0.002s
90 9s 0.002s
100 9s 0.002s

How come the time it takes to compute a consequently bigger number takes just the same amount of time as a smaller number? This is probably because raising a number (no matter how big) to a single digit number is not a really computationally expensive and it is linearly complex. In English, our computers are still fast enough to handle numbers this big. The only limitation is the data structure we choose to store our numbers.

With GMP, we can definitely store more.

Pengiuns Can Fly: Panasonic Putting Linux in Every Seat

August 27th, 2007

Here is an interesting story about Singapore Air loading up each in flight seat with a copy of RedHat Linux. This is one of sure signs that Linux has really grown up. … or many become a kid again?

Flying in economy class doesn’t have to be a miserable experience. To make flying more enjoyable for its passengers, Singapore Airlines Ltd. is adding bigger screens, more in-flight movies and a PC, running Red Hat Inc.’s distribution of the Linux operating system, in every seat on its newest planes. …

The latest version of KrisWorld is based on Panasonic Avionics Corp.’s eX2 in-flight entertainment system and was jointly developed by the two companies. The system consists of a central Linux server that connects to a network of PCs installed in every seat on the aircraft. The KrisWorld software offers an improved user interface and each economy-class seat is fitted with a 10.6-inch LCD (liquid crystal display) screen that offers resolution of 1,280 pixels by 768 pixels.

For those of you who are wondering, StarOffice? Airline systems tend to use a pretty old but really stable version of any given platform. This is because the entire aviation industry has this “only tried and tested will do” mentality.

Of course, the opportunity to have a full computer on each seat is still a really big help. Maybe this will encourage me to ride Singapore Airlines the next time I travel.

A Big New Security Threat: The Apple iPhone

August 19th, 2007

After playing with the Apple iPhone for a bit, I have come to appreciate Apple’s effort in designing this next generation device. All the development towards unleashing the power of the iPhone has left the world with about 200,000 pretty powerful mobile computers (I believe these devices are more powerful than just PDAs and phones).

With great power comes … potential security threats. The mobile phone industry has largely been immune to malware due to the fact that their mobile phone operating systems are either very restricted or very security. Another possibility is that malware authors are not quite interested in writing malware for these devices because of the small number of devices out their in the market with a particular system. A potential malware author would have to crack all of these various systems. It just takes too much work for so little exposure.

However, the Apple iPhone has the potential to sell like iPods. When the numbers get this big, the crackers start paying interest. Here is how I see it happening with the iPhone:

  1. Getting Entry. Regular Virii, Trojans and Worms infect millions of unsuspecting computers. These forms of malware can detect the presence of an iPhone.
  2. Breaking in. Once an iPhone is detect, the next step will be to jailbreak the iPhone. There are lots of way to do this already. All the tools are also publicly available.
  3. Putting a Back Door. Next step would be to install an SSH server on that iPhone and create a compromised backdoor account. Also other necessary software can be installed at this point. Since, most people won’t bother doing this themselves, the attacker can put this in un-noticed.
  4. Schedule an awakening job. It would be bad for a piece of malware to be too noisy because it would destroy the ecosystem it needs to survive. The malware can be forced to schedule a crack job much later instead it will focus on spreading far and wide.
  5. Join the Collective Mind. Botnet software can then be installed on each infected iPhone. The rest is history.

A simpler way would be to infect an application distributed via in an Installer.app package. Another option would be to entire via a Safari vulnerability. There are even more possibilities. Some where somebody is already writing a proof of concept or the real thing. Finally, mobile security needs more attention.

So whose fault is it? Nobody in particular. Well, things like these come with success.