Newer
Older
BLE_CTF_V2 / reset_scoreboard.py
#! /usr/bin/python
import binascii
import struct
import sys, os, time
import bluepy.btle as btle
  
chall_uuid = 0x32
score_uuid = 0x00ff

deviceMAC = open('ctf_mac.txt').read()  
p = btle.Peripheral(deviceMAC)
print ("Attached to peripheral")
services=p.getServices()

print("Resetting scoreboard")
hex1 = binascii.unhexlify("C1EA12")
response = p.writeCharacteristic(chall_uuid, hex1, True)
#print (response) 

scoreboard = p.getServiceByUUID(score_uuid)
#print(scoreboard)
q = scoreboard.getCharacteristics()
for characteristic in q:
  hex1 = int(format(characteristic.getHandle(),'02X'), 16)
  if (characteristic.supportsRead()):
     hex2 = binascii.b2a_hex(p.readCharacteristic(hex1))
     hexlif2 = binascii.unhexlify(hex2)
     print (str(hex1)+"  0x"+ format(characteristic.getHandle(),'02X')  +"   "+ characteristic.propertiesToString() + "	" + hexlif2)
  
p.disconnect()