Tuesday, June 5, 2012

Installing the latest bluez software in ubuntu 12.04 along with the test suite tools

Compiling the bluez software in linux is fairly straight forward, but getting getting the bluez test applications to build can be a pain your first time doing it. The test tools included with the source give us many cool applications not typically installed with ubuntus binary bluez package (i.e. apt-get install bluez). One of the applications included in the test tools that I use all the time is bdaddr. The bluez bdaddr tool allows users to change thier bluetooth mac address which can be useful for mitm attacks on bluetooth devices.
This tutorial is really short, but it should save you tons of time if you have never done this before. The thing that hung me up my first time was the build dependancy in the test tools called "check". If check is not installed, the test tools build fails, but the rest of the bluez source is compiled. This can lead to some frustration if you cant figure out why your test tools are not being compiled. Lets get started...
First, lets install some required tools.
sudo apt-get install build-essential libdbus-1-dev check
Now, lets download the latest bluez software.
wget http://www.kernel.org/pub/linux/bluetooth/bluez-4.101.tar.gz
Now lets untar it.
tar xfvz bluez-4.101.tar.gz
Finally, lets build our package.
cd bluez-4.101
./configure --enable-test
If you want, you can now run "sudo make install" to install the binaries to your distro packages. I typically dont do this. Also, if you are looking for the bdaddr tool, it is built in the bluez source's "test" directory

Sunday, June 3, 2012

Installing the latest Kismet client and server with uberooth support in ubuntu 12.04

The following tutorial is a step by step guide on how I go about setting up Kismet with uberooth support on a fresh ubuntu 12.04 install. The guide will work on both 32 and 64 bit OS variants and can also be altered to work on other distros.
This tutorial assumes you already have a working ubertooth setup. If you do not, please follow my other guides on this site for setting up your ubertooth device.
First, I like to create a work directory for all my Source code, so lets create it and change to that directory:
mkdir ~/Source
cd ~/Source
We will need to install some packages for the task.
sudo apt-get install build-essential git subversion libncurses-dev libpcap-dev libnl-dev libpcre3-dev
Lets grab the latest Ubertooth source code and store it in a directory labeled ubertooth-latest:
svn co https://ubertooth.svn.sourceforge.net/svnroot/ubertooth ubertooth-latest
Now, lets download the latest kismet release:
wget http://www.kismetwireless.net/code/kismet-2011-03-R2.tar.gz
Now we can untar our kismet source and cd into the source directory.
tar xfvz kismet-2011-03-R2.tar.gz
cd cd kismet-2011-03-R2
We can now configure and compile and install our latest kismet code.
sudo make install
We must now compile our ubertooth kismet plugin. Assuming you checked out the latest ubertooth source in the same directory listed above, run the following.
cd ~/Source/ubertooth-latest/trunk/host/kismet/plugin-ubertooth
sudo KIS_SRC_DIR=~/Source/kismet-2011-03-R2 make install
The next steps are optional, but without them, you will not have bluetooth baseband pcap files and you will have to manually setup your uberooth device each time you start kismet server and client.
In your kismet conf file, find the "logtypes" line and append pcapbtbb to the end. The line in my conf file for logtypes is as follows.
I also like to include my ubertooth device in my conf file so it is up and working each time I fire up kismet. In order to do this, find the ncsource section of your kismet configuration file and add the following line.
There you have it, you should now be on your way to viewing bluetooth traffic in kismet with your uberooth device

Saturday, June 2, 2012

Compiling the newest firmware for the Ubertooth on Ubuntu 12.04

Keeping the firmware on your Ubertooth up to date with the latest code changes will give you access to the newest fixes and features available for the device. It is not clearly evident to all uses that the software for this device is in constant growth and not automatically updated, so this tutorial will help you quickly learn how you can sync your firmware with the latest greatest device code.
Learning how to do this for the first time can prove to be a daunting task if you have never compiled code with the gcc arm embedded compiler. This tutorial will walk you though step by step on the process for ubuntu 12.04 variants and should also work with minimal changes for other OS versions and variants. Also note, this tutorial will work for both 32 and 64 bit ubuntu operating systems.
First, I like to create a work directory for all my Source code, so lets create it and change to that directory:
mkdir ~/Source
cd ~/Source
We will need to install some packages for the task.
sudo apt-get install python-dev build-essential git subversion libusb-1.0-0-dev python-pip
sudo pip install pyusb
If you are on a 64 bit OS you will also need to install the following:
sudo apt-get install ia32-libs
Grab the latest gcc arm source code:
wget https://launchpad.net/gcc-arm-embedded/4.6/4.6-2012-q1-update/+download/gcc-arm-none-eabi-4_6-2012q1-20120316.tar.bz2
Lets grab the latest Ubertooth source code and store it in a directory labeled ubertooth-latest:
svn co https://ubertooth.svn.sourceforge.net/svnroot/ubertooth ubertooth-latest
We also need to grab the latest libbtbb source code. This is a library that supplies the ubertooth with datastructures and methods for housing and deriving information from bluetooth baseband packets:
git clone git://git.code.sf.net/p/libbtbb/code libbtbb-latest
Now, lets untar the gcc arm source code file we downloaded earlier:
tar xfvj gcc-arm-none-eabi-4_6-2012q1-20120316.tar.bz2
For compiling the ubertooth arm architecture source code, we will also need to specify where our new compiler lives. I typically do this each time before I compile the source, but if you like you could also add this line to your .bashrc file or install the arm gcc copiler to a bin (i.e. /usr/local/bin) directory in your base operating system.
export PATH=~/Source/gcc-arm-none-eabi-4_6-2012q1/bin:$PATH
Now, lets compile our libbtbb source code and install its shared libraries in our base operating system.
cd libbtbb-latest
sudo make install
Now lets compile our latest ubertooth firmware and host tools
cd uberooth-latest/trunk/firmware
And if you want, we can compile our latest ubertooth host code. These are the applications you can run in ~/Source/uberooth-latest/trunk/host/bluetooth_rxtx in order to use some of the ubertooths features. Note, the latest revisions of the uberooth code now uses shared libraries so we must now do a make install when compiling the uberooth toolset.
cd ~/Source/uberooth-latest/trunk/host/bluetooth_rxtx
sudo make install
Now, lets update our devices firmware. Make sure to plug in your uberooth device for this step. Note, these next few steps require sudo or root access. However, if you have setup your ubertooth device be accessible with non root privileges, you can do this as a less privileged user without sudo. For instructions on how to set up your device to be accessible without root privileges check out my other tutorials on this blog.
cd ~/Source/ubertooth-latest/trunk/host/bluetooth_rxtx
sudo ./uberooth-util -f
cd ~/Source/ubertooth-latest/trunk/host/usb_dfu
sudo ./ubertooth-dfu write ../../firmware/bluetooth_rxtx/bluetiith_rxtx.bin
Wait a few minutes for the firmware to finish writing, the lights on the ubertooth device will indicate that the transfer is complete although I can not remember what the actual indication looks like. When the transfer is complete, you can disconnect your ubertooth and then reconnect it.
If you want to verify the firmware version on the device, run the following:
cd ~/Source/ubertooth-latest/trunk/host/bluetooth_rxtx
sudo ./uberooth-util -v
You can then check it against you latest ubertooth svn revision code
cd ~/Source/ubertooth-latest
svn info
Congratulations, you now have an ubertooth with the latest firmware.

Friday, June 1, 2012

Setting udev usb permissions to use your Ubertooth (or usb) device as a regular user.

NOTE: The latest ubertooth source builds now instruct you on how to do this. You can follow their steps or use this if you like. The config changes in this tutorial are also helpful if you want non root access to your other usb devices.
I try to avoid running arbitrary software as root whenever possible. By applying this simple udev rule, you will not have to worry about running your ubertooth software with escalated privileges.
Also note, this tweak will work for all usb devices. This is helpful for me so my hcitool and hciconfig commands no longer require root.
This tutorial is for ubuntu 12.04, but will most likely work on older versions and similar distros.
To start, fire up your favorite editor and create a usb rules file in the /etc/udev/rules.d directory if id does not exist.
sudo vi /etc/udev/rules.d/45-usb.rules
Add this single line to the file. Replace USER_NAME with your users name. In ubuntu, each user has a group named after them, so this may differ on non ubuntu systems.
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="USER_NAME"
Thats it, plug in your ubertooth device and you should now be able to use its corresponding tools without root access.