Babar Haq

Saturday, March 18, 2006

Extraction of Nokia nfb file

I recently lost my six months old nokia 6230i. 29th birthday gift from my wife. Besides the emotional attachment, I had a huge phone book with almost 300 entries in it. I am a sort of person who relies heavily on the phone book. Luckily a week before I lost it, I started using PC Nokia suite provided with the mobile. While getting a hang of it, I took a back up of my phone book. The back up created a file with extension of .nfb.

I didnt know how to extract the phone book from the .nfb file. Googling took me to From this website I downloaded some python scripts

The zip file contains three python files namely:, and

After struggling with the files for some time, I was able to extract my phone book from the backup nfb file on linux.

This is how I did it:
#./ -xv nameofnfbfile.nfb /PHONEBOOK > resultant_file

The resultant_file was perfectly viewable using the "cat" command but if opened using some text editor it would show a lot of "#" characters. These "#"'s were between each character. I resolved it by simply replacing all "#" with nothing (put nothing in the replace field).

The file looked something like this before

2#0#8# #0#2#6#0#6#8#1#8#1##0#1#8#3#9##_#C#O

Using openoffice's find and replace option I transformed it

200 PIT_CONTACT 208 +92514431878 202 Sufi 210 03037778319
200 PIT_CONTACT 202 Abbas Butt Com 208 03008555188

Each line seems to specify one entry in the contact book. Each entry has different fileds and its values. Each field vaule is preeceded by a three digit code representing the type of field. For example the name field is preceeded by 202.

Using this file, I could temporary look up contacts in my lost mobiles phonebook. Last month I bought a new nokia mobile 6020. This is a scaled down version of 6230i. I thought I would be able to directly restore my phonebook (nfb) to my new mobile. However I was yet to face more challanges :)

Whenever I tried to retrieve the phonebook using nokia PC suite, it exited giving some error. Again google came in handy. I found that Nokia PC suite provides two options for taking backups. One option creates nfb file type and the other nfc file type. Obviously nfb doesent work across different phones. Now Nokia has updated its PC suite a so that when you take a backup it creates both nfb and nfc files.

Therefore I opened the phone book file using vim (you could also use ultraedit). Using vertical text editing, I formated the file so that I was left with only two comma seperated fields. The file started looking something like this

Abbas Butt Com,03008555188

I named the file with a .csv extension and imported it into Outlook express address book. I chose the first field to represent name and the second to be telephone number. After I got this done I syncronised my mob with Outlook express address book. Its an option which is self explanatory in Nokia PC Suite.

Wednesday, March 08, 2006


A lot of open source web based applications use mysql as a backend database. Almsot all of them require to create a mysql database and a mysql user who has full access to the database. Following is a quick tutorial on doing all that. This assumes that the db and application are on the same machine.

1) Connect to mysql as root user and create database
#mysqladmin -h localhost -u root -ppassword create databasename
Replace password by mysql root users password. Replace the databasename with the name you want to give your database.

2) Add a mysql user

Connect to mysql as root user
#mysql -h localhost -u root -ppassword
Replace password by mysql root users password.

mysql> USE mysql;
Switch to mysql database which holds the user information.

mysql> INSERT INTO user (Host, User, Password, Select_priv) VALUES ('localhost', 'username', password('password'), 'Y');
This adds the desired user name and allow him to connect from localhost. Replace the username and password in italic to the actual user name and password you want to assign.

databasename.* TO username;
Give full access on databasename to username.

Required everytime GRANT command is used.