Thursday, May 22, 2014

Genymotion - Setting up for Android Studio & Titanium Appcelerator

I needed to test a new Android device today and decided it was time to give Genymotion a try. So far a great experience that has greatly simplified the installation and running of new emulators. Below are steps involved to get Genymotion running for both Android Studio and Titanium Appcelerator on a Mac (OS X 10.9.3)

Get Genymotion and dependencies


Get and install Virtual Box if you don't have it already, as this is a dependency:

https://www.virtualbox.org/wiki/Downloads


Get Genymotion:

https://shop.genymotion.com/index.php?controller=order-opc



Configure Development Environments

Configure for Android Studio

Android Studio --> Preferences --> Plugins

Click the button: "Install JetBrains Plugin..."

Select "Genymotion" from the link

Restart Android Studio



Run Genymotion

Install & run an emulator.


Go to Android Studio and the emulator should be available as an option as you build and launch your app.

Configure Titanium Appcelerator (Version 3.2)

Add config to Titanium from your shell.
ti config genymotion.enabled true

View config to verify you have a section for "Genymotion Emulators"
ti info -t android

Run Genymotion
Install & run an emulator.

Then you should be able to run the app in the emulator you ran in Genymotion from Titanium Studio.


Wednesday, May 21, 2014

Ubertooth Mac Installation Notes


Installation notes for the Ubertooth Bluetooth test tool on Mac OS X 10.9.3.

Installation was strait forward with a glitch or two from the description described on the Ubertooth site, so I've documented the process here for my own notes.

Project site: http://ubertooth.sourceforge.net/

Note the wiki: https://github.com/greatscottgadgets/ubertooth/wiki

Getting started URL: https://github.com/greatscottgadgets/ubertooth/wiki/Build-Guide

With some help from the troubleshooting guide, here: https://github.com/Homebrew/homebrew/wiki/troubleshooting.


Get PySide & QT if you want to run the spectrum analyzer demo:
http://qt-project.org/wiki/PySide_Binaries_MacOSX

Install Brew the Mac package manager if you don't yet have it:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Brew installation failed, so I (hesitatingly) changed /usr/local permissions:
sudo chowbn -R j2:admin /usr/local
Install prerequisites:
brew install libusb wget cmake
...including PyUSB:
wget https://github.com/walac/pyusb/archive/1.0.0b1.tar.gz -O pyusb-1.0.0b1.tar.gz
tar xvf pyusb-1.0.0b1.tar.gz
cd pyusb-1.0.0b1
sudo python setup.py install
The next step of installing libbtbb failed because a missing package:
brew install pkg-config
then libbtbb still couldn't install correctly, because of the failed partial installation. Uninstalling, didn't work, but manually removing the files from /usr/local/lib and the header file btbb.h in /usr/local/include. worked.

I was then able to install libbtbb:
wget https://github.com/greatscottgadgets/libbtbb/archive/2014-02-R2.tar.gz -O libbtbb-2014-02-R2.tar.gz
tar xf libbtbb-2014-02-R2.tar.gz
cd libbtbb-2014-02-R2
mkdir build
cd build
cmake ..
make
sudo make install
Then, I was able to continue with the installation as described on Ubertooth site:
wget https://github.com/greatscottgadgets/ubertooth/archive/2014-02-R2.tar.gz -O ubertooth-2014-02-R2.tar.gz
tar xf ubertooth-2014-02-R2.tar.gz
cd ubertooth-2014-02-R2/host
mkdir build
cd build
cmake ..
make
sudo make install
Then upgrade firmware of device. Mine shipped with a previous version of the firmware. So using the firmware provided in the source tree, and following these directions, this worked for me.

$ubertooth-util -v
    Firmware revision: 2012-10-R1

$cd ubertooth-2014-02-R2/ubertooth-one-firmware-bin

$ ubertooth-dfu --write bluetooth_rxtx.dfu
    Checking firmware signature
    No DFU devices found - attempting to find Ubertooth devices

    1) Found 'Ubertooth One' with USB ID: 1d50:6002

    Select a device to flash (default:1, exit:0):
             .............................................................................................................................................
    Write complete
$ ubertooth-dfu --detach
    Detached$ ubertooth-util -v
    Firmware revision: 2014-02-R2
$ ubertooth-util -V
    ubertooth 2014-02-R2 (dominicgs@mercury) Thu Feb 20 13:28:01 GMT 2014




Wednesday, September 11, 2013

Is your iPhone broadcasting your name via Bluetooth?

Very likely!

I developed BlueScan, an Android Bluetooth scanner, as a research project to better understand Bluetooth usage in the wild. The app scans for Bluetooth devices (Low Energy and Classic) and stores the results in a database on the phone which can then be downloaded for analysis.  As a mobile app, it allows me to identify nearby Bluetooth signals as I'm driving around town - essentially war driving for Bluetooth except that it's scanning passively - it just listens for broadcasts but does not initiate any connections.


Initial Observations: 

After a couple of days of on-again off-again scanning as I tested the app, I had a look at the data I had collected. The most obvious observation based a small dataset of 152 devices was that one quarter of the Apple users (mostly iPhones, iPads and Macbooks) were broadcasting their full names via Bluetooth

Here is the breakdown based on the 152 devices in the dataset:

  • 36 of the 152 devices were Apple devices
  • 9 of the Apple devices included both first name and last name identifier, as in "John Abraham's iPhone"
  • 19 of the Apple devices had just a first name identifier such as "John's MacBook Pro"
  • Only 8 of the 36 Apple devices were broadcasting but not including some sort of personal or device naming in their broadcasts

In infosec, we'd characterize this as unnecessary information disclosure. While information disclosure by itself is not always a high risk security issue in the enterprise information security realm, it's best practice to avoid doing so. In the consumer realm this is a privacy issue and you never how or when this kind of information can be used or aggregated with some other data. Given the number of Bluetooth scanners in public places thanks to the adoption of Bluetooth Low Energy and the boost from iBeacon, Apple users should be aware of this. 

Sunday, September 8, 2013

Considerations for Cross Platform App Development - Direct iOS/Androd SDK vs. Titanium Appcelerator

After having developed a number of apps on both iOS and Android, using both native SKDs as well as a cross platform development toolkit (Titanium Appcelerator) , I thought I'd reflect on some of the benefits and drawbacks that I experienced using Titanium as opposed to doing development directly in the native development environments. With more experience developing on Android with Java than on iOS with Objective-C, this comparison is based more on my specific Android/Java experience, though it's applicable to both.
  • Documentation: I found the Titanium Appcelerator documentation somewhat lacking in detail and incomplete. This issue is somewhat mitigated by the fact that the developer community Q&A site is active enough that answers to most questions can readily be found. However, I'm a big fan of Google's developer documentation in general and along with the over-abundance of StackOverflow activity, it's always a pleasure to develop in a Google environment.
  • Cross Platform Compilation. For the McRun Running Calculator of which we have an iOS version and an Android version, we developed first for iOS and released a couple of versions using Titanium Appcelerator getting the app stable on iOS before moving to Android. Development time for initial release was perhaps an 8-10 week project. This included working through UX considerations, directing graphic design, and also working thorough the process of implementing and testing the algorithm that is the core of the McRun app. Other than having to do additional graphic work (see below) to support android, much of this effort translated to Android with zero additional effort. However, while much of the backend code was easily ported to Android, most of the UI components had to be completely redone on Android. Appcelerator calls their cross platform framework as a "write once, adapt everywhere" platform, in which perhaps 80% to 100% of the code can be re-used. My experience is that now that we have revised the code to support both Android and iOS with conditional branching in the code (if (platform=="iOS" { // do iOS stuff } else { //do Android stuff }) and some conditional includes per platform, the code is now perhaps 90% compatible across both platforms. Eventually, we might strive to release updates on both platforms concurrently. Right now, we're one code base, and we release on one platform, then later do a release on another, and things get broken across platforms in the process. On our first Android build when the UI was so broken that app was in no way usable - complete jumbled spaghetti - fixing this and getting release ready was about a 3 week project. So from an effort perspective,  it required an additional 1/3 of the iOS development effort to release on Android.
  • Graphic Assets: Beyond the actual porting to Android, it's important to understand that the screen size and density permutations on Android is really extensive as compared to iOS which owns the entire hardware and software stack. Android development required multiple versions of graphics to support the various device configurations. This effort was wrapped into our porting effort mentioned above, but would have been required even if our app was purely an Android only app. iOS is easy in this respect - though I suspect this will change in the future.
  • Performance: I have found that Titanium performance on iOS to be very crispy. The load time is fast and the UI is very responsive. While the same app built on Titanium for Android suffers from extremely slow startup time. I suspect (and hope) this is an issue we'll be able to debug (more on this below) and resolve, but as of now, this remains an open issue and - for me - remains a big negative factor with Titanium Appcelerator.
  • Debugging: One challenge with Titanium Appcelerator is debugging on-device Android debugging. Developing directly in Java provides easy access to debug, error message, stack traces, etc. This is something I am still working through, so I may have more to say, but for now, I am still unclear on where my issue is on my app load performance issue on startup and on-device debugging capabilities aren't helping.
  • File size: An app built on the Titanium Appcelerator platform might be a 6MB Android APK file, whereas the same app built directly on Android with Java, would likely be less than 1MB; this is similar with iOS. While mobile devices are resource constrained on many levels, I don't believe that file storage is the biggest constraint. So, while this is definitely something to be aware of, this is not necessarily a deal breaker.
  • Hardware support: One benefit of using Titanium Appcelerator as compared to an HTML5 cross platform solution (at least the last time I checked) is that you get access (albeit indirectly) to the device APIs that control the hardware; so in theory as a developer you get full access to cameras, audio and sensors, such as the accelerometer.  Where this breaks down however, is where Appcelerator opts not to support an element of the API. For example, with BlueScan, my Android Bluetooth 4.0 scanner app research project, direct development in Java worked best as Titanium chose not to support Bluetooth. I have contacted Appcelerator directly and submitted an Issue that has been unresolved for months. Furthermore there are quite a few comments on the developer message boards that have gone unanswered by the Appcelerator team, so Bluetooth support doesn't appear to be on the horizon. There is a 3rd party module available but I didn't want to entrust my core code to a module that seemed to have limited usage and unproven support. Furthermore, as a research project, I needed to be tinkering at a lower level with Bluetooth capabilities, so I did not want to be abstracted from the API. Not all apps are appropriate for Titanium.
  • API Updates: One risk of using a framework like Appcelerator's Titanium is that their team needs to react and revise their platform as the underlying Android and iOS APIs evolve. I have seen a number of API updates (including the update to support the iPhone5) during my Appcelerator development cycles and was always surprised how quickly the Appcelerator team reacts to updates. This has never been an issue for me.
  • App store submittal: I haven't noticed any difference in my experience submitting to the app stores based on my development platform. As a security guy I like the Apple closed system, but as a developer Android is refreshingly simple and fast.

These are just my un-scientific observations. What's the best approach for cross platform development? I guess as with most anything, that really depends on the specific requirements, but there are merits to either approach.

Friday, September 6, 2013

Android: Java Adapters & Loaders

After porting the McRun iOS app to Android, I realized that using a cross platform framework was not going to work for my Bluetooth scanning data collection project as I needed better access to the radio hardware interfaces.  So I developed BlueScan directly on the Android SDK. While I am always a fan of Google's developer documentation, I found that the Java frameworks for adapters and loaders a bit abstract. As such I documented the framework for a very common development scenario: accessing a database and providing the results to a ListView with favorable UI performance.

The following diagram provides the overview of my class implementation to implement this in the BlueScan Bluetooth 4.0 scanner.


I leveraged a number of resources for getting my arms around the framework:

Thursday, April 4, 2013

Git - List files in repository

Here's a quick way to list files in your git repository: 


git log --pretty=format: --name-only --diff-filter=A | sort -




Tuesday, April 2, 2013

Flask / Python Web Development Resources

I've been doing some web development using a Python/Flask/PostgreSQL/Heroku stack. In the spirit of documenting some of my doings for my own reference, Below are some of the resources that I wanted to make note of. Some of the work I am doing is on my GitHub repository, while some of my mobile apps and anything that involves sensitive data is offline.

Flask

RESTful API

  • RESTful design blog post: An excellent discussion on RESTful APIs in general as well as API implementation with flask. This was particularly useful for the mobile API I am building.

Sessions and Login




Thursday, February 28, 2013

Heroku: API Unavailable

I went to update some content on my Heroku hosted Python/Flask app and was unable to upload / git push the app due to an "internal server error" and associated "We're investigating issues with an API database failure. We're recovering the database now" message.

Pretty scary, and not a confidence builder given it's my first week testing the service. However. on the upside the downtime (for me) was just a few minutes and the live production web app was still available during this time using the public URL.


Below is a log of the session.

Sunday, February 24, 2013

Idealist (sortable): Python, Flask, Jinja2, Javascript and Tablesorter

I've been experimenting with Python and the Flask web development framework. Combined with hosting on Heroku, I was surprised how quickly one could get a web app up and running. For my experiment this weekend, I created a sortable table of the business model and technology ideas from my previous blog post.

In the spirit of documenting my efforts, here are the ingredients to this micro app:
  • Python v2.7.1: An interpreted open source programming language, with an incredible number of modules/resources available
  • Flask: a Python-based web development language (BSD Liscense)
  • Jinja2: a Python-based templating engine for web development
  • Heroku: a cloud-based web application hosting platform
Below, is a sample of the result embedded from the live Heroku site, but since this Blogger blog platform seems to scrub Javascript from the iframe to be able to sort the list may have to go directly to the site hosted at Heroku.

<Note: this may take some time to load as it's hosted on a development Heroku dyno and goes into sleep mode when accessed sparsely.)



FBI Surveillance Van - WiFi Network

I've heard of people having fun with naming their WiFi networks with funny names and the FBI strategy is always mentioned. So I was amused this week as I was out to dinner with the kids in downtown Santa Barbara. I pulled out my iPhone and this is the network list that was found. Pretty funny to see the "FBI Surveillance Van" name used in the wild. While my first thought was, "ha ha, that's pretty funny," I must admit, I did have a gander out the window to see if there happend to be a blacked out van parked out front.