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