NightRang3r / Broadlink-e-control-db-dump

These two scripts will "parse" the broadlink e-Control Android application database or SharedData and dump the IR / RF codes for selected accessories into a text file which can be later used with broadlink-python to send the codes to the RM PRO hub
149 stars 52 forks source link

IOS DB Support BroadLinkDeviceList.sqlite #31

Open xscope44 opened 4 years ago

xscope44 commented 4 years ago

Hi,

Was not able to use shared script for non rooted Android and since I have JB iPad i updated script to work with IOS DB.

import sqlite3 as lite

This script will "parse" the broadlink e-Control IOS application database and dump the IR / RF codes for selected accessories into a text file which can be later used with broadlink-python to send the codes to the RM PRO hub

You need to get the "BroadLinkDeviceList.sqlite" file from your (Jailbreaked) IOS device. the file is located in "var/mobile/Containers/Data/Application/[application e-control]/Documents/BroadLinkDeviceList.sqlite" and put it in the same folder as this script.

buttonIDS = [] buttonNames = []

e-Control Database file

con = lite.connect('BroadLinkDeviceList.sqlite')

Get All Accessories

with con: cur = con.cursor() cur.execute("SELECT subirID, name FROM broadlink_subir")

rows = cur.fetchall()

for row in rows:
    print "Accessory ID: " + str(row[0]) + " | Accessory Name: " + row[1].encode('utf-8')

Choose Accessory

accessory = input("Select Accessory ID: ")

cur.execute("SELECT name FROM broadlink_subir where subirID =" + str(accessory))

accessory_name = cur.fetchone()[0]

print "[+] You selected: " + accessory_name.encode('utf-8') print "[+] Dumping codes to " + accessory_name.encode('utf-8') + ".txt"

Get Buttons subirID

with con: cur = con.cursor() cur.execute("SELECT name, buttonID FROM broadlink_button where subIRId=" + str(accessory)) rows = cur.fetchall()

for row in rows:
    buttonIDS.append(row[1])
    buttonNames.append(row[0])

codesFile = open(accessory_name.encode('utf-8') + '.txt', 'w')

# Get Codes

for i in range(0, len(buttonIDS)):
    cur.execute("SELECT code FROM broadlink_code where buttonId=" + str(buttonIDS[i]))
    code = cur.fetchone()[0]
    result = "Button Name: " + buttonNames[i] + "| Button ID: " + str(buttonIDS[i]) + " | Code: " + str(code).encode('hex') + "\n"
    codesFile.writelines(result.encode('utf-8'))
codesFile.close()