Newer
Older
BLE_CTF_V2 / lvl_01.py
root on 11 Mar 2022 600 bytes tidying for public release
#! /usr/bin/python
import binascii
import struct
import sys, os, time
import bluepy.btle as btle
  
'''
42  0x2A   READ         goodbye

fc3fd58dcdad9ab23fac
'''

deviceMAC = open('ctf_mac.txt').read()  
p = btle.Peripheral(deviceMAC)
svc=p.getServiceByUUID(0x00FF)
print ("Attached to peripheral")

print("Loading level 1")
hex1 = binascii.unhexlify(str('%0*x' % (4,1)))
p.writeCharacteristic(0x30, hex1, withResponse=False)


print("Reading value")
hex1 = p.readCharacteristic(0x2C)
hex2 = binascii.b2a_hex(hex1) 
hexlif2 = str(binascii.unhexlify(hex2))
print("Flag: %s" % hexlif2)

p.disconnect()