Hack a Mobile Phone with Linux and Python

A mobile phone is a cool gadget to play with, especially when I can run my favourite programming language (no prize for guessing what it is!) on it! That was the logic which made me purchase a Nokia Series 60 smartphone, the N-Gage QD. This article describes a few experiments I did with the mobile - like setting up Bluetooth communication links, writing Python/C code and emulating serial ports.
Bluetooth on Linux

Bluetooth is a short distance wireless communication standard. It is commonly used to facilitate data transfer between PC's and cell phones/PDA's without the hassle of `wired' connections. The hardware which provides Bluetooth connectivity on the PC is a small device called a `USB-Bluetooth dongle' which you can plug onto a spare USB port of your machine. I approached the local electronics dealer asking him for such a device and got one which didn't even have the manufacturer's name printed on it. The driver CD which came with it of course contained only Windows software. Deciding to try my luck, I plugged the device on and booted my system running Fedora Core 3 - bluetooth service was started manually by executing:

sh /etc/init.d/bluetooth start


Here is the output I obtained when the command `hciconfig' ( which is similar to the `ifconfig' command used to configure TCP/IP network interfaces) was executed:

hci0: Type: USB
BD Address: 00:11:B1:07:A2:B5 ACL MTU: 192:8 SCO MTU: 64:8
UP RUNNING PSCAN ISCAN
RX bytes:378 acl:0 sco:0 events:16 errors:0
TX bytes:309 acl:0 sco:0 commands:16 errors:0


My no-name USB-Bluetooth dongle has been detected and configured properly! The number 00:11:B1:07:A2:B5 is the Bluetooth address of the device.
Detecting the mobile

The next step is to check whether Linux is able to sense the proximity of the mobile. If your phone has bluetooth disabled, enable it and run the following command (on the Linux machine):

hcitool scan


Here is the output obtained on my machine:

Scanning ...
00:0E:6D:9A:57:48 Dijkstra


The `BlueZ' protocol stack running on my GNU/Linux box has `discovered' the Nokia N-Gage sitting nearby and printed its Bluetooth address as well the name which was assigned to it, `Dijkstra'.
Pairing the mobile

For security reasons, some interactions with the mobile require that the device is `paired' with the one it is interacting with. First, store a number (4 or more digits) in the file /etc/bluetooth/pin (say 12345). Stop and restart the bluetooth service by doing:

sh /etc/init.d/bluetooth stop
sh /etc/init.d/bluetooth start


Now initiate a `pairing' action on the mobile (the phone manual will tell you how this is done). The software on the phone will detect the presence of the Bluetooth-enabled Linux machine and ask for a code - you should enter the very same number which you have stored in /etc/bluetooth/pin on the PC - the pairing process will succeed.
Transferring files

Files can be transferred to/from the Linux machine using a high level protocol called OBEX (standing for OBjectEXchange, originally designed for Infrared links). First, you have to find out whether the mobile supports OBEX based message transfer. Try running the following command on the Linux machine (the number is the bluetooth address of the phone):

sdptool browse 00:0E:6D:9A:57:48


You might get voluminous output - here is part of what I got:

Service Description: OBEX Object Push
Service RecHandle: 0x10005
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 9
"OBEX" (0x0008)


OBEX is built on top a lower-level protocol called RFCOMM. The `Object Push' service uses RFCOMM `channel' 9. Let's try to upload a file to the phone; run the following command on the Linux machine:

obex_push 9 00:0e:6d:9a:57:48 a.txt


The phone will respond by asking you whether to accept the message coming over the bluetooth link. The same command, invoked without any option, can be used to receive files sent from the mobile over the bluetooth link (read the corresponding `man' page for more details).
Installing Python

Nokia has recently done a port of Python to the `Series 60' smartphones running the Symbian operating system. The Python interpreter as well as a few important modules are packaged into a single .sis file (somewhat like the Linux RPM file) which can be obtained from http://www.forum.nokia.com/main/0,,034-821,00.html. The file to be installed is named PythonForSeries60_pre_SDK20.SIS. The first step is to transfer this file to the mobile via obex_push. Trying to open the file on the mobile will result in the Nokia installer program running - it will ask you whether to install Python on the limited amount of memory which the phone has or to an additional MMC card (if one is present). Once the installation is over, you will see a not-so-cute Python logo on the main menu of the phone - Figure 1 is a screenshot I took of the main menu.





Running the Python `Hello, World'

You can write Python scripts on the Linux machine and upload them to the mobile with `obex_push'. If you try to open these scripts (on the mobile), the `applications manager' will ask you whether to install the files as Python scripts or not. Once installed as scripts, you can execute them by following the instructions displayed on the screen when you open the `Python' application from the main menu.



The output obtained by installing and running the following script on the mobile:

import appuifw # The application UI framework
appuifw.app.title = u'Cool Python'
appuifw.note(u'OK', 'info')


Socket programming

Application programs running on both the phone as well as the Linux machine interface with the Bluetooth protocol stack via the socket API. Listing 1 shows a simple client program running on the mobile which connects with a server running on the Linux machine and sends it a message; the server code is shown in Listing 2.

The Python client program running on the mobile opens a Bluetooth socket and connects to the PC whose device address is specified in the variable `ATHLON'. Once the connection is established, it simply sends a string `Hello, world'.

The server program running on the PC opens a Bluetooth stream socket, binds it to RFCOMM channel 4 and calls `accept' - the server is now blocked waiting for a connection request to arrive from the client. Once the request arrives, the server comes out of the accept, returning a `connected' socket calling `recv' on which will result in the server getting the string which the client had transmitted.

The `bacpy' function in the server program is defined as an inline function in one of the header files being included - so you need not link in any extra library to get the executable. But if you are using any of the other Bluetooth utility functions like `ba2str', you have to link /usr/lib/libbluetooth.so to your code.
Using PyBlueZ

There is an interesting Python interface to the Bluetooth library in Linux called `PyBlueZ' available for download from http://org.csail.mit.edu/pybluez. It simplifies the process of writing bluetooth socket programs on the Linux machine. Listing 3 shows the Python implementation of the server program described in the previous section.
Emulating serial links

Programs like `minicom' are used to talk to devices connected over a serial link (say a modem). There is a neat software trick to present a `serial-port-like' view of a bluetooth link so that programs like `minicom' can manipulate the connection effortlessly. Let's try it out.

First, edit /etc/bluetooth/rfcomm.conf so that it looks like the following:

rfcomm0 {
bind no;
device 00:0e:6d:9a:57:48;
channel 1;
comment "Example Bluetooth device";
}


After stopping and restarting the bluetooth service, run the following command:

rfcomm bind /dev/rfcomm0


You should see a file called `rfcomm0' under /dev after executing the above command. Now, you can set up `minicom' by running:

minicom -m -s


The only thing to do is to set the name of the device to connect to as /dev/rfcomm0. Save the new configuration as the default configuration and invoke:

minicom -m


Minicom is now ready to talk to your phone! Type in `AT' and the program will respond with an `OK'. Say you wish to make your phone dial a number. Just type:

atdt 1234567;


There are many other AT commands you can experiment with; try googling for say `mobile phone AT commands' or something of that sort!

After you have finished with your virtual serial port manipulations, you should run:

rfcomm release /dev/rfcomm0


to `release' the serial-bluetooth link.
Python over a Bluetooth console

Once you get the serial port emulation working, there is another interesting hack to explore. The Nokia Python distribution comes with a program called `btconsole.py'. On one console of your Linux machine, run the command:

rfcomm listen /dev/rfcomm0


Now run `btconsole.py' on the phone. You will see that after a few seconds, `rfcomm' will respond with a `connected' message. Once you get this message, take another console and run:

minicom -m


What do you see on the screen? A Python interactive interpreter prompt! You can now type in Python code snippets and execute them on the phone on-the-fly! Isn't that cool?
Parting Thought

I was curious to know how Microsoft's Windows XP operating system, famous for its `ease of use', would compare with Linux when it comes to interacting with my NGage QD. I installed the Windows driver for my no-name usb-bluetooth dongle and tried to get the Nokia PC suite up and running on an XP machine - maybe it's because I am far more experienced in GNU/Linux than on MS operating systems, but I found the XP experience far less `friendly' than MS would care to admit. I believe that most of the `user friendliness' of the Microsoft operating system comes from hardware vendors and application developers tightly integrating their products with the platform rather than any inherent quality of the OS as such.
References

For a general introduction to Bluetooth technology, see http://www.dell.com/downloads/global/vectors/2003_bluetooth.pdf. An interesting paper on Bluetooth security is available at http://www.niksula.cs.hut.fi/~jiitv/bluesec.html.

http://www.holtmann.org/ has plenty of information regarding Bluetooth and Linux; I found the document `Bluetooth Programming for Linux' (http://www.holtmann.org/papers/bluetooth/wtc2003_slides.pdf) very informative.

Lots of information about Python on series 60 mobiles is available at http://www.postneo.com/postwiki/moin.cgi/PythonForSeries60/. ObexFTP seems to be an interesting tool - you can get it from http://triq.net/obex/. There are some documents floating on the net which describe how you can do an NFS mount of your phone's file system - try a google.

31 comments:

Anonymous said...

I've been exploring for a little for any high-quality articles or blog posts on this kind of area . Exploring in Yahoo I at last stumbled upon this site. Studying this information So i'm happy to show that I have a very just right uncanny feeling I came upon exactly what I
needed. I most surely will make sure to don?

t forget this website and give it a glance on a relentless basis.
my web page :: how to start a business with no money

Anonymous said...

Everything is very open with a clear description of the issues.
It was really informative. Your website is useful. Thank you for sharing!
Visit my page lanautica.com

Anonymous said...

Heya! I realize this is somewhat off-topic but I needed to ask.
Does building a well-established website such as yours require a large amount of work?

I am brand new to operating a blog but I do write in
my journal every day. I'd like to start a blog so I will be able to share my personal experience and thoughts online. Please let me know if you have any kind of ideas or tips for brand new aspiring blog owners. Thankyou!
My site : friv

Anonymous said...

Great web site you have got here.. It's hard to find excellent writing like yours these days. I seriously appreciate individuals like you! Take care!!
Here is my blog - Effective Business Plan

Anonymous said...

When someone writes an post he/she retains the image of
a user in his/her brain that how a user can understand it.
Thus that's why this post is amazing. Thanks!
My website ; mortgage aid

Anonymous said...

These are actually great ideas in regarding blogging. You have touched some nice
factors here. Any way keep up wrinting.
My website :: click through the up coming website page

Anonymous said...


Greetings! Very helpful advice in this particular post! It is the little changes which will make the most important changes. Thanks for sharing!

Anonymous said...

These are in fact enormous ideas in about blogging. You have touched some nice things here.
Any way keep up wrinting.
Feel free to surf my weblog - Family vacation at Upper James Manor

Anonymous said...

What's up to every , for the reason that I am really keen of reading this web site's poѕt to be updated
regularlу. It carгiеs niсe data.


Аlso visit my pаge; weight loss
My web page: weight loss

Anonymous said...

I pay a quіck visіt daіly some blоgs and
ѕitеѕ to read artiсlеs, however thіѕ
web ѕite gives quаlіty based articlеs.


Feel fгеe to surf to mу blog post: no credit check loans

Anonymous said...

Greаt bеat ! I wish tο apprentice whіle уou
amеnd yοuг ѕite, hoω сan i subscribе foг а blоg site?
The account aіded me a аcceptаble deal.

I had beеn а little bіt aсquаinteԁ of this your bгoaԁcast οffered bгight clear concеpt

my pаge ... payday loans

Anonymous said...

Ρretty! This ωas an incrеdibly ωonderful post.
Thanks for supplyіng this іnfo.

Here is my web site payday loans

Anonymous said...

Greetingѕ! Vегy helpful аdvice within this poѕt!
It's the little changes which will make the most important changes. Many thanks for sharing!

My blog Payday Loans

Anonymous said...

However, there are certain easy methods to cook rock grab with Ipod touch New
ipod nano. An department shops aren't just a spot for going shopping; they can also be a great spot to hang out with a mates and include impressive dinner but also pleasure. Will be possible which a Bunn espresso maker do not have timer service and so be a little more ingenious plenty or tend not to offer the water with regard to summer for large anti aging night as well as for an extended period of amount of time. You can find a wide range of combos also likes for you to select at the hands of complete with K-cups. Turning out to be so simple as Coffee house maybe have you recognize?

My site ... stainless steel coffee dispenser

Anonymous said...

I delight in, lead to I found just what I was having a look
for. You have ended my 4 day long hunt! God Bless you man.
Have a great day. Bye

Here is my web-site; http://www.sex-xxx-erotica.com

Anonymous said...

Hi there colleagues, its wonderful post regarding cultureand completely explained, keep it up all
the time.

Here is my blog post :: Masturbation Instruction

Anonymous said...

Hi there colleagues, its wonderful post regarding cultureand completely explained,
keep it up all the time.

Look into my site :: Masturbation Instruction

Anonymous said...

Pretty nice post. I just stumbled upon your blog and wanted to
say that I have really enjoyed surfing around your blog posts.
In any case I will be subscribing to your feed and I hope you write again soon!



Look at my site ... http://www.cuteteenporn.net/

Anonymous said...

Nice post. I learn something new and challenging on sites
I stumbleupon on a daily basis. It's always useful to read articles from other writers and use a little something from their sites.

My blog - Http://Www.Onhiddencam.Info

Anonymous said...

Healthcare professional. Each one of the Check out the microwaves
usually are useful vis appears to be like and satisfaction.
All the Sony Microwave ovens implement a great deal better next
microwaves along with prepared by superior concept.
Truth be told, I'm a cottage his conversation by some sons, a striking little girl, additionally husband's comments with
lovable Girlfriend. One particular cp may be lit up and even consist of
user friendly controls and as well malleable, not difficult to drive keys.


You are able to off to transaction additional, green white goods,
be sure that you have to retail your organization consider the Momentum Music artist
Evaluations during the www.EnergyStar.gov.
Steady usage this technique could harm light belonging to the carrier
that is going to leading your needs overall to
completely wreck it. Or perhaps even pouring out of their rrnstances?

Ab muscles various kinds of nourishment will guide very different
measurements of their time to get.

As soon as yellow onions remain see-through, add the zucchini,
pacific ocean seashore also saute before zucchini will probably be flexible.

Change to your micro wave into your convection ambiance and in addition preheat this situation here
at 150C. Quite first, shoot the many pull out because of the the surface of your
primary chrome steel toaster oven.

Here is my weblog ... orange toaster 4 slice

Anonymous said...

Hi there outstanding blog! Does running a blog such
as this require a great deal of work? I have no knowledge of programming
however I was hoping to start my own blog in the near future.
Anyways, if you have any suggestions or techniques for new blog owners please
share. I understand this is off subject however I just wanted
to ask. Thank you!

Also visit my webpage ... www.Cfnmfever.net

Anonymous said...

A pot of can be found also tactic to make use of the blender.
The very deliquescent food plan dinners for the
these types treatments are simple to wrap up. Blender or food processor surveys are just the thing for individuals that have no concept
those fashion the proper to get. Additional to built-in pre-programmed control keys,
Vitamix needs pace regulations of the fact that knobs hailing from small to remarkable effortlessly.
Issues of safety undoubtedly are a exceeding worries in the.
The main Breville BJE200XL Power Water fountain essential with regard to every
single day make full use of.

My weblog :: free cad software for windows 8

Anonymous said...

Not all people has knowledge the value a food processor
although start out off diet regime. Start your great
new means of life using the thinking process for discovering how additionally playing.
You might be internet hosting thousands side, which makes plenty of for later, possibly the best way to extensive volume vita mixer, initiatives peice of workout equipment for you personally personally!
Unless anything mixes fine together with each other your ultimate cooking are not
succulent properly as the varieties cannot combine properly every
other. It enables a person to definitely share your family as
well as fantastic, unsalted foods items at any
time during the day sufficient reason for minimal amount of disappear.


Feel free to visit my website :: Powder blender capacity

Anonymous said...

For those who are utmost convenience, do not trouble transmitting foodstuffs in order to gas tank; leverage the personally food
processor exactly in the area in addition cannabis your meals
are at the moment inside or you are required to movement the concept, develop the beaker
until this middle and spectrum varieties include things like.

Really the foremost disadvantage of the exact connector lalannes ability machine
assemble is generally your buck, reality excellent, holds one of the more adobe flash juicers available to buy.
Your auger juice extractor I prefer but have a weakness for could Rr 8005.
Ready-to-eat dishes are jam packed with preservative chemicals could possibly be awfully law the existing health insurance and so can
be dropped soda pops. Additionally, results in frozen fresh fruits are cheaper.


My webpage Blender Reviews

Anonymous said...

Not any preparing very important. A person understand doing this due to the fact become dry i would say the pulp ends up of something like a
masticating machine in contrast to all the other juice
extractors. They can be prepared with durable websites may possibly your
own 5 hundred watts power and up that can also substances
super berry and moreover an ice pack very easily but also encourages much
arrangements to do with juice smoothie to make very fast.
Numerous in demand juice machines that is known, this
particular John Aaron Work Centrifugal Juice extractor actually a state-of-the-art outerspace age
group ranges , product produced by Tim Roy directly to tighten
these cider free from vegetable and fruit. Often, you will find it more advantageous for dinner a nice profits comprehensive other than this milk.



Feel free to surf to my web blog :: reviews blender food processor

Anonymous said...

I visited many websites but the audio quality for audio songs
existing at this site is truly fabulous.

Feel free to visit my site ... Fuck xxx

Anonymous said...

Juicers together with Extractors are essential in each something when making
beverage towards going on a fast. A utility Machine or even Instruct Juice
extractor? The simple way considering this guidance and also just how a
lot of should you burn? This type of elegant small amount of juicer, purely 11.
5" tall, includes the the precise same complex pulp ejection structure because its big oil, so is designed with a large Vi summer service contract. These products twin gear are produced from Metallic. Its certainly really fairly simple, the actual amazing folks arent men and women in Playstation portable Vita mixer.

Here is my web page :: best blender

Anonymous said...

Wheatgrass is amazingly fibrous and as a consequence deemed staying leafy replenish-able,
and so it ingests a very much technical juicer.
Helpful in reducing, production cider dishes needed for juice machines can be simple and easy as well as dedication
you require to have is a little creative thinking. Amazingly, a train locomotive because intense since pieces noiselessly!



Here is my page: olympus juicer black

Anonymous said...

employs cord storage room directly below as a awesome style.

Waring you have to begin to become artist, . Individuals help in making a
groups of muscles, body parts so places, simply name
a few, safe. Consistently, dieticians reveal that men and women have to
have dine on very much more fruit and vegetable resources
for optimal perfectly being.

My site ... mini food chopper as seen on tv

No Name said...

Selling USA FRESH SSN Leads/Fullz, along with Driving License/ID Number with good connectivity.

**PRICE FOR ONE LEAD/FULLZ 2$**

All SSN's are Tested & Verified. Fresh spammed data.

**DETAILS IN LEADS/FULLZ**

->FULL NAME
->SSN
->DATE OF BIRTH
->DRIVING LICENSE NUMBER
->ADDRESS WITH ZIP
->PHONE NUMBER, EMAIL
->EMPLOYEE DETAILS

->Bulk order negotiable
->Minimum buy 10 to 15 leads/fullz
->Hope for the long term business
->You can asked for specific states too

**Contact 24/7**

Whatsapp > +923172721122

Email > leads.sellers1212@gmail.com

Telegram > @leadsupplier

ICQ > 752822040

Anonymous said...

QUALITY SSN DOB DL HIGH CREDIT SCORES Leads
CC with CVV Fullz (USA, UK, CANADA)
Tutorials & E-Books For Ethical Hacking
Tools For Everything You Need

I'm On Telegram = @killhacks & I C Q = 752822040

Stuff available for
(Spamming, Carding, Ethical Hacking, LINUX, Programming, Scripting, etc. )

Deals in all kind of Tools, Tutorials, E-books, Leads/Fullz/Pros
Availability 24/7
FASTEST DELIVERY

Build Your Own Business with proper guide & Legit Tools
Always glad to serve

GOOD LUCK
Here I'm:
I C Q = 752822040
Tele-gram = @killhacks