Newer
Older
BLE_CTF_V2 / lvl_05.py
  1. #! /usr/bin/python
  2. import binascii
  3. import struct
  4. import sys, os, time
  5. import bluepy.btle as btle
  6. '''
  7. 42 0x2A READ find a valid write value in this pcap to use below
  8. 44 0x2C READ WRITE https://github.com/hackgnar/ble_ctf_infinity/blob/master/gatt_servers/pcap_write/write_sample.pcap
  9. 46 0x2E READ WRITE write here to goto to scoreboard
  10.  
  11. 84cf61c35b2d9c92217d
  12. '''
  13.  
  14. deviceMAC = open('ctf_mac.txt').read()
  15. p = btle.Peripheral(deviceMAC)
  16. svc=p.getServiceByUUID(0x00FF)
  17. print ("Attached to peripheral")
  18.  
  19. print("Loading level 05")
  20. hex1 = binascii.unhexlify(str('%0*x' % (4,5)))
  21. p.writeCharacteristic(0x30, hex1, withResponse=False)
  22.  
  23. print("Sending \"121212121222\" to 0x2c")
  24.  
  25. services=p.getServices()
  26.  
  27. hexlif2 = binascii.unhexlify("121212121222")
  28. hexlif2 = str(hexlif2)
  29. response = p.writeCharacteristic(0x2C, hexlif2, True)
  30.  
  31. print("Reading value")
  32. hex1 = p.readCharacteristic(0x2C)
  33. hex2 = binascii.b2a_hex(hex1)
  34. hexlif2 = str(binascii.unhexlify(hex2))
  35. print("Flag: %s" % hexlif2)
  36.  
  37. p.disconnect()
Buy Me A Coffee