Newer
Older
BLE_CTF_V2 / send2handle.py
#! /usr/bin/python
import binascii
import struct
import sys, os, time
import bluepy.btle as btle
  

if len(sys.argv) != 3:
   print "send content to handle\n eg.", sys.argv[0], "0x30 \"some content\""
   quit()

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

handle = sys.argv[1]
content = sys.argv[2]

print("Sending \""+content+"\" to "+handle)

services=p.getServices()

hex_int = int(handle, 16)
new_int = hex_int + 0x200
print(hex_int)
hex1 = binascii.hexlify(handle)
#hex2 = binascii.unhexlify(str(content))
response = p.writeCharacteristic(hex_int, content, True)
print (response) 

p.disconnect()