Newer
Older
BLE_CTF_V2 / reset_scoreboard.py
  1. #! /usr/bin/python
  2. import binascii
  3. import struct
  4. import sys, os, time
  5. import bluepy.btle as btle
  6. chall_uuid = 0x32
  7. score_uuid = 0x00ff
  8.  
  9. deviceMAC = open('ctf_mac.txt').read()
  10. p = btle.Peripheral(deviceMAC)
  11. print ("Attached to peripheral")
  12. services=p.getServices()
  13.  
  14. print("Resetting scoreboard")
  15. hex1 = binascii.unhexlify("C1EA12")
  16. response = p.writeCharacteristic(chall_uuid, hex1, True)
  17. #print (response)
  18.  
  19. scoreboard = p.getServiceByUUID(score_uuid)
  20. #print(scoreboard)
  21. q = scoreboard.getCharacteristics()
  22. for characteristic in q:
  23. hex1 = int(format(characteristic.getHandle(),'02X'), 16)
  24. if (characteristic.supportsRead()):
  25. hex2 = binascii.b2a_hex(p.readCharacteristic(hex1))
  26. hexlif2 = binascii.unhexlify(hex2)
  27. print (str(hex1)+" 0x"+ format(characteristic.getHandle(),'02X') +" "+ characteristic.propertiesToString() + " " + hexlif2)
  28. p.disconnect()
Buy Me A Coffee