<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chirashi Security &#187; BlackBerry</title>
	<atom:link href="http://chirashi.zenconsult.net/tag/blackberry/feed/" rel="self" type="application/rss+xml" />
	<link>http://chirashi.zenconsult.net</link>
	<description>A blog with scattered thoughts on security</description>
	<lastBuildDate>Sun, 16 Oct 2011 17:26:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Puttering around with BlackBerry forensics &#8212; Part 1</title>
		<link>http://chirashi.zenconsult.net/2011/07/puttering-around-with-blackberry-forensics-part-1/</link>
		<comments>http://chirashi.zenconsult.net/2011/07/puttering-around-with-blackberry-forensics-part-1/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 16:29:38 +0000</pubDate>
		<dc:creator>chopstick</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Forensics]]></category>
		<category><![CDATA[bbt]]></category>
		<category><![CDATA[conparse]]></category>
		<category><![CDATA[event logs]]></category>
		<category><![CDATA[evt2sqlite]]></category>

		<guid isPermaLink="false">http://chirashi.zenconsult.net/?p=603</guid>
		<description><![CDATA[ I&#8217;m guilty of sitting on source code which I should have released a long time ago.  I make excuses to myself that I didn&#8217;t release any of it because I was waiting for someone to come along and prove to me that there was a better way of doing things.  I guess the bottom line [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://chirashi.zenconsult.net/wp-content/uploads/2011/07/514914659_220e004fd41.jpg"><img class="alignnone size-medium wp-image-605" title="Mag glass" src="http://chirashi.zenconsult.net/wp-content/uploads/2011/07/514914659_220e004fd41-300x221.jpg" alt="" width="210" height="155" /></a> I&#8217;m guilty of sitting on source code which I should have released a long time ago.  I make excuses to myself that I didn&#8217;t release any of it because I was waiting for someone to come along and prove to me that there was a better way of doing things.  I guess the bottom line was that I was just lazy and procrastinating.</p>
<p>Today, I&#8217;m releasing source code to three of my projects that I&#8217;ve been incubating.  1) <a href="https://github.com/sheran/bbt">bbt</a> 2) <a href="https://github.com/sheran/evt2sqlite">evt2sqlite</a>  3) <a href="https://github.com/sheran/ConParse">ConParse</a> Take! Build! Enjoy! <del>At some point or another, I may just split them up into their own repos.  For now, they all live in the <a href="https://github.com/sheran/bb-tools">bb-tools</a> repository down at github.</del> <strong>Update:</strong><em> I&#8217;ve split them up now</em></p>
<p>In today&#8217;s post, I&#8217;ll cover the first tool, bbt.</p>
<h3>bbt</h3>
<p>bbt is a python script that analyzes the thumbnail cache from a BlackBerry.  The purpose of a thumbnail cache in any system, is generally to speed up the browsing of large numbers of graphic or video files.  Instead of presenting a static icon to the user, a small thumbnail of the picture or frame of the video file is shown.  Apparently this is a good thing, because  you can see an icon of the image that you&#8217;re clicking on and will hopefully be able to find the file you&#8217;re looking for quicker.  Typically, the Operating System will find and shrink pictures found in directories of the filesystem.  These shrunk pictures will then be placed inside the thumbnail cache.</p>
<p>When conducting a digital forensics analysis of a computer, looking for these thumbnail caches often provide clues as to what files may have existed before they were deleted off the file system.  The thumbnail cache is important enough to warrant its <a href="http://www.forensicswiki.org/wiki/Thumbs.db">own entry</a> on the Forensics Wiki (albeit only the Windows thumbnail cache is spoken about).  The principle generally remains the same when extended to the BlackBerry device as well.  So, bottom line: being able to analyze this file is useful.</p>
<p>bbt will do just that for thumbnail cache files found on BlackBerry devices.  There are two types of thumbnail caches on the BlackBerry device: 1) BBThumbs.dat format 2) key/dat format.</p>
<p>Format 1 is pre OS 5.0 and the key/dat format is post OS 5.0  The key/dat combination is interesting because it uses two files to keep track of thumbnails.  They look something like thumbs86x86.key and thumbs86x86.dat (the 86&#215;86 indicates the size of the thumbnail &#8211; 86 pixels by 86 pixels).  I&#8217;ve noticed quite a few interesting things in these files and no doubt, you will too after you look through the source or play around with them long enough:</p>
<ol>
<li>The BBThumbs.dat header is 0&#215;24052003 (which is a hex number)</li>
<li>The thumbs.dat file header is 0&#215;22062009 (hex again)</li>
<li>The thumbs.key file header is 0&#215;08062009 (hex)</li>
</ol>
<p>This is pure speculation, but if you took those hexadecimal representations and looked at just the numbers, don&#8217;t they look like dates?</p>
<ul>
<li>0&#215;24052003 &#8211;&gt; 24 05 2003</li>
<li>0&#215;22062009 &#8211;&gt; 22 06 2009</li>
<li>0&#215;08062009 &#8211;&gt; 08 06 2009</li>
</ul>
<p>Maybe birth dates of the file format itself or someone significant to someone who wrote it? Dunno.</p>
<p>Another interesting observation of the key/dat thumbnail cache is that it not only stores image thumbnails, but also stores details of all types of media including &#8216;wav&#8217;, &#8216;mp3&#8242;, and &#8216;mid&#8217;.  It doesn&#8217;t store any content inside it though.  The only content stored inside the files is image data.</p>
<p>I&#8217;m not actually going to tell you what is found inside the thumbs files in this post, but instead, I am going to tell you how to run bbt.  bbt is a python script and as such will require that you have python installed on your system.  I&#8217;d always recommend cloning my <a href="https://github.com/sheran/bb-tools">repository on github</a> so that you can easily pull any updates.  You may also want to sign up for a <a href="http://github.com">github</a> account and watch the repository so that you will be notified of any commits I make.  You could also fork the project and get to work on it yourself.</p>
<pre>azazel:Device sheran$ ~/github/bb-tools/bbt/bbt.py
Usage: bbt.py [options]
  -h, --help: This cruft
  -k, --key &lt;bbthumbs key file&gt;: Process post OS5 thumbs.key file (requires thumbs.dat file in same directory)
  -b, --bbthumbs &lt;old bbthumbs file&gt;: Process pre OS5 BBThumbs.dat file
  -x, --extract: Extracts the thumbnails into directory specified by -o
  -o, --output &lt;output directory&gt;: Directory to extract thumbs to (used only with -x)
azazel:Device sheran$</pre>
<p>The output above is what you will receive if you run bbt without options.  As of the latest release (0.3b), the most magical thing you can do with this tool is to extract the thumbs into a specific output directory.  Additionally, bbt will parse out information about 1) What thumbnails are stored in the file (filename) for BBThumbs.dat files or 2) Where at what offset in a &#8216;dat&#8217; file a specific record id is stored.  Here&#8217;s some example output when parsing a key/dat pair:</p>
<pre>azazel:Device sheran$ ~/github/bb-tools/bbt/bbt.py -k thumbs116x116.key -x -o out
*** Processing thumbs116x116.key on 2011-07-22 21:50:48.156899
Record ID C620B80A is at offset 7 in 'dat' file // [1306132653179.jpeg]
Record ID DB0B7CA3 is at offset 25930 in 'dat' file // [1306492410606.jpeg]
Record ID D2EC23E3 is at offset 52123 in 'dat' file // [1306732433796.jpeg]
*** thumbs116x116.key has 9 records
*** Processed 3 records
azazel:Device sheran$</pre>
<p>When you parse a key/dat file combination, you need to make sure that both the &#8216;key&#8217; and &#8216;dat&#8217; file are in the same directory.  When you run bbt, you will point it to the location of the &#8216;key&#8217; file.  From the output above, you can see that it has discovered 3 records, corresponding record ids and offsets where they are stored in the &#8216;dat&#8217; file.  Also, the filename of the thumbnail is provided.  What do the offsets mean?  Well, if you were to take the numbers and open up the &#8216;dat&#8217; file in a hex editor, then you would land on the location where that specific record began.  This is what it looks like:</p>
<p><a href="http://chirashi.zenconsult.net/wp-content/uploads/2011/07/Screen-shot-2011-07-22-at-9.51.50-PM.png"><img class="alignnone size-medium wp-image-617" title="inside the dat file" src="http://chirashi.zenconsult.net/wp-content/uploads/2011/07/Screen-shot-2011-07-22-at-9.51.50-PM-300x154.png" alt="" width="300" height="154" /></a></p>
<p>The highlighted portion is the first part of the record with the correct starting offset.  You may also notice that the &#8216;key&#8217; file supposedly has 9 records but only 3 were processed.  This happens because the &#8216;key&#8217; file holds 9 record ids and 9 offsets, but only 3 of those actually match up in the &#8216;dat&#8217; file.  One assumption that can be made is that the files were deleted from the &#8216;dat&#8217; file, but the ids and offsets still remained in the &#8216;key&#8217; file.</p>
<p>bbt also has the &#8216;-x&#8217; option which allows you to extract the thumbnails that are inside either the BBThumbs.dat file or the key/dat files.  You do this by specifying the &#8216;-x&#8217; option along with the &#8216;-o&#8217; option to tell bbt where to extract the thumbnails to.  You will need to make sure that the output directory specified by the &#8216;-o&#8217; option does not already exist.</p>
<p>For now, that&#8217;s as much as you&#8217;re going to get out of bbt.  Some features that are planned in the roadmap for bbt are:</p>
<ul>
<li>HTML Reporting</li>
<li>Identification of Exif data within thumbnails</li>
<li>Completely parsing some of the header and record bytes that are as yet unknown</li>
</ul>
<p>I&#8217;ll cover the other tools in subsequent posts.  For now, though, the tools are all live in the github repository.  All of the tools contain a basic README doc that tells you how to get started with each of the tools.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2011/07/puttering-around-with-blackberry-forensics-part-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>You want the BlackBerry Event Log? beg damnit!</title>
		<link>http://chirashi.zenconsult.net/2010/07/you-want-the-blackberry-event-log-beg-damnit/</link>
		<comments>http://chirashi.zenconsult.net/2010/07/you-want-the-blackberry-event-log-beg-damnit/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 07:03:41 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Forensics]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=486</guid>
		<description><![CDATA[It&#8217;s been quite a while since my last post.  I&#8217;ve been a bit on the busy side with work, family and a bit of research.  Inspired by a friend and fellow researcher &#8211; Cst. Shafik Punja, I decided to look deeper into BlackBerry connectivity via USB.  If I succeeded at understanding this topic, I would [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://chirashi.zenconsult.net/wp-content/uploads/2010/07/forensics.png"><img class="alignnone size-full wp-image-500" title="forensics" src="http://chirashi.zenconsult.net/wp-content/uploads/2010/07/forensics.png" alt="" width="120" height="61" /></a>It&#8217;s been quite a while since my last post.  I&#8217;ve been a bit on the busy side with work, family and a bit of research.  Inspired by a friend and fellow researcher &#8211; Cst. Shafik Punja, I decided to look deeper into BlackBerry connectivity via USB.  If I succeeded at understanding this topic, I would be able to directly connect to a BlackBerry device and collect all the information that I wanted.  I wouldn&#8217;t be bound by tools like JavaLoader or the Desktop Manager and would have the freedom to write my own tools.  Well, I succeeded at understanding this and went a step further, I&#8217;m releasing a tool today.</p>
<div id="_mcePaste">I know that many forensic analysts are always looking at ways to pull data off mobile devices without installing invasive tools.  So I set about coding a tool to do something simple &#8212; pull the BlackBerry Event Log (you can open the event log from a BlackBerry device by holding down &#8220;ALT&#8221; and typing &#8220;LGLG&#8221;) from a BlackBerry device.  Sure, JavaLoader does this, so to differentiate the tool from JavaLoader, I made it a little more intelligent.  I called it <a href="http://chirashi.zensay.com/Resources">beg &#8211; BlackBerry Eventlog Grepper</a>.  beg can add a little bit of sanity to the madness that is the BlackBerry event log.  In other words, it translates the seemingly gibberish looking data to a more human friendly format.</div>
<h4>Example Event Log Output:</h4>
<pre lang="sh">guid:0x3B91E1630F0745BC time:2010/06/30 22:45:40.0 severity:Always Log type:String app:net.rim.tunnel data:Clos-MagicRudyAPN.rim
guid:0x316C1626A9DDC375 time:2010/06/30 22:45:40.0 severity:Always Log type:String app:net.rim.tcp data:clos
guid:0xB2EC7A712090AD8F time:2010/06/30 22:45:46.0 severity:Always Log type:String app:net.rim.smsui data:UTSC
guid:0xB2EC7A712090AD8F time:2010/06/30 22:45:46.0 severity:Always Log type:String app:net.rim.smsui data:UTSC
guid:0xB2EC7A712090AD8F time:2010/06/30 22:45:54.0 severity:Always Log type:String app:net.rim.smsui data:UTSC
guid:0xB2EC7A712090AD8F time:2010/06/30 22:45:54.0 severity:Always Log type:String app:net.rim.smsui data:UTSC
guid:0xB2EC7A712090AD8F time:2010/06/30 22:45:57.0 severity:Always Log type:String app:net.rim.smsui data:UTSC
guid:0x647E5DBBC34B5549 time:2010/06/30 22:46:09.0 severity:Always Log type:String app:net.rim.clock data:+CHG
guid:0xDAA64EAD4E49C5D5 time:2010/06/30 22:46:09.0 severity:Always Log type:String app:net.rim.usb.pwd data:CbCn
guid:0x5D41D4729582C2DA time:2010/06/30 22:46:09.0 severity:Always Log type:String app:RootRegister data:usbConnectionStateChange:1</pre>
<div id="_mcePaste">I started by looking at the phone calls that are written to the event log.  One thing you may notice from the event log is this:  If you delete a call from your call history, the event log does not delete it.  So if you pull the event logs, you will be caught in a lie.  I know that my friend in Law Enforcement would find this invaluable, so I started there.  For now, beg is able to dump the event logs, dump only the phone event logs and translate the phone event logs into something more readable.  The output looks something like this:</div>
<pre lang="bash">sheran@devbox:~/progs$ ./beg -p -r
Connected to 20fe2f60
2010/06/30 21:07:55.0: Incoming Call from +622157939018
2010/06/30 22:29:19.0: Outgoing Call to 02114045
2010/06/30 22:30:37.0: Outgoing Call to +628119917931
2010/06/30 22:41:54.0: Outgoing Call to +6281219684934
2010/06/30 22:53:27.0: Outgoing Call to +6281219684934
sheran@devbox:~/progs$</pre>
<h3>Inner workings</h3>
<div>First, I&#8217;d like to quickly go over the two main ways that you can connect to your BlackBerry device.  One of the initial methods I used was to write a Python script to take advantage of the libusb and PyUSB libraries.  I would then send raw commands back and forth.  These commands were sniffed from legitimate connections made between the BlackBerry and either JavaLoader or Desktop Manager.  The second method was to use an already existing library called Barry.  <a href="http://netdirect.ca/barry" target="_blank">Barry</a> was developed to allow Linux users to sync their BlackBerry devices on .  Since most of the work was already done, I decided to go with method 2 &#8211; using the Barry library.  So bear in mind that you will need to install the Barry library and it&#8217;s pre-requisites first.</div>
<div>To use beg, just download it and untar/gzip it to a folder.  Then, have a look through the README file.  It contains everything you would ever need to know.  For the moment, beg <strong>only works on Linux</strong> distributions and does require the Barry library and libusb library.  Support can always be found by getting in touch via the <a href="http://chirashi.zensay.com/Contact/" target="_blank">Contact page</a>.</div>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2010/07/you-want-the-blackberry-event-log-beg-damnit/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>InputStream to ByteArray on a BlackBerry</title>
		<link>http://chirashi.zenconsult.net/2010/01/inputstream-to-bytearray-on-a-blackberry/</link>
		<comments>http://chirashi.zenconsult.net/2010/01/inputstream-to-bytearray-on-a-blackberry/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 03:53:05 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=473</guid>
		<description><![CDATA[A quick and easy method to read an InputStream to a byte array is available in the IOUtilities class of the BlackBerry API.  I didn&#8217;t check if this is available pre 4.6 or not, but it does exist in 4.6 To read an InputStream directly to a byte array you can do something like this: [...]]]></description>
			<content:encoded><![CDATA[<p>A quick and easy method to read an InputStream to a byte array is available in the <a href="http://www.blackberry.com/developers/docs/4.6.0api/net/rim/device/api/io/IOUtilities.html">IOUtilities</a> class of the BlackBerry API.  I didn&#8217;t check if this is available pre 4.6 or not, but it does exist in 4.6</p>
<p>To read an InputStream directly to a byte array you can do something like this:</p>
<pre LANG="Java" Line="1">
FileConnector fconn = (FileConnector)Connector.open("testfile.txt");
InputStream inStream = fconn.openInputStream();
byte[] byteData = IOUtilities.streamToBytes(inStream);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2010/01/inputstream-to-bytearray-on-a-blackberry/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RIM says &#8220;Would you like a password hint?&#8221;</title>
		<link>http://chirashi.zenconsult.net/2010/01/rim-says-would-you-like-a-password-hint/</link>
		<comments>http://chirashi.zenconsult.net/2010/01/rim-says-would-you-like-a-password-hint/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 02:26:18 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=467</guid>
		<description><![CDATA[It would appear that RIM is planning to provide end-users with a mechanism to remember their passwords.  According to patent application 20090307498, RIM proposes to allow a user to store his password with unique version data to help him remember it later.  As per the patent application, the version data will be in the form [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://chirashi.zenconsult.net/wp-content/uploads/2009/10/topleft.gif"><img class="alignnone size-full wp-image-269" title="topleft" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/10/topleft.gif" alt="" width="139" height="55" /></a>It would appear that RIM is planning to provide end-users with a mechanism to remember their passwords.  According to patent application <a href="http://appft.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&amp;Sect2=HITOFF&amp;d=PG01&amp;p=1&amp;u=%2Fnetahtml%2FPTO%2Fsrchnum.html&amp;r=1&amp;f=G&amp;l=50&amp;s1=%2220090307498%22.PGNR.&amp;OS=DN/20090307498&amp;RS=DN/20090307498" target="_blank">20090307498</a>, RIM proposes to allow a user to store his password with unique version data to help him remember it later.  As per the patent application, the version data will be in the form of a date.  Thus, if the user forgets his password on the initial prompt and as long as he has not exceeded the maximum number of password attempts, he will receive a second prompt that says something like &#8220;The password that has been used is one from 3rd January 2009, please enter it to unlock the device.&#8221;  This can be helpful, but to someone like me who is awful with dates, it won&#8217;t help me much.  Here&#8217;s my initial take on the patent application.  Feel free to provide your views in either the comments or in the <a href="http://www.linkedin.com/groups?gid=2383165" target="_blank">LinkedIn group &#8211; BlackBerry Security</a>.</p>
<p>The thing that jumps out at me regarding this patent application is the fact that RIM is certainly becoming more consumer friendly.  In the country where I reside at the moment, one thing is apparent.  BlackBerries rule.  I have seen teenage girls in malls who have their faces buried in their BlackBerry.  I have also seen the regular business user owning not one but two.  It is easily the most popular phone sold here.  While corporates praise RIM for their security, consumers will not feel the same way.  In my brief, personal experience with alleged power-users, I came away feeling like no one really understood security at all.  This will most likely multiply with regular end-users.  So, in an effort not to appear too anal, RIM seems to have decided to provide a way for a user to remember his password.  Of course the patent refers to &#8220;unique version data&#8221; and remains fairly nebulous on what it can be.  In it&#8217;s patent application, RIM states that this unique data can be a date, integer or string.  It might be that the end-user will have the ability to configure an option like &#8220;prompt me with the 3rd and 8th character of my password&#8221;.  I know the maximum limit for incorrect passwords is no more than 10.  I still think it won&#8217;t be possible to guess a password in 10 attempts.  Thus this is quite a good move in helping make the device both secure and consumer-friendly.  I expect they will roll it out in one of their next OS updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2010/01/rim-says-would-you-like-a-password-hint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>App World Dynamic Licensing HOWTO</title>
		<link>http://chirashi.zenconsult.net/2009/12/app-world-dynamic-licensing-howto/</link>
		<comments>http://chirashi.zenconsult.net/2009/12/app-world-dynamic-licensing-howto/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 09:30:39 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Activation Code]]></category>
		<category><![CDATA[App World]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Licensing]]></category>
		<category><![CDATA[linkedin]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=452</guid>
		<description><![CDATA[I started releasing commercial applications on BlackBerry App World and yesterday was the first time I used the Dynamic Licensing model.  I devised a quick solution for working with Dynamic Licensing based on Google App Engine and this post shows how this can be achieved and also includes sample source code for other developers in [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">I started releasing commercial applications on BlackBerry App World and yesterday was the first time I used the Dynamic Licensing model.  I devised a quick solution for working with Dynamic Licensing based on Google App Engine and this post shows how this can be achieved and also includes sample source code for other developers in a similar situation.  Dynamic Licensing provides a mechanism for granting activation codes to user who purchase applications.  The system works like this:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">As with almost all commercial, downloadable applications, online purchase and activation codes have become the norm.  The end-user pays for the product, downloads it and waits for an activation code to be sent to his email address.  Once he receives the code, he enters it into the app and he can begin using it.  This is straightforward if the developer sells the app on his own store that is hosted on his own server.  If he is to sell it on other stores, however, things become tricky.  Usually, well established stores like MobiHand and others have a mechanism that allows a developer to interface with their storefront for various purposes.  One of these instances is when activation codes are involved.  In cases like these, here is a quick run-down of how the purchase flow works:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1. End-user visits Online Store</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">2. End-user buys app from the Online Store</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">3. Online Store contacts the Developer Server (using an HTTP POST request) with end-user specific details</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">4. Developer Server generates the activation key</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">5. Developer Server responds to the Online Store POST request with an activation key</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">6. Online Store then presents this activation key to the End-user</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">It is the Developer&#8217;s responsibility to get his activation server up and running to ensure steps 3-5 are completed.  Sometimes this can be a painful task; especially after you&#8217;ve spent a few grueling weeks in developing your latest and greatest application.  Here then are the steps to help simplify the process:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">My solution is to setup a free account on Google App Engine to host my activation server routines there.  Why bother you ask?  Here are some advantages that I can see:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1. App Engine is free and can easily be converted to a paid model (reasonably priced) based only on usage of resources</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">2. App Engine offers Java so its more likely to be familiar to a BlackBerry developer</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">3. No administrative overhead with setting up a server or maintaining it</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">4. It&#8217;s cool if you like to get into &#8220;Cloud Computing&#8221;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">5. It&#8217;s very easy to move off Google App Engine and onto your own server when you&#8217;re ready because of the standardized modules</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">I&#8217;m not going to talk you through how to get an account, sign-up, etc.  Google has tons of docs and tutorials on how to do so.  I&#8217;ll assume you&#8217;ve already got your App Engine and know how to deploy apps on it.  What we&#8217;re going to create is a servlet and optionally, some classes to help us persist the incoming information to the app engine database.  If you&#8217;re using Eclipse with the Google App Engine plugin, then creating a project is simple.  On Eclipse simply click File-&gt;New-&gt;Project and then choose Web Application Project under the Google folder.  By default, a new project will be created with a servlet having the &#8220;doGet&#8221; method.  This method handles only HTTP GET requests.  You also need to create your own &#8220;doPost&#8221; method.  This is usually because stores including App World will POST the data to your URL.  What I do is just swap the doGet with doPost.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">I then write my routines to handle the incoming request.  I usually capture all relevant information, extract some key parameters, use it to generate my activation key and provide a response.  For the sake of simplifying things.  Here is the code for my servlet that captures information from BlackBerry App World, generates the Activation Code and responds with that code:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">If you paste the code above into your Eclipse, you will run into some errors.  These are the typical ones and how they can be fixed:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1. The KeyGen Class isn&#8217;t available.  This is my own KeyGen routine for generating Activation Keys.  It takes the BlackBerry PIN as an argument and does some magic on it.  You have to write this one yourself.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">2. The Hex Class isn&#8217;t available.  In my case, I wanted to work with Hex strings and convert them back and forth.  I looked up the source to the Apache Commons Codec project and copied across the source code for the Hex class and all its dependencies into my own project.  You do not need to use it, but if you do, then I advise you to look at the Apache Commons Project.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">3. The PMF class is missing.  This class is used if you want to Persist or store data. The PMF class source code is standard and Google App Engine has the sample code for it here.  If you need it, I&#8217;ve attached the code later on in this post.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">As far as I recall this is what you will need to address.  Now, lets move onto storing the incoming data on the database.  I store each request in a class called an Entry.  Thus, each POST request to my servlet will be checked and if it isn&#8217;t tagged as a test, then it will be stored to the database.  The Entry object is marked as persistable and this makes it easy to store in the App Engine datastore.  Here is the code for the Entry object:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Once you get this up and running, you have about the simplest mechanism for working with Dynamic Licensing with not only BlackBerry App World, but other stores as well.  You can, of course, make this as grandiose as you wish; that part is left as an exercise.  I&#8217;m just giving you a point to start at.</div>
<p>I started releasing commercial applications on BlackBerry App World and yesterday was the first time I used the Dynamic Licensing model.  I devised a solution based on Google App Engine and this post shows how this can be achieved and also includes sample source code for other developers in a similar situation.  Dynamic Licensing provides a mechanism for granting activation codes to user who purchase applications.  The system works like this:</p>
<div id="attachment_453" class="wp-caption alignnone" style="width: 490px"><a href="http://chirashi.zenconsult.net/wp-content/uploads/2009/12/appworldflow_sm.png"><img class="size-full wp-image-453" title="appworldflow_sm" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/12/appworldflow_sm.png" alt="App World Flow" width="480" height="112" /></a><p class="wp-caption-text">App World Flow</p></div>
<p>As with almost all commercial, downloadable applications, online purchase and activation codes have become the norm.  The end-user pays for the product, downloads it and waits for an activation code to be sent to his email address.  Once he receives the code, he enters it into the app and he can begin using it.  This is straightforward if the developer sells the app on his own store that is hosted on his own server.  If he is to sell it on other stores, however, things become tricky.  Usually, well established stores like <a href="http://www.mobihand.com" target="_blank">MobiHand</a> and others have a mechanism that allows a developer to interface with their storefront for various purposes.  One of these instances is when activation codes are involved.  In cases like these, here is a quick run-down of how the purchase flow works:</p>
<ol>
<li>End-user visits Online Store</li>
<li>End-user buys app from the Online Store</li>
<li>Online Store contacts the Developer Server (using an HTTP POST request) with end-user specific details</li>
<li>Developer Server generates the activation key</li>
<li>Developer Server responds to the Online Store POST request with an activation key</li>
<li>Online Store then presents this activation key to the End-user</li>
</ol>
<p>It is the Developer&#8217;s responsibility to get his activation server up and running to ensure steps 3-5 are completed.  Sometimes this can be a painful task; especially after you&#8217;ve spent a few grueling weeks in developing your latest and greatest application.  My solution is to setup a free account on Google App Engine to host my activation server routines there.  Why bother you ask?  Here are some advantages that I can see:</p>
<ol>
<li>App Engine is free and can easily be converted to a paid model (reasonably priced) based only on usage of resources</li>
<li>App Engine offers Java so its more likely to be familiar to a BlackBerry developer</li>
<li>No administrative overhead with setting up a server or maintaining it</li>
<li>It&#8217;s cool if you like to get into &#8220;Cloud Computing&#8221;</li>
<li>It&#8217;s very easy to move off Google App Engine and onto your own server when you&#8217;re ready because of the standardized modules</li>
</ol>
<p>I&#8217;m not going to talk you through how to get an account, sign-up, etc.  Google has tons of docs and tutorials on how to do so.  I&#8217;ll assume you&#8217;ve already got your App Engine and know how to deploy apps on it.  What we&#8217;re going to create is a servlet and optionally, some classes to help us persist the incoming information to the app engine database.  If you&#8217;re using Eclipse with the Google App Engine plugin, then creating a project is simple.  On Eclipse simply click File-&gt;New-&gt;Project and then choose Web Application Project under the Google folder.  By default, a new project will be created with a servlet having the &#8220;doGet&#8221; method.  This method handles only HTTP GET requests.  You also need to create your own &#8220;doPost&#8221; method.  This is usually because stores including App World will POST the data to your URL.  What I do is just swap the doGet with doPost.</p>
<p>I then write my routines to handle the incoming request.  I usually capture all relevant information, extract some key parameters, use it to generate my activation key and provide a response.  For the sake of simplifying things.  Here is the code for my servlet that captures information from BlackBerry App World, generates the Activation Code and responds with that code:</p>
<pre LANG="Java" line="1">
package net.zenconsult.keyserver;

import java.io.IOException;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.zenconsult.codec.binary.Hex;

@SuppressWarnings("serial")
public class KeyServerServlet extends HttpServlet {
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		// The RIM POST Format:
		// PIN=12341234&#038;email=customeremail@email.com&#038;product=product&#038;version=1.2&#038;transactionid=123&#038;test=false

		String PIN = req.getParameter("PIN");
		String email = req.getParameter("email");
		String product = req.getParameter("product");
		String version = req.getParameter("version");
		String transactionId = req.getParameter("transactionid");
		String test = req.getParameter("test");
		String verify = req.getParameter("verify");

		//Init vlaues
		if(email == null)
		{
			email = "";
		}
		if(product == null)
		{
			product = "";
		}
		if(version == null)
		{
			version = "";
		}
		if(transactionId == null)
		{
			transactionId = "";
		}
		if(test == null)
		{
			test = "true";
		}

		// I realize using String.matches is taboo, but I did it anyway.  Feel free to change it
		// Since you can also pass your own parameters, I am passing the "verify" parameter; security by obscurity, I know,
		// but when using App Engine, your Servlet is publicly accessible, so...

		if((PIN.matches("\p{XDigit}{8}")) &#038;&#038; (verify != null) &#038;&#038; (verify.equalsIgnoreCase("bbappworld")) )
		{
			// This is my own Key Generation Routine
			KeyGen kg = new KeyGen(PIN);
			String hexString = new String(Hex.encodeHex(kg.genKey()));

			String Key = hexString.toUpperCase();
			if(test.equals("false"))
			{
				PersistenceManager pm = PMF.get().getPersistenceManager();
				Entry entry = new Entry(email, product, version, transactionId);
				pm.makePersistent(entry);
				pm.close();
			}
			resp.setContentType("text/plain");
			resp.getWriter().println("key="+Key);
		}

	}
}</pre>
<p>If you paste the code above into your Eclipse, you will run into some errors.  These are the typical ones and how they can be fixed:</p>
<ol>
<li>The KeyGen Class isn&#8217;t available.  This is my own KeyGen routine for generating Activation Keys.  It takes the BlackBerry PIN as an argument and does some magic on it.  You have to write this one yourself.</li>
<li>The Hex Class isn&#8217;t available.  In my case, I wanted to work with Hex strings and convert them back and forth.  I looked up the source to the Apache Commons Codec project and copied across the source code for the Hex class and all its dependencies into my own project.  You do not need to use it, but if you do, then I advise you to look at the Apache Commons Project.</li>
<li>The PMF class is missing.  This class is used if you want to Persist or store data. The PMF class source code is standard and Google App Engine has the sample code for it <a href="http://code.google.com/appengine/docs/java/datastore/usingjdo.html" target="_blank">here</a>.  If you need it, I&#8217;ve attached the code later on in this post.</li>
</ol>
<p>As far as I recall this is what you will need to address.  Now, lets move onto storing the incoming data on the database.  I store each request in a class called an Entry.  Thus, each POST request to my servlet will be checked and if it isn&#8217;t tagged as a test, then it will be stored to the database.  The Entry object is marked as persistable and this makes it easy to store in the App Engine datastore.  Here is the code for the Entry object:</p>
<pre LANG="Java" line="1">
package net.zenconsult.keyserver;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Entry
{
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

	@Persistent
	private String email;

	@Persistent
	private String product;

	@Persistent
	private String version;

	@Persistent
	private String transactionId;

	@Persistent
	private Date creationDate;

	public Entry(String email, String product, String version, String transactionId)
	{
		setEmail(email);
		setProduct(product);
		setVersion(version);
		setTransactionId(transactionId);
		setCreationDate(new Date());
	}

	/**
	 * @param key the key to set
	 */
	public void setKey(Key key) {
		this.key = key;
	}

	/**
	 * @return the key
	 */
	public Key getKey() {
		return key;
	}

	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param product the product to set
	 */
	public void setProduct(String product) {
		this.product = product;
	}

	/**
	 * @return the product
	 */
	public String getProduct() {
		return product;
	}

	/**
	 * @param version the version to set
	 */
	public void setVersion(String version) {
		this.version = version;
	}

	/**
	 * @return the version
	 */
	public String getVersion() {
		return version;
	}

	/**
	 * @param transactionId the transactionId to set
	 */
	public void setTransactionId(String transactionId) {
		this.transactionId = transactionId;
	}

	/**
	 * @return the transactionId
	 */
	public String getTransactionId() {
		return transactionId;
	}

	/**
	 * @param creationDate the creationDate to set
	 */
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	/**
	 * @return the creationDate
	 */
	public Date getCreationDate() {
		return creationDate;
	}

}
</pre>
<p>Once you get this up and running, you have about the simplest mechanism for working with Dynamic Licensing with not only BlackBerry App World, but other stores as well.  You can, of course, make this as grandiose as you wish; that part is left as an exercise.  I&#8217;m just giving you a point to start at.</p>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2009/12/app-world-dynamic-licensing-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Emulating the BlackBerry Phone Call Log Field</title>
		<link>http://chirashi.zenconsult.net/2009/12/emulating-the-blackberry-phone-call-log-field/</link>
		<comments>http://chirashi.zenconsult.net/2009/12/emulating-the-blackberry-phone-call-log-field/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 13:54:27 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jde]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=433</guid>
		<description><![CDATA[While writing an application for the BlackBerry, I wanted to emulate the layout of the Phone Log.  Typically, this looks like a set of rows laid out in a two-column or multi-column format.  Since there was no available field to achieve this, I had to write my own.  The way I did it was to [...]]]></description>
			<content:encoded><![CDATA[<p>While writing an application for the BlackBerry, I wanted to emulate the layout of the Phone Log.  Typically, this looks like a set of rows laid out in a two-column or multi-column format.  Since there was no available field to achieve this, I had to write my own.  The way I did it was to override the drawListRow method in an ObjectListField.  One thing you can notice in your BlackBerry call log screen is that the last 10 characters are always reserved and never appear as an ellipsis.  The last 10 characters are usually formatted thusly:</p>
<p><strong>[Call Attribute: upto 4 characters][Date or Time: upto 6 characters]</strong></p>
<p>Some examples of these are:</p>
<pre><code>
(W) 9:58p
(W2)11:22p
(H) 01/09
</code></pre>
<p>You will see in example 2 above, that all 10 characters are used up.  After I figured this out, the rest was pretty straightforward.  Here is the source code to my Field called PhoneNumberListField.</p>
<pre lang="Java">import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ObjectListField;

public class PhoneNumberListField extends ObjectListField
{

	public PhoneNumberListField()
        {
     	    super();
        }

	public PhoneNumberListField(long style)
        {
     	    super(style);
        }

        public void drawListRow(ListField listField, Graphics graphics,
        		int index, int y, int width)
        {

        	String tmpCol1 = (String) this.get(listField, index);
        	String col1 = tmpCol1.substring(0, (tmpCol1.length() - 10));
        	String col2 = tmpCol1.substring(tmpCol1.length()-10);

        	int col2Size = this.getFont().getAdvance(col2);
                int col1Size = width - col2Size;

        	int col1Start = 0;
        	int col2Start = (width - col2Size);

        	graphics.drawText(col1, col1Start, y, DrawStyle.ELLIPSIS, col1Size);

        	graphics.drawText(col2, col2Start, y, DrawStyle.HDEFAULT, col2Size);

        }

}</pre>
<h3>How to implement</h3>
<p>You first create an array of Strings.  This array can contain phone numbers or a combination of First Name, Last Name together with the phone attribute like (W), (H) for Work and Home numbers respectively.  The last field will be the date or time.  I check the time of the call to see if it is older than 24 hours.  If it is, I use the date.  The format for the time is “<em>h:mma</em>” and for date it is “<em>MM/dd</em>”.  You can format these using SimpleDateFormat.</p>
<p>The full list of BlackBerry Attributes are represented as follows:</p>
<p>Home: (H)<br />
Work: (W)<br />
Mobile: (M)<br />
Pager: (P)<br />
Fax: (F)<br />
Other: (O)<br />
Work2: (W2)<br />
Home2: (H2)</p>
<p>The attribute constants can be found in the <a href="http://www.blackberry.com/developers/docs/4.6.0api/net/rim/blackberry/api/pdap/BlackBerryContact.html" target="_blank">BlackBerryContact Interface</a>.  A typical array of mine would look like this:</p>
<pre><code>
String[] numList = {“Sheran Gunasekera (W) 09/09”, “Scott Mosier (M) 9:39a”,
“Kevin Smith (M)10:39p”, “+12120031337     10:04p};</code></pre>
<p>Then, if I want to place this field on my MainScreen, I do this:</p>
<pre lang="Java">PhoneNumberListField numbers = new PhoneNumberListField();
numbers.setEmptyString(“*** No Calls Yet ***”, DrawStyle.HCENTER);
numbers.set(numList);
add(numbers);</pre>
<p>This is what it looks like:</p>
<div id="attachment_444" class="wp-caption alignnone" style="width: 310px"><a href="http://chirashi.zenconsult.net/wp-content/uploads/2009/12/PhoneNumberListField.png"><img class="size-medium wp-image-444" title="PhoneNumberListField" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/12/PhoneNumberListField-300x200.png" alt="PhoneNumberListField" width="300" height="200" /></a><p class="wp-caption-text">PhoneNumberListField</p></div>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2009/12/emulating-the-blackberry-phone-call-log-field/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Platform specific download statistics for the BlackBerry</title>
		<link>http://chirashi.zenconsult.net/2009/12/platform-specific-download-statistics-for-blackberries/</link>
		<comments>http://chirashi.zenconsult.net/2009/12/platform-specific-download-statistics-for-blackberries/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 06:54:29 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=419</guid>
		<description><![CDATA[I looked at the statistics for the number of downloads of Kisses, that I had today.  It was interesting to see the different types of Operating System versions or Platforms that were indeed downloading the tool.  Over all, I had 3051 downloads for a period of about 6 weeks.  I started writing applications that I [...]]]></description>
			<content:encoded><![CDATA[<p>I looked at the statistics for the number of downloads of Kisses, that I had today.  It was interesting to see the different types of Operating System versions or Platforms that were indeed downloading the tool.  Over all, I had 3051 downloads for a period of about 6 weeks.  I started writing applications that I plan to sell and was faced with the tough decision of choosing features based on the specific OS revision.  If I set a base OS version, then I stood to loose a percentage of the BlackBerry users out there.  So I turned to my existing downloads and came up with this chart.  In the hopes that others find it useful, I&#8217;ve included it in this post.  Surprisingly, I thought there would be more users for 4.2 and 4.3 versions.  Thus, based on this, I will set my base version to 4.5.  This cuts out weeks of development time (mainly making workarounds).  Obviously these figures don&#8217;t paint the full picture, but they give me a fair idea of how to plan.</p>
<p><a href="http://chirashi.zenconsult.net/wp-content/uploads/2009/12/BlackBerry_OS_Version_Statistics.png"><img class="alignnone size-medium  wp-image-420" title="BlackBerry_OS_Version_Statistics" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/12/BlackBerry_OS_Version_Statistics-238x300.png" alt="BlackBerry_OS_Version_Statistics" width="238" height="300" /></a></p>
<p style="clear: both;">&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2009/12/platform-specific-download-statistics-for-blackberries/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mice, Permissions and a Solution?</title>
		<link>http://chirashi.zenconsult.net/2009/11/mice-permissions-and-a-solution/</link>
		<comments>http://chirashi.zenconsult.net/2009/11/mice-permissions-and-a-solution/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 18:14:04 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Surveillance]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=394</guid>
		<description><![CDATA[The BlackBerry default application permissions should be one of the most important things to a BlackBerry Internet Service (BIS) user.  But how can these application permissions be monitored and checked for those times when they are changed (creating a potentially risky situation) and the user forgets to revert to its original setting?  This post will highlight a possible mechanism of checking for the most critical permissions.  There's also some sample program source code that users can download and play with.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-medium wp-image-399" style="padding: 0 7px 5px; 0" title="mice" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/11/mice-300x218.jpg" alt="mice" width="300" height="218" />What do mice do when its cold?  They sit around a candle.  What do they do when its really cold?  They light the candle.  In a sense, the same applies to the Default Application Permissions on your BlackBerry.  They are important, but without being set correctly and understood well, they’re very much like the unlit candle the mice sit around: lots of potential, but completely ineffectual.  The perils of not setting your application permissions correctly?  Here are a two:</p>
<ol>
<li>You don’t know if your “Input Simulation” permission is set to “Allow”.  If it is allowed, any application can make key-presses on your handheld as if they were you.  Potential: <a href="http://chirashi.zensay.com/2009/10/remote-listening-for-the-blackberry/">an application can answer your phone calls</a>.</li>
<li>You’re not sure your “Security Timer Reset” permission is set to “Allow”.  If it is, then any application can <a href="http://chirashi.zensay.com/2009/11/the-security-timer-reset-permission/">render your screen lockout useless</a>.</li>
</ol>
<p>I can almost hear you asking me, “Why tell me about it? You think I don’t know about this?” and the truth is, its an even split.  There are users out there that are blissfully unaware of things like Default Application Permissions.  The BlackBerry is going the way of the consumer, and fast.  With the rise in popularity of the <a href="http://en.wikipedia.org/wiki/BlackBerry_Internet_Service" target="_blank">BlackBerry Internet Service</a>, a user no longer needs to be a part of an large organization to reap the many benefits of a BlackBerry.  The flip side?  There is no <a href="http://en.wikipedia.org/wiki/BlackBerry_Enterprise_Server" target="_blank">enterprise security administrator</a> or policy to protect these users.  Thus when they decide to go with BIS, they take on the task of remaining secure.  For a second, leave these users out of the picture.  Pick the other half of the users who are aware.  Suppose they set some permissions and then forgot about them?  Maybe they allowed access based on an application requesting them to do so and they never set the permissions back.  What then?</p>
<p>I thought about this and came up with a solution of sorts.  Why not have a list of the most important security permissions and check them at a timed interval to see if they have been changed?  If they have, then send the user an alert.  Here’s the code I came up with:</p>
<pre lang="JAVA">package com.zensay.sectest;

import java.util.Timer;
import java.util.TimerTask;
import net.rim.device.api.applicationcontrol.ApplicationPermissions;
import net.rim.device.api.applicationcontrol.ApplicationPermissionsManager;
import net.rim.device.api.system.Application;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiEngine;
import net.rim.device.api.ui.component.Dialog;

public class Main extends Application
{
    public static void main(String args[])
    {
        Main app = new Main();
        app.enterEventDispatcher();
    }

    public Main()
    {
        TimerTask tm = new TimerTask()
        {
			public void run()
			{
				reqPerm();
			}
        };
    	Timer t = new Timer();
        t.schedule(tm,10000, 10000);
    }

    public void reqPerm()
	{
		ApplicationPermissionsManager apm = ApplicationPermissionsManager.getInstance();
		int input = apm.getPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION);
		if(input == ApplicationPermissions.VALUE_ALLOW)
		{
			synchronized(Application.getEventLock())
			{
				UiEngine ui = Ui.getUiEngine();
				Screen screen = new Dialog(Dialog.D_OK, "Input Simulation is allowed!!",
						Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);
				ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);
			}
		}
	}
}</pre>
<p><img class="alignnone size-medium wp-image-406" title="perm_check" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/11/perm_check-188x300.jpg" alt="perm_check" width="188" height="300" /></p>
<p style="clear: both;">To explain it a little bit, the code (when compiled, signed and executed on your BlackBerry) will check your “Input Simulation” permission.  If it is set to “Allow” the application will pop open a message window and notify the user.  It does this every 10 seconds.  Its annoying as hell, but I think you get the general idea.  I tested this on my Bold and it works very well.  I’m thinking about making it an additional feature in Kisses; with a slightly longer timeout of course.  Its a feature I would find useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2009/11/mice-permissions-and-a-solution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The &#8216;Security Timer Reset&#8217; permission</title>
		<link>http://chirashi.zenconsult.net/2009/11/the-security-timer-reset-permission/</link>
		<comments>http://chirashi.zenconsult.net/2009/11/the-security-timer-reset-permission/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 18:14:53 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ubertwitter]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=334</guid>
		<description><![CDATA[Did you ever wonder what some of those Application Permissions were on your BlackBerry?  I&#8217;m putting together a paper that details the more important ones and why you should be careful in changing them.  For now, I thought I&#8217;d share some information about the &#8220;Security Timer Reset&#8221; permission and what you can do with it. [...]]]></description>
			<content:encoded><![CDATA[<p>Did you ever wonder what some of those Application Permissions were on your BlackBerry?  I&#8217;m putting together a paper that details the more important ones and why you should be careful in changing them.  For now, I thought I&#8217;d share some information about the &#8220;<em>Security Timer Reset</em>&#8221; permission and what you can do with it.</p>
<p>The Security Timer Reset permission is set to Deny by default.  This is good.  Be wary of applications asking you for Allow permissions on this.  One of the things you can do with this permission enabled is to delay your lock screen.  Indefinitely.</p>
<p>The lock screen usually appears when your <em>Security Timeout</em> is exceeded.</p>
<div id="attachment_336" class="wp-caption alignnone" style="width: 250px"><img class="size-full wp-image-336" title="9000_lock_screen" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/11/9000_lock_screen.png" alt="Device Lock Screen" width="240" height="160" /><p class="wp-caption-text">Device Lock Screen</p></div>
<p>For example, if you have a <em>Security Timeout</em> set to 2 minutes, your screen will lock automatically and you will have to enter your password to access the device again.  This is handy to have, if you leave your BlackBerry on your desk at work and are afraid someone will pick it up and install nasty stuff on your BlackBerry.</p>
<div id="attachment_335" class="wp-caption alignnone" style="width: 250px"><img class="size-full wp-image-335" title="9000_lock_screen-01" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/11/9000_lock_screen-01.png" alt="Lock Screen Timeout" width="240" height="160" /><p class="wp-caption-text">Security Timeout</p></div>
<p>Let&#8217;s take the case where you download a malicious application (you don&#8217;t know its malicious of course).  It is such a compelling one (read: porn slideshow) that you just HAD to download it.  Now the application innocently asks you for the &#8220;<em>Event Injection</em>&#8221; &amp; &#8220;<em>Security Timer Reset</em>&#8221; permission to &#8216;advance&#8217; the slides back and forth.  &#8220;Sure&#8221;, you think, &#8220;no problems there now is it?&#8221; and you grant Allow access to the application.  What this application <strong><em>could</em></strong> do is to then inject a key event every 15 seconds.  This can be done so that you don&#8217;t notice.  When this key event is injected every 15 seconds, its as if you are moving the trackball or clicking a key.  This delays the device lockout because the timer is reset every 15 seconds.  <strong>The device will now never lock itself out.</strong></p>
<p>So be wary of granting Allow Permissions on almost everything.  I know UberTwitter is an application that asks for a lot of Allow permissions (although it doesn&#8217;t ask you for the Security Timer Reset permission).  I think it might be worthwhile starting a Permissions Hall of Shame on my site, just to list such offenders.</p>
<div id="attachment_337" class="wp-caption alignnone" style="width: 346px"><img class="size-full wp-image-337 " title="ubertwitter_2" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/11/ubertwitter_2.png" alt="Permission Change Request" width="336" height="224" /><p class="wp-caption-text">Permission Change Request</p></div>
<div id="attachment_338" class="wp-caption alignnone" style="width: 346px"><img class="size-full wp-image-338 " title="ubertwitter_3" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/11/ubertwitter_3.png" alt="Allow All" width="336" height="224" /><p class="wp-caption-text">Allow All</p></div>
<div id="attachment_339" class="wp-caption alignnone" style="width: 346px"><img class="size-full wp-image-339 " title="ubertwitter_4" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/11/ubertwitter_4.png" alt="...like really!" width="336" height="224" /><p class="wp-caption-text">...like really!</p></div>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2009/11/the-security-timer-reset-permission/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Team BlackBerryForums! Fu*k Yeah!</title>
		<link>http://chirashi.zenconsult.net/2009/11/team-blackberryforums-fuk-yeah/</link>
		<comments>http://chirashi.zenconsult.net/2009/11/team-blackberryforums-fuk-yeah/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 07:54:46 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[humor]]></category>
		<category><![CDATA[Spyware]]></category>
		<category><![CDATA[Surveillance]]></category>
		<category><![CDATA[WTF?]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=324</guid>
		<description><![CDATA[I&#8217;m glad I don&#8217;t take things personally.  I am also a firm believer in the phrase &#8220;no good deed goes unpunished&#8221;.  I decided to post in both the CrackBerry Forums and BlackBerryForums communities that I&#8217;d released the program called Kisses.  It would appear, however, that the fact that I had designed both PhoneSnoop and Kisses [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-325" style="margin: 5px;" title="teamamerica_1024" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/11/teamamerica_1024.jpg" alt="teamamerica_1024" width="294" height="222" />I&#8217;m glad I don&#8217;t take things personally.  I am also a firm believer in the phrase &#8220;no good deed goes unpunished&#8221;.  I decided to post in both the <a href="http://forums.crackberry.com/f83/show-hidden-apps-263067/#post2993904" target="_blank">CrackBerry</a> Forums and <a href="http://www.blackberryforums.com/" target="_blank">BlackBerryForums</a> communities that I&#8217;d released the program called <a href="http://kisses.zensay.com/" target="_blank">Kisses</a>.  It would appear, however, that the fact that I had designed both <a href="http://chirashi.zensay.com/2009/10/remote-listening-for-the-blackberry/" target="_blank">PhoneSnoop</a> and Kisses seemed to strike a nerve with the members of both forums.  CrackBerry has deleted the post I made.  The <a href="http://www.blackberryforums.com/aftermarket-software/209443-kisses-free-spyware-detector.html" target="_blank">thread on the BlackBerryForums</a>, however, is still alive and kicking. If you have some time to waste, head on down there and have a read.</p>
<p>The thread demonstrates some of the ways in which people formulate opinions and it highlighted something very important; to me at least.  Its a trait that I have seen with so many developers of applications as well.  It would appear to me that people are always looking to &#8220;play&#8221; within a certain set of distinct boundaries.</p>
<p>I&#8217;ll give you an example of a web application developer.  In one banking application I tested, I was able to do a &#8220;negative transfer&#8221;.  It worked like this, if Alice were to transfer -$1000 to Bob, the logic of the application made Bob do a transfer of $1000 to Alice.  So by Alice initiating a negative transfer, she was able to pull money out of Bob&#8217;s account.  When confronted with this, the developer simply stated &#8220;yes, but a user is not supposed to do this.&#8221;  Well of course he&#8217;s not supposed to do this, but isn&#8217;t it your job as a developer to check for it?  An attacker is not going to play nice; he&#8217;s going to find any way he can to own you.  If he can&#8217;t hack your systems, he&#8217;ll come at you with a knife or a gun.  To him, the end goal is getting what he wants.  He&#8217;s not going to stop doing something just because &#8220;a user is not supposed to do this&#8221;.</p>
<p>If you take the case of what happened in the forums above, it seems very similar.  Here goes:</p>
<p>The forum users and moderators that did reply, seem to be under the impression that just because I released PhoneSnoop, I am trying to infect them by pushing Kisses (in their minds a malicious app) as a cure.  So to me, at least, it appears that their &#8220;boundary&#8221; or &#8220;sandbox&#8221; is the fact that I should have released one or the other but not both.  I&#8217;ll cover why this is not a very sound way of thinking later, but first, some fun.  Here are some of the things said in the forum post if you didn&#8217;t bother reading the whole thing.</p>
<ul>
<li>I was asked if now that I had raised awareness how long I will make PhoneSnoop available for.</li>
<li>I was compared to a fox guarding a hen house</li>
<li>I was compared to a pharmaceutical company</li>
<li>I was wished with &#8220;Kisses of death&#8221;</li>
<li>I was threatened with being sent back to Sri Lanka in a box.</li>
<li>I was called a lovely set of names ranging from &#8220;super-spy&#8221;, &#8220;spy-master&#8221; and compared with mid-eastern terrorists</li>
<li>I asked for donations to help get my hands of copies of FlexiSpy and MobileSpy (mostly because I was writing Kisses for free and was not in a position to pay over $200 for them) and thanks to some members of the phone community out there, I was able to get my hands on copies.  I was questioned as to why I asked for donations and they stated that even free anti-virus product companies don&#8217;t ask for donations.</li>
<li>One of them thinks my Kim Jong Il avatar (taken from Team America; very apt in this case I must say <img src='http://chirashi.zenconsult.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  ) on my twitter page makes me look very shady.</li>
</ul>
<p>So I now am going to dub these wonderful people who are protectors of the BlackBerry community as <strong>Team <span style="color: #ff0000;">Black</span><span style="color: #c0c0c0;">Berry</span><span style="color: #0000ff;">Forums</span></strong>.</p>
<p>I have to admit, though, that I respect them very much.  The are very dedicated and I hope that most of what they say comes from some place inside them where they want to protect other users.  For this, yes, I have to bow down and say that I&#8217;m impressed.</p>
<p>Right, now onto the reason why this sort of behavior is not very helpful.  First, I really don&#8217;t care if users don&#8217;t download and use my Kisses application.  I put it up there, because I wanted to give something back to users for free to help them protect themselves.  This was my only intention.</p>
<p>By making it appear to other users that I am evil because I wrote PhoneSnoop and now I&#8217;m writing Kisses, <strong>Team <span style="color: #ff0000;">Black</span><span style="color: #c0c0c0;">Berry</span><span style="color: #0000ff;">Forums</span></strong> are not being helpful to their users.  Its like in <a href="http://en.wikipedia.org/wiki/Green_Eggs_and_Ham" target="_blank">Green Eggs and Ham</a> &#8211; a pre-conceived notion before investigating things further. It would have been far more helpful to their users if they had verified things first before seemingly writing off the app as spyware.  To their credit, however, they did ask a lot of questions.  CrackBerry Forums just shut down the thread.  If they had researched what I <a href="http://www.slideshare.net/ch0pstick/spyware-presentation-at-hitb" target="_blank">presented in the Hack In The Box</a> security conference, they would known that there are far more creative ways of infecting BlackBerry users.  I tried to stress this point in my replies, but I guess their minds were already made up.</p>
<p>Lets <a href="http://dictionary.reference.com/browse/hypothetical" target="_blank">hypothetically</a> take the situation where I am someone evil and my only job is to spy on BlackBerry users.  I think I would have a far better chance of being stealthy.  I would certainly not highlight the fact that I can bug peoples phones and I surely would not release a proof-of-concept application.  This removes the element of stealth from my plan.  This is how I would do it, again, <a href="http://dictionary.reference.com/browse/hypothetical" target="_blank">hypothetically</a>.</p>
<p>I think <strong>Team <span style="color: #ff0000;">Black</span><span style="color: #c0c0c0;">Berry</span><span style="color: #0000ff;">Forums</span></strong> believes that by releasing a proof-of-concept tool makes me a terrorist of sorts.  They seem to think that nothing I do from now on can be trusted and is not well-intentioned.  Now I can see how they would think that.  But surely, they should be aware that if I had a serious need to read people&#8217;s email or tap their phone calls, I would find a way to do it?  And do it quietly?</p>
<p>Looking at my latest log file, I have 489 distinct downloads of Kisses.  I have had numerous emails from people asking me to support older versions of their BlackBerries and I have had lots of emails thanking me for releasing the free app.  I&#8217;m very happy that some people out there perceive the app as useful.  I think that&#8217;s enough for me.  So for the sake of those people out there, I will continue to develop Kisses and release it.  A big thanks go out to you guys.</p>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2009/11/team-blackberryforums-fuk-yeah/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

