Skip to main content

Bluetooth Low Energy : Build, Recon,Enumerate and Attack !

Introduction
In this post I will try to share some information on bluetooth low energy protocol. Bluetooth Low Energy ( BLE ) is Bluetooth 4.0.It has been widely used in creating "smart" devices like bulbs that can be controlled by mobile apps, or electrical switches that can be controlled by mobile apps. The terms Low Energy refers to multiple distinctive features that is operating on low power and lower data transfer.


Code


BLE Internals and Working
The next thing what we need to know is a profile. Now every bluetooth device can be categorized based on certain specification which makes it easy. Here we will take a close look into two profiles of Bluetooth which is specifically designed for BLE.
  • Generic Access Profile (GAP) - This profiles describes how two BLE devices defines discovery and establishment of connection with each other. There are two types of data payload that can be used. The Advertising Data Payload and Scan Response Payload. The GAP uses broadcast mechanism to send out the data payload.Now this advertisement process will only continue to work so longer the BLE device is not connected with any device.During the research I learn this as I was not able to find the device as it was paired with an android device. Once I unpaired or switched off the bluetooth in the android device , the scan showed up the BLE device. In the next image we can see how a advertising data payload looks like that is received from the BLE device that is under test.  


The another type of payload that is available is called  Scan Response Payload. This is generally  used to help designers to send extra information about the BLE device, like its name.
     


  • Generic Attribute Profile (GATT)  - After we connect to the device , the next step is all about data transfer. Here GATT protocol comes in picture.This profile describes how two BLE devices exchange data.  It uses the ATT Protocol which is a protocol that is  used to read and write certain attributes from and to the BLE devices.  GATT uses the concept of client server architecture. So here the BLE device will act as server and our android device as a client. In GATT we need to know few more terms i.e Profile , Service and Characteristics.

Profiles - Uniquely Classify the categories of BLE products like blood pressure , heart rate, etc

Service - Collection of characteristics which uniquely encapsulates a behavior. They are identified by Unique IDs.

Characteristics - They are basically data. The are meant to be read or written.





Enumeration
Enumerating  the BLE devices reveal lot of information on the service the BLE device provides.





BLE Target and Working

So we have few information about the services with us right now after the recon and enumeration

  • BLE Device MAC Address
  • The Generic Access
  • The Generic Attributes 
  • Device Information 
  • An unknown services ( Which I am most interested as an attacker )
Let us see how the entire set up behaves. If you review the code once you will find that for the value 'a' the LED switches ON and for the value 'b' it switches OFF.



From the bluetooth logs we can find more details about the services and we can confirm that the service ffe1 is used to control the LED light. The Service ID is same as that of the Unknown Service ID. So we can confirm now  that service is all about controlling LED.



Now that we know about the target BLE device's MAC, the BLE services's handle to switch ON or OFF the LED  and the characteristic value it expects to alter the state of the LED. Now with these information, we can attack the setup and inject values of 'a' and 'b' to switch ON or OFF the LED  without having access to the client / android app.




If you are from non-security background you might wonder whats the "BIG DEAL" about it ?

Well imagine that a company produces this setup in a mass and an attacker can compromise every device just by knowing how to hack one device.

References:
https://www.bluetooth.com/specifications/gatt/generic-attributes-overview
https://learn.adafruit.com/introduction-to-bluetooth-low-energy/
https://roboindia.com/tutorials/tutorial.php?tutorial_id=30


Popular posts from this blog

KringleCon : Sans Holiday Hack 2018 Writeup

SANS HOLIDAY HACK 2018 Writeup , KRINGLECON The objectives  Orientation Challenge  Directory Browsing  de Bruijn Sequences  Data Repo Analysis  AD Privilege Discovery  Badge Manipulation  HR Incident Response  Network Traffic Forensics  Ransomware Recovery  Who Is Behind It All? First I go to Bushy Evergreen and try to solve the terminal challenge . Solving it is fairly easy , Escape_Key followed by  ":q" without quotes After this we move to the kiosk and solve the questions The question were based on the themes of previous Holiday Hack Challenges. Once we answer it correctly we get the flag. For this I visited Minty Candycane and I tried to solve the terminal challenge.  The application has command injection vulnerability , so injecting a system command with the server ip allows execution of the command. So first I perform an `ls` operation to list of the directory contents , followed by a cat of t

Linux Privilege Escalation : SUID Binaries

After my OSCP Lab days are over I decided to do a little research and learn more on Privilege Escalation as it is my weak area.So over some series of blog post I am going to share with you some information of what I have learnt so far. The methods mentioned over here are not my own. This is something what I have learnt by reading articles, blogs and solving CTFs SUID - Set User ID The binaries which has suid enabled, runs with elevated privileges. Suppose you are logged in as non root user, but this suid bit enabled binaries can run with root privileges. How does a SUID Bit enable binary looks like ? -r- s r-x---  1 hack-me-bak-cracked hack-me-bak         7160 Aug 11  2015 bak How to find all the SUID enabled binaries ? hack-me-bak2@challenge02:~$ find / -perm -u=s 2>/dev/null /bin/su /bin/fusermount /bin/umount /usr/lib/openssh/ssh-keysign /usr/lib/eject/dmcrypt-get-device /usr/lib/dbus-1.0/dbus-daemon-launch-helper /usr/bin/gpasswd /usr/bin/newgrp /usr/bin