Skip to content

Instantly share code, notes, and snippets.

@hackgnar
Last active September 26, 2023 07:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save hackgnar/c9fd9bbf5a96fdd0d43f9f3a8c4e7aeb to your computer and use it in GitHub Desktop.
Save hackgnar/c9fd9bbf5a96fdd0d43f9f3a8c4e7aeb to your computer and use it in GitHub Desktop.
Ghetto Gatttool Bleah Output
#!/bin/bash
# run with the following syntax:
# ./ghetto_bleah.sh 11:22:33:44:55:66
mac=$1 ;
while read i;
do
printf "%s " $(echo -n $i|awk '{printf "%s : ", $1'});
printf "%s " $(echo -n $i|awk '{printf "%s : ", $3'});
#printf "%s : " $(echo -n $i|awk '{printf "%s", $2'});
j=$(printf "%.8d" $(echo "obase=2; ibase=12; $(echo -n $i|awk '{printf "%s", toupper($2)'}|cut -b3-)"|bc));
#printf "%s : " $j;
if [ $(echo -n $j |cut -b7) == "1" ]; then printf "READ "; else printf " "; fi;
if [ $(echo -n $j |cut -b5) == "1" ] || [ $(echo -n $j |cut -b6) == "1" ] ; then printf "WRITE "; else printf " "; fi;
if [ $(echo -n $j |cut -b4) == "1" ]; then printf "NOTIFY "; else printf " "; fi;
if [ $(echo -n $j |cut -b3) == "1" ]; then printf "INDICATE "; else printf " "; fi;
printf ": "
gatttool --char-read -b $mac -a $(echo -n $i|awk '{printf "%s : ", $1'}) |awk -F':' '{print $2}'|tr -d ' '|xxd -r -p; printf '\n' ;
done < <(sudo gatttool -b $mac --characteristics |awk '{print $12, $7, $15}' |tr -d ',')
@hackgnar
Copy link
Author

hackgnar commented Aug 3, 2019

to run, just copy this to a bash script and pass the mac address you want to scan as an argument. Example run looks as follows:
./ghetto_bleah.sh 11:22:33:44:55:66

Output will look as follows:

0x0003 : 00002a05-0000-1000-8000-00805f9b34fb :      WRITE NOTIFY          : Characteristic value/descriptor read failed: Attribute can't be read

0x0016 : 00002a00-0000-1000-8000-00805f9b34fb : READ                       : 2b00042f7481c7b056c4b410d28f33cf
0x0018 : 00002a01-0000-1000-8000-00805f9b34fb : READ                       : 
0x001a : 00002aa6-0000-1000-8000-00805f9b34fb : READ                       : 
0x002a : 0000ff01-0000-1000-8000-00805f9b34fb : READ                       : Score: 0/20
0x002c : 0000ff02-0000-1000-8000-00805f9b34fb : READ WRITE                 : Write Flags Here
0x002e : 0000ff03-0000-1000-8000-00805f9b34fb : READ                       : d205303e099ceff44835
0x0030 : 0000ff04-0000-1000-8000-00805f9b34fb : READ                       : MD5 of Device Name
0x0032 : 0000ff05-0000-1000-8000-00805f9b34fb : READ WRITE                 : Write anything here
0x0034 : 0000ff06-0000-1000-8000-00805f9b34fb : READ WRITE                 : Write the ascii value "yo" here
0x0036 : 0000ff07-0000-1000-8000-00805f9b34fb : READ WRITE                 : Write the hex value 0x07 here
0x0038 : 0000ff08-0000-1000-8000-00805f9b34fb : READ                       : Write 0xC9 to handle 58
0x003a : 0000ff09-0000-1000-8000-00805f9b34fb :      WRITE                 : Write 0xC9 to handle 58
0x003c : 0000ff0a-0000-1000-8000-00805f9b34fb : READ WRITE                 : Brute force my value 00 to ff
0x003e : 0000ff0b-0000-1000-8000-00805f9b34fb : READ                       : 6ffcd214ffebdc0d069e
0x0040 : 0000ff0c-0000-1000-8000-00805f9b34fb : READ WRITE NOTIFY          : Listen to me for a single notification
0x0042 : 0000ff0d-0000-1000-8000-00805f9b34fb : READ                       : Listen to handle 0x0044 for a single indication
0x0044 : 0000ff0e-0000-1000-8000-00805f9b34fb : READ              INDICATE : Listen to handle 0x0044 for a single indication
0x0046 : 0000ff0f-0000-1000-8000-00805f9b34fb : READ WRITE NOTIFY          : Listen to me for multi notifications
0x0048 : 0000ff10-0000-1000-8000-00805f9b34fb : READ                       : Listen to handle 0x004a for multi indications
0x004a : 0000ff11-0000-1000-8000-00805f9b34fb : READ              INDICATE : Listen to handle 0x004a for multi indications
0x004c : 0000ff12-0000-1000-8000-00805f9b34fb : READ                       : Connect with BT MAC address 11:22:33:44:55:66
0x004e : 0000ff13-0000-1000-8000-00805f9b34fb : READ                       : Set your connection MTU to 444
0x0050 : 0000ff14-0000-1000-8000-00805f9b34fb : READ WRITE                 : Write+resp 'hello'  
0x0052 : 0000ff15-0000-1000-8000-00805f9b34fb : READ WRITE                 : No notifications here! really?
0x0054 : 0000ff16-0000-1000-8000-00805f9b34fb : READ WRITE NOTIFY INDICATE : So many properties!
0x0056 : 0000ff17-0000-1000-8000-00805f9b34fb : READ                       : md5 of author's twitter handle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment