Newer
Older
BLE_CTF_V2 / submit_flag.py
  1. #! /usr/bin/python
  2. import binascii
  3. import struct
  4. import sys, os, time
  5. import bluepy.btle as btle
  6. '''
  7.  
  8. '''
  9.  
  10. if len(sys.argv) != 2:
  11. print "submit password\n eg.", sys.argv[0], "<flag>"
  12. quit()
  13.  
  14. deviceMAC = open('ctf_mac.txt').read()
  15. p = btle.Peripheral(deviceMAC)
  16. print ("Attached to peripheral")
  17.  
  18. flag = sys.argv[1]
  19.  
  20. print("Submitting Password")
  21. p.writeCharacteristic(0x2E, flag, withResponse=False)
  22.  
  23. scoreboard = p.getServiceByUUID(0xFF)
  24. q = scoreboard.getCharacteristics()
  25. for characteristic in q:
  26. hex1 = int(format(characteristic.getHandle(),'02X'), 16)
  27. if (characteristic.supportsRead()):
  28. hexlif2 = characteristic.read()
  29. print (str(hex1)+" 0x"+ format(characteristic.getHandle(),'02X') +" "+ characteristic.propertiesToString() + " " + hexlif2)
  30. else:
  31. print (str(hex1)+" 0x"+ format(characteristic.getHandle(),'02X') +" "+ characteristic.propertiesToString() )
  32.  
  33. p.disconnect()
Buy Me A Coffee